Skip to content

Commit

Permalink
Merge pull request #9 from dstolpmann/master
Browse files Browse the repository at this point in the history
Hide minimized windows in screenshot UI
  • Loading branch information
danigm authored May 3, 2022
2 parents 8ef7fde + 971225c commit 703c8dd
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions extension.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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() {
}
Expand All @@ -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;
}
}

0 comments on commit 703c8dd

Please sign in to comment.