diff --git a/extension.js b/extension.js old mode 100644 new mode 100755 index 26cbac3..0c468cb --- a/extension.js +++ b/extension.js @@ -1,7 +1,16 @@ +const Config = imports.misc.config; +const [major] = Config.PACKAGE_VERSION.split('.'); +const shellVersion = Number.parseInt(major); + const isOverviewWindow = imports.ui.workspace.Workspace.prototype._isOverviewWindow; const { Workspace } = imports.ui.workspace; const { altTab } = imports.ui; const { getWindows } = altTab; +if(shellVersion >= 42) { + var capture = imports.ui.screenshot.UIWindowSelector.prototype.capture; + var { UIWindowSelector, UIWindowSelectorWindow } = imports.ui.screenshot; + var Main = imports.ui.main; +} function init() { } @@ -18,9 +27,50 @@ function enable() { const windows = getWindows(workspace); return windows.filter((w, i, a) => !w.minimized); }; + if(shellVersion >= 42) { + // Patched version of original function from: + // https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/screenshot.js + UIWindowSelector.prototype.capture = function() { + for (const actor of global.get_window_actors()) { + let window = actor.metaWindow; + let workspaceManager = global.workspace_manager; + let activeWorkspace = workspaceManager.get_active_workspace(); + if (window.is_override_redirect() || + !window.located_on_workspace(activeWorkspace) || + window.get_monitor() !== this._monitorIndex || + window.minimized) + continue; + + const widget = new UIWindowSelectorWindow( + actor, + { + style_class: 'screenshot-ui-window-selector-window', + reactive: true, + can_focus: true, + toggle_mode: true, + } + ); + + widget.connect('key-focus-in', win => { + Main.screenshotUI.grab_key_focus(); + win.checked = true; + }); + + if (window.has_focus()) { + widget.checked = true; + widget.toggle_mode = false; + } + + this._layoutManager.addWindow(widget); + } + }; + } } function disable() { Workspace.prototype._isOverviewWindow = isOverviewWindow; altTab.getWindows = getWindows; + if(shellVersion >= 42) { + UIWindowSelector.prototype.capture = capture; + } }