This file is indexed.

/usr/share/gnome-shell/extensions/pixel-saver@deadalnix.me/app_menu.js is in gnome-shell-extension-pixelsaver 1.10+git20161217-49f47bf-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
const Lang = imports.lang;
const Main = imports.ui.main;
const Mainloop = imports.mainloop;
const Shell = imports.gi.Shell;
const St = imports.gi.St;
const Tweener = imports.ui.tweener;

const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Util = Me.imports.util;

function LOG(message) {
	// log("[pixel-saver]: " + message);
}

function WARN(message) {
	log("[pixel-saver]: " + message);
}

let appMenu = null;

/**
 * AppMenu synchronization
 */
function updateAppMenu() {
	let win = global.display.focus_window;
	if (!win) {
		return false;
	}
	
	let title = win.title;
	
	// Not the topmost maximized window.
	if (win !== Util.getWindow()) {
		let app = Shell.WindowTracker.get_default().get_window_app(win);
		title = app.get_name();
	}
	
	LOG('Override title ' + title);
	appMenu._label.set_text(title);
	tooltip.text = title;
	
	return false;
}

/**
 * Track the focused window's title
 */
let activeWindow = null;
let awCallbackID = 0;
function changeActiveWindow(win) {
	if (win === activeWindow) {
		return;
	}
	
	if (activeWindow) {
		activeWindow.disconnect(awCallbackID);
	}
	
	activeWindow = win;
	
	if (win) {
		awCallbackID = win.connect('notify::title', updateAppMenu);
		updateAppMenu();
	}
}

/**
 * Focus change
 */
function onFocusChange() {
	let input_mode_check = (global.stage_input_mode === undefined)
		? true
		: global.stage_input_mode == Shell.StageInputMode.FOCUSED;
	if (!Shell.WindowTracker.get_default().focus_app && input_mode_check) {
		// If the app has just lost focus to the panel, pretend
		// nothing happened; otherwise you can't keynav to the
		// app menu.
		return false;
	}
	
	changeActiveWindow(global.display.focus_window);
	return false;
}

/**
 * tooltip
 */
let tooltip = null;
let showTooltip = false;

let SHOW_DELAY = 350;
let SHOW_DURATION = 0.15;
let HIDE_DURATION = 0.1;

let tooltipDelayCallbackID = 0;
let menuCallbackID = 0;

function resetMenuCallback() {
	if (menuCallbackID) {
		appMenu.menu.disconnect(menuCallbackID);
		menuCallbackID = 0;
	}
}

function onAppMenuHover(actor) {
	let hover = actor.get_hover();
	if (showTooltip === hover) {
		return false;
	}
	
	// We are not in the right state, let's fix that.
	showTooltip = hover;
	
	if (showTooltip) {
		tooltipDelayCallbackID = Mainloop.timeout_add(SHOW_DELAY, function() {
			if (!showTooltip) {
				WARN('showTooltip is false and delay callback ran.');
			}
			
			// Something wants us to stop.
			if (tooltipDelayCallbackID === 0) {
				return false;
			}
			
			let label = appMenu._label;
			if (!label.get_clutter_text().get_layout().is_ellipsized()) {
				// Do not need to hide.
				tooltipDelayCallbackID = 0;
				return false;
			}
			
			Main.uiGroup.add_actor(tooltip);
			
			resetMenuCallback();
			menuCallbackID = appMenu.menu.connect('open-state-changed', function(menu, open) {
				if (open) {
					Main.uiGroup.remove_actor(tooltip);
				} else {
					Main.uiGroup.add_actor(tooltip);
				}
			});
			
			[bx, by] = label.get_transformed_position();
			[w, h] = label.get_transformed_size();
			
			let y = by + h + 5;
			let x = bx - Math.round((tooltip.get_width() - w)/2);
			tooltip.opacity = 0;
			tooltip.set_position(x, y);
			
			LOG('show title tooltip');
			
			Tweener.removeTweens(tooltip);
			Tweener.addTween(tooltip, {
				opacity: 255,
				time: SHOW_DURATION,
				transition: 'easeOutQuad',
			});
			
			return false;
		});
	} else if (tooltipDelayCallbackID > 0) {
		// If the event ran, then we hide.
		LOG('hide title tooltip');
		
		resetMenuCallback();
		
		Tweener.removeTweens(tooltip);
		Tweener.addTween(tooltip, {
			opacity: 0,
			time: HIDE_DURATION,
			transition: 'easeOutQuad',
			onComplete: function() {
				Main.uiGroup.remove_actor(tooltip);
			}
		});
		
		tooltipDelayCallbackID = 0;
	}
	
	return false;
}

/**
 * Subextension hooks
 */
function init() {}

let wmCallbackIDs = [];
let focusCallbackID = 0;
let tooltipCallbackID = 0;

function enable() {
	appMenu = Main.panel.statusArea.appMenu;
	
	tooltip = new St.Label({
		style_class: 'tooltip dash-label',
		text: '',
		opacity: 0
	});
	
	wmCallbackIDs = wmCallbackIDs.concat(Util.onSizeChange(updateAppMenu));
	
	focusCallbackID = global.display.connect('notify::focus-window', onFocusChange);
	tooltipCallbackID = appMenu.actor.connect('notify::hover', onAppMenuHover);
}

function disable() {
	wmCallbackIDs.forEach(function(id) {
		global.window_manager.disconnect(id);
	});
	
	wmCallbackIDs = [];
	
	global.display.disconnect(focusCallbackID);
	focusCallbackID = 0;
	
	appMenu.actor.disconnect(tooltipCallbackID);
	tooltipCallbackID = 0;
	
	if (activeWindow) {
		activeWindow.disconnect(awCallbackID);
		awCallbackID = 0;
		activeWindow = null;
	}
	
	if (tooltipDelayCallbackID) {
		Mainloop.source_remove(tooltipDelayCallbackID);
		tooltipDelayCallbackID = 0;
	}
	
	resetMenuCallback();
	
	tooltip.destroy();
	tooltip = null;
}