58c40761d1d32b081962a9f9d86bba654e345547
[show-app-menu-on-key-press] / extension.js
1 const St = imports.gi.St;
2 const Main = imports.ui.main;
3 const Views = imports.ui.appDisplay.Views;
4
5 let signalId = null;
6
7 function init() {
8 }
9
10 function enable() {
11 signalId = global.stage.connect('key-press-event', onStageKeyPress);
12 }
13
14 function disable() {
15 if (signalId) {
16 global.stage.disconnect('key-press-event');
17 signalId = null;
18 }
19 }
20
21 function onStageKeyPress() {
22 if (!hasVisibleWindows() && !Main.overview.visible) {
23 Main.overview.viewSelector.showApps();
24 Main.overview.viewSelector.appDisplay._showView(Views.FREQUENT);
25 Main.overview.viewSelector._activePage.navigate_focus(null, St.DirectionType.TAB_FORWARD, false);
26 }
27 }
28
29 function hasVisibleWindows() {
30 return global.display.get_tab_list(0, null).find((w) => !w.is_hidden());
31 }
32