Skip to content

Commit 90b1ac7

Browse files
jmmarananmmstick
authored andcommitted
fix(windowmgt): handle skiptaskbar across versions
1 parent d397cfb commit 90b1ac7

File tree

1 file changed

+73
-16
lines changed

1 file changed

+73
-16
lines changed

src/extension.ts

Lines changed: 73 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ const { layoutManager, loadTheme, overview, panel, setThemeStylesheet, screenShi
4747
const { ScreenShield } = imports.ui.screenShield;
4848
const { AppSwitcher, AppIcon, WindowSwitcherPopup } = imports.ui.altTab;
4949
const { SwitcherList } = imports.ui.switcherPopup;
50-
const { WindowPreview } = imports.ui.windowPreview;
5150
const { Workspace } = imports.ui.workspace;
5251
const { WorkspaceThumbnail } = imports.ui.workspaceThumbnail;
5352
const Tags = Me.imports.tags;
@@ -2541,14 +2540,33 @@ let default_isoverviewwindow_ws_thumbnail: any;
25412540
let default_init_appswitcher: any;
25422541
let default_getwindowlist_windowswitcher: any;
25432542
let default_getcaption_windowpreview: any;
2543+
let default_getcaption_workspace: any;
25442544

25452545
/**
25462546
* Decorates the default gnome-shell workspace/overview handling
25472547
* of skip_task_bar. And have those window types included in pop-shell.
25482548
* Should only be called on extension#enable()
2549+
*
2550+
* NOTE to future maintainer:
2551+
* Skip taskbar has been left out by upstream for a reason. And the
2552+
* Shell.WindowTracker seems to skip handling skip taskbar windows, so they are
2553+
* null or undefined. GNOME 40+ and lower version checking should be done to
2554+
* constantly support having them within pop-shell.
2555+
*
2556+
* Known skip taskbars ddterm, conky, guake, minimized to tray apps, etc.
2557+
*
2558+
* While minimize to tray are the target for this feature,
2559+
* skip taskbars that float/and avail workspace all
2560+
* need to added to config.ts as default floating
2561+
*
25492562
*/
25502563
function _show_skip_taskbar_windows() {
25512564
if (!GNOME_VERSION?.startsWith("40.")) {
2565+
// TODO GNOME 40 added a call to windowtracker and app var is not checked if null
2566+
// in WindowPreview._init(). Then new WindowPreview() is being called on
2567+
// _addWindowClone() of workspace.js.
2568+
// So it has to be skipped being overriden for now.
2569+
25522570
// Handle the overview
25532571
default_isoverviewwindow_ws = Workspace.prototype._isOverviewWindow;
25542572
Workspace.prototype._isOverviewWindow = function(window: any) {
@@ -2560,15 +2578,30 @@ function _show_skip_taskbar_windows() {
25602578
}
25612579

25622580
// Handle _getCaption errors
2563-
default_getcaption_windowpreview = WindowPreview.prototype._getCaption;
2564-
WindowPreview.prototype._getCaption = function() {
2565-
if (this.metaWindow.title)
2566-
return this.metaWindow.title;
2567-
2568-
let tracker = Shell.WindowTracker.get_default();
2569-
let app = tracker.get_window_app(this.metaWindow);
2570-
return app? app.get_name() : "";
2571-
};
2581+
if (GNOME_VERSION?.startsWith("3.36")) {
2582+
// imports.ui.windowPreview is not in 3.36,
2583+
// _getCaption() is still in workspace.js
2584+
default_getcaption_workspace = Workspace.prototype._getCaption;
2585+
Workspace.prototype._getCaption = function() {
2586+
if (this.metaWindow.title)
2587+
return this.metaWindow.title;
2588+
2589+
let tracker = Shell.WindowTracker.get_default();
2590+
let app = tracker.get_window_app(this.metaWindow);
2591+
return app? app.get_name() : "";
2592+
}
2593+
} else {
2594+
const { WindowPreview } = imports.ui.windowPreview;
2595+
default_getcaption_windowpreview = WindowPreview.prototype._getCaption;
2596+
WindowPreview.prototype._getCaption = function() {
2597+
if (this.metaWindow.title)
2598+
return this.metaWindow.title;
2599+
2600+
let tracker = Shell.WindowTracker.get_default();
2601+
let app = tracker.get_window_app(this.metaWindow);
2602+
return app? app.get_name() : "";
2603+
};
2604+
}
25722605

25732606
// Handle the workspace thumbnail
25742607
default_isoverviewwindow_ws_thumbnail =
@@ -2651,14 +2684,38 @@ function _show_skip_taskbar_windows() {
26512684
* This is the cleanup/restore of the decorator for skip_taskbar when pop-shell
26522685
* is disabled.
26532686
* Should only be called on extension#disable()
2687+
*
2688+
* Default functions should be checked if they exist,
2689+
* especially when skip taskbar setting was left on during an update
2690+
*
26542691
*/
26552692
function _hide_skip_taskbar_windows() {
26562693
if (!GNOME_VERSION?.startsWith("40.")) {
2657-
Workspace.prototype._isOverviewWindow = default_isoverviewwindow_ws;
2694+
if (default_isoverviewwindow_ws)
2695+
Workspace.prototype._isOverviewWindow = default_isoverviewwindow_ws;
2696+
}
2697+
2698+
if (GNOME_VERSION?.startsWith("3.36")) {
2699+
if (default_getcaption_workspace)
2700+
Workspace.prototype._getCaption = default_getcaption_workspace;
2701+
} else {
2702+
if (default_getcaption_windowpreview) {
2703+
const { WindowPreview } = imports.ui.windowPreview;
2704+
WindowPreview.prototype._getCaption =
2705+
default_getcaption_windowpreview;
2706+
}
2707+
}
2708+
2709+
if (default_isoverviewwindow_ws_thumbnail) {
2710+
WorkspaceThumbnail.prototype._isOverviewWindow =
2711+
default_isoverviewwindow_ws_thumbnail;
2712+
}
2713+
2714+
if (default_init_appswitcher)
2715+
AppSwitcher.prototype._init = default_init_appswitcher;
2716+
2717+
if (default_getwindowlist_windowswitcher) {
2718+
WindowSwitcherPopup.prototype._getWindowList =
2719+
default_getwindowlist_windowswitcher;
26582720
}
2659-
WindowPreview.prototype._getCaption = default_getcaption_windowpreview;
2660-
WorkspaceThumbnail.prototype._isOverviewWindow =
2661-
default_isoverviewwindow_ws_thumbnail;
2662-
AppSwitcher.prototype._init = default_init_appswitcher;
2663-
WindowSwitcherPopup.prototype._getWindowList = default_getwindowlist_windowswitcher;
26642721
}

0 commit comments

Comments
 (0)