forked from broxen/ShowDesktopFromOverview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension.js
50 lines (42 loc) · 1.95 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
/*
* Show Desktop from Overview
* Very small extension which minimizes all windows when you click on an empty space in the windows-overview-mode.
*
* Contact:
* https://github.com/Bazon/ShowDesktopFromOverview/tree/master or [email protected]
* Feel free to send improvments!
*/
const Main = imports.ui.main;
const Shell = imports.gi.Shell;
var connectid = null;
var reactiveBefore = null;
function _showDesktop() {
//TODO: when public, do that by meta_screen_show_desktop();
let activeWorkspace = global.screen.get_active_workspace();
let tracker = Shell.WindowTracker.get_default();
let windows = activeWorkspace.list_windows();
for (let i = 0; i < windows.length; i++) {
//New in V3&4: tracker.is_window_interesting checks whether this is a real window and not a desktop icon
if (!windows[i].minimized && (windows[i].get_window_type() == 0) && !(windows[i].get_title().indexOf("Conky") >= 0)) {
windows[i].minimize();
}
}
Main.overview.hide();
}
function init() {
reactiveBefore=Main.overview.viewSelector._workspacesDisplay.actor.reactive;
//normal: false. but maybe set by another extension.
}
function enable() {
Main.overview.viewSelector._workspacesDisplay.actor.reactive=true;
connectid = Main.overview.viewSelector._workspacesDisplay.actor.connect('button-press-event', _showDesktop);
//if you want to swipe workspaces (like Dr_g00f in comments) from overview use this instead:
//connectid = Main.overview._viewSelector._workspacesDisplay.actor.connect('button-release-event', _showDesktop);
//in Gnome-Shell 3.6: shows desktop when button released
//in Gnome-Shell 3.8: shows desktop when desktop is doubleclicked. whyever.
}
function disable() {
//set back to default value which is normally false.
Main.overview.viewSelector._workspacesDisplay.actor.reactive=reactiveBefore;
Main.overview.viewSelector._workspacesDisplay.actor.disconnect(connectid);
}