-
Notifications
You must be signed in to change notification settings - Fork 0
/
extension.js
67 lines (49 loc) · 1.29 KB
/
extension.js
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
const Main = imports.ui.main;
let topBarClickListener_;
/*!
* Check if a window is active.
*/
function IsActiveWindow(window) {
let activeWorkspaceIndex = global.screen.get_active_workspace_index();
let metaWindow = window.get_meta_window();
let workspaceIndex = metaWindow.get_workspace().index();
return metaWindow.has_focus() && (workspaceIndex == activeWorkspaceIndex);
}
/*!
* Get the active window.
*/
function GetActiveWindow() {
let activeWindows = global.get_window_actors().filter(
function(window) {
return IsActiveWindow(window);
}
);
return ((activeWindows.length > 0) ? activeWindows[0] : null);
}
/*!
* Top bar click handler.
*/
function TopBarClick(_, event) {
if (event.get_button() == 2) {
// Middle click
// Get active window
let window = GetActiveWindow();
if (window != null) {
window.get_meta_window().lower();
}
}
}
/*!
* Enable extension.
*/
function enable() {
// Add listener to handle top bar clicks
topBarClickListener_ = Main.panel.actor.connect("button-press-event", TopBarClick);
}
/*!
* Disable extension.
*/
function disable() {
// Remove listener
Main.panel.actor.disconnect(topBarClickListener_);
}