|
1 |
| -const Config = imports.misc.config; |
2 |
| -const [major] = Config.PACKAGE_VERSION.split('.'); |
3 |
| -const shellVersion = Number.parseInt(major); |
4 |
| - |
5 |
| -const isOverviewWindow = imports.ui.workspace.Workspace.prototype._isOverviewWindow; |
6 |
| -const { Workspace } = imports.ui.workspace; |
7 |
| -const { altTab } = imports.ui; |
8 |
| -const { getWindows } = altTab; |
9 |
| -if(shellVersion >= 42) { |
10 |
| - var capture = imports.ui.screenshot.UIWindowSelector.prototype.capture; |
11 |
| - var { UIWindowSelector, UIWindowSelectorWindow } = imports.ui.screenshot; |
12 |
| - var Main = imports.ui.main; |
13 |
| -} |
| 1 | +import { Workspace } from 'resource:///org/gnome/shell/ui/workspace.js' |
| 2 | +import { |
| 3 | + GroupCyclerPopup, |
| 4 | + WindowCyclerPopup, |
| 5 | + WindowSwitcherPopup, |
| 6 | +} from 'resource:///org/gnome/shell/ui/altTab.js' |
| 7 | + |
| 8 | +// import { UIWindowSelector, UIWindowSelectorWindow } from 'resource:///org/gnome/shell/ui/screenshot.js' |
| 9 | +// import * as Main from 'resource:///org/gnome/shell/ui/main.js'; |
| 10 | + |
| 11 | +const isOverviewWindow = Workspace.prototype._isOverviewWindow; |
| 12 | +const groupGetWindows = GroupCyclerPopup.prototype._getWindows; |
| 13 | +const windowGetWindows = WindowCyclerPopup.prototype._getWindows; |
| 14 | +const windowSwitcherWindows = WindowSwitcherPopup.prototype._getWindowList; |
| 15 | + |
| 16 | +// const capture = UIWindowSelector.prototype.capture; |
| 17 | + |
14 | 18 |
|
15 |
| -function init() { |
| 19 | +function _filterWindows(windows) { |
| 20 | + return windows.filter((w, i, a) => !w.minimized); |
16 | 21 | }
|
17 | 22 |
|
18 |
| -function enable() { |
19 |
| - Workspace.prototype._isOverviewWindow = (win) => { |
20 |
| - const show = isOverviewWindow(win); |
21 |
| - let meta = win; |
22 |
| - if (win.get_meta_window) |
23 |
| - meta = win.get_meta_window() |
24 |
| - return show && !meta.minimized; |
25 |
| - }; |
26 |
| - altTab.getWindows = (workspace) => { |
27 |
| - const windows = getWindows(workspace); |
28 |
| - return windows.filter((w, i, a) => !w.minimized); |
29 |
| - }; |
30 |
| - if(shellVersion >= 42) { |
| 23 | + |
| 24 | +export default class HideMinimized { |
| 25 | + constructor() { |
| 26 | + } |
| 27 | + |
| 28 | + enable() { |
| 29 | + Workspace.prototype._isOverviewWindow = (win) => { |
| 30 | + const show = isOverviewWindow(win); |
| 31 | + let meta = win; |
| 32 | + if (win.get_meta_window) |
| 33 | + meta = win.get_meta_window() |
| 34 | + return show && !meta.minimized; |
| 35 | + }; |
| 36 | + |
| 37 | + WindowCyclerPopup.prototype._getWindows = function() { |
| 38 | + return _filterWindows(windowGetWindows.bind(this)()); |
| 39 | + }; |
| 40 | + |
| 41 | + GroupCyclerPopup.prototype._getWindows = function() { |
| 42 | + return _filterWindows(groupGetWindows.bind(this)()); |
| 43 | + }; |
| 44 | + |
| 45 | + WindowSwitcherPopup.prototype._getWindowList = function() { |
| 46 | + return _filterWindows(windowSwitcherWindows.bind(this)()); |
| 47 | + }; |
| 48 | + |
| 49 | + /* |
31 | 50 | // Patched version of original function from:
|
32 | 51 | // https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/screenshot.js
|
33 | 52 | UIWindowSelector.prototype.capture = function() {
|
@@ -64,13 +83,14 @@ function enable() {
|
64 | 83 | this._layoutManager.addWindow(widget);
|
65 | 84 | }
|
66 | 85 | };
|
| 86 | + */ |
67 | 87 | }
|
68 |
| -} |
69 | 88 |
|
70 |
| -function disable() { |
71 |
| - Workspace.prototype._isOverviewWindow = isOverviewWindow; |
72 |
| - altTab.getWindows = getWindows; |
73 |
| - if(shellVersion >= 42) { |
74 |
| - UIWindowSelector.prototype.capture = capture; |
| 89 | + disable() { |
| 90 | + Workspace.prototype._isOverviewWindow = isOverviewWindow; |
| 91 | + WindowCyclerPopup.prototype._getWindows = windowGetWindows; |
| 92 | + GroupCyclerPopup.prototype._getWindows = groupGetWindows; |
| 93 | + WindowSwitcherPopup.prototype._getWindowList = windowSwitcherWindows; |
| 94 | + // UIWindowSelector.prototype.capture = capture; |
75 | 95 | }
|
76 | 96 | }
|
0 commit comments