Skip to content

Commit b76b83b

Browse files
jmmarananmmstick
authored andcommitted
fix: handle proton games in gnome 3.36
1 parent ab87042 commit b76b83b

File tree

1 file changed

+116
-100
lines changed

1 file changed

+116
-100
lines changed

src/extension.ts

Lines changed: 116 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -2567,138 +2567,154 @@ function _show_skip_taskbar_windows(ext: Ext) {
25672567
// So it has to be skipped being overriden for now.
25682568

25692569
// Handle the overview
2570-
if (!default_isoverviewwindow_ws)
2570+
if (!default_isoverviewwindow_ws) {
25712571
default_isoverviewwindow_ws = Workspace.prototype._isOverviewWindow;
2572-
Workspace.prototype._isOverviewWindow = function(win: any) {
2573-
let meta_win = win;
2574-
if (GNOME_VERSION?.startsWith("3.36"))
2575-
meta_win = win.get_meta_window();
2572+
Workspace.prototype._isOverviewWindow = function(win: any) {
2573+
let meta_win = win;
2574+
if (GNOME_VERSION?.startsWith("3.36"))
2575+
meta_win = win.get_meta_window();
25762576

2577-
// wm_class Gjs needs to be skipped to prevent the ghost window in
2578-
// workspace and overview
2579-
let show_skiptb = !cfg.skiptaskbar_shall_hide(meta_win);
2580-
return (show_skiptb && meta_win.skip_taskbar && meta_win.get_wm_class() !== "Gjs") ||
2581-
default_isoverviewwindow_ws(win);
2582-
};
2577+
let show_skiptb = !cfg.skiptaskbar_shall_hide(meta_win);
2578+
return (show_skiptb && meta_win.skip_taskbar &&
2579+
// ignore wm_class == null + Gjs and
2580+
// are skip taskbar true
2581+
(meta_win.get_wm_class() !== null &&
2582+
meta_win.get_wm_class() !== "Gjs")) ||
2583+
default_isoverviewwindow_ws(win);
2584+
};
2585+
}
25832586
}
25842587

25852588
// Handle _getCaption errors
25862589
if (GNOME_VERSION?.startsWith("3.36")) {
25872590
// imports.ui.windowPreview is not in 3.36,
25882591
// _getCaption() is still in workspace.js
2589-
if (!default_getcaption_workspace)
2592+
if (!default_getcaption_workspace) {
25902593
default_getcaption_workspace = Workspace.prototype._getCaption;
2591-
Workspace.prototype._getCaption = function() {
2592-
if (this.metaWindow.title)
2593-
return this.metaWindow.title;
2594-
2595-
let tracker = Shell.WindowTracker.get_default();
2596-
let app = tracker.get_window_app(this.metaWindow);
2597-
return app? app.get_name() : "";
2594+
// 3.36 _getCaption
2595+
Workspace.prototype._getCaption = function() {
2596+
let metaWindow = this._windowClone.metaWindow;
2597+
if (metaWindow.title)
2598+
return metaWindow.title;
2599+
2600+
let tracker = Shell.WindowTracker.get_default();
2601+
let app = tracker.get_window_app(metaWindow);
2602+
return app ? app.get_name() : "";
2603+
}
25982604
}
25992605
} else {
26002606
const { WindowPreview } = imports.ui.windowPreview;
2601-
if (!default_getcaption_windowpreview)
2607+
if (!default_getcaption_windowpreview) {
26022608
default_getcaption_windowpreview = WindowPreview.prototype._getCaption;
2603-
WindowPreview.prototype._getCaption = function() {
2604-
if (this.metaWindow.title)
2605-
return this.metaWindow.title;
2609+
log.debug(`override workspace._getCaption`);
2610+
// 3.38 _getCaption
2611+
WindowPreview.prototype._getCaption = function() {
2612+
if (this.metaWindow.title)
2613+
return this.metaWindow.title;
26062614

2607-
let tracker = Shell.WindowTracker.get_default();
2608-
let app = tracker.get_window_app(this.metaWindow);
2609-
return app? app.get_name() : "";
2610-
};
2615+
let tracker = Shell.WindowTracker.get_default();
2616+
let app = tracker.get_window_app(this.metaWindow);
2617+
return app ? app.get_name() : "";
2618+
};
2619+
}
26112620
}
26122621

26132622
// Handle the workspace thumbnail
2614-
if (!default_isoverviewwindow_ws_thumbnail)
2623+
if (!default_isoverviewwindow_ws_thumbnail) {
26152624
default_isoverviewwindow_ws_thumbnail =
26162625
WorkspaceThumbnail.prototype._isOverviewWindow;
2617-
WorkspaceThumbnail.prototype._isOverviewWindow = function (win: any) {
2618-
let meta_win = win.get_meta_window();
2619-
// wm_class Gjs needs to be skipped to prevent the ghost window in
2620-
// workspace and overview
2621-
let show_skiptb = !cfg.skiptaskbar_shall_hide(meta_win);
2622-
return (show_skiptb && meta_win.skip_taskbar && meta_win.get_wm_class() !== "Gjs") ||
2623-
default_isoverviewwindow_ws_thumbnail(win);
2624-
};
2626+
WorkspaceThumbnail.prototype._isOverviewWindow = function (win: any) {
2627+
let meta_win = win.get_meta_window();
2628+
// wm_class Gjs needs to be skipped to prevent the ghost window in
2629+
// workspace and overview
2630+
let show_skiptb = !cfg.skiptaskbar_shall_hide(meta_win);
2631+
return (show_skiptb && meta_win.skip_taskbar &&
2632+
// ignore wm_class == null + Gjs and
2633+
// are skip taskbar true
2634+
(meta_win.get_wm_class() !== null &&
2635+
meta_win.get_wm_class() !== "Gjs")) ||
2636+
default_isoverviewwindow_ws_thumbnail(win);
2637+
};
2638+
}
26252639

26262640
// Handle switch-applications
2627-
if (!default_init_appswitcher)
2641+
if (!default_init_appswitcher) {
26282642
default_init_appswitcher = AppSwitcher.prototype._init;
2629-
// Do not use the Shell.AppSystem apps
2630-
AppSwitcher.prototype._init = function(_apps: any, altTabPopup: any) {
2631-
// Simulate super._init(true);
2632-
SwitcherList.prototype._init.call(this, true);
2633-
this.icons = [];
2634-
this._arrows = [];
2635-
2636-
let windowTracker = Shell.WindowTracker.get_default();
2637-
let settings = new Gio.Settings({ schema_id: 'org.gnome.shell.app-switcher' });
2638-
2639-
let workspace = null;
2640-
if (settings.get_boolean('current-workspace-only')) {
2641-
let workspaceManager = global.workspace_manager;
2642-
workspace = workspaceManager.get_active_workspace();
2643-
}
2644-
2645-
let allWindows = global.display.get_tab_list(Meta.TabList.NORMAL_ALL, workspace);
2646-
let allRunningSkipTaskbarApps = allWindows.filter((w,i,a) => {
2647-
if (w) {
2648-
let found_idx: any;
2649-
// Find the first instance using wm_class
2650-
for (let index = 0; index < a.length; index++) {
2651-
if (a[index].get_wm_class() === w.get_wm_class()) {
2652-
found_idx = index;
2653-
break;
2643+
// Do not use the Shell.AppSystem apps
2644+
AppSwitcher.prototype._init = function(_apps: any, altTabPopup: any) {
2645+
// Simulate super._init(true);
2646+
SwitcherList.prototype._init.call(this, true);
2647+
this.icons = [];
2648+
this._arrows = [];
2649+
2650+
let windowTracker = Shell.WindowTracker.get_default();
2651+
let settings = new Gio.Settings({ schema_id: 'org.gnome.shell.app-switcher' });
2652+
2653+
let workspace = null;
2654+
if (settings.get_boolean('current-workspace-only')) {
2655+
let workspaceManager = global.workspace_manager;
2656+
workspace = workspaceManager.get_active_workspace();
2657+
}
2658+
2659+
let allWindows = global.display.get_tab_list(Meta.TabList.NORMAL_ALL, workspace);
2660+
let allRunningSkipTaskbarApps = allWindows.filter((w,i,a) => {
2661+
if (w) {
2662+
let found_idx: any;
2663+
// Find the first instance using wm_class
2664+
for (let index = 0; index < a.length; index++) {
2665+
if (a[index].get_wm_class() === w.get_wm_class()) {
2666+
found_idx = index;
2667+
break;
2668+
}
26542669
}
2670+
return found_idx == i;
26552671
}
2656-
return found_idx == i;
2657-
}
2658-
});
2672+
});
26592673

2660-
for (let i = 0; i < allRunningSkipTaskbarApps.length; i++) {
2661-
let meta_win = allRunningSkipTaskbarApps[i];
2662-
let show_skiptb = !cfg.skiptaskbar_shall_hide(meta_win);
2663-
if (meta_win.is_skip_taskbar() && !show_skiptb) continue;
2664-
let appIcon = new AppIcon(windowTracker.get_window_app(meta_win));
2665-
appIcon.cachedWindows = allWindows.filter(
2666-
w => windowTracker.get_window_app(w) === appIcon.app);
2667-
if (appIcon.cachedWindows.length > 0)
2668-
this._addIcon(appIcon);
2669-
}
2674+
for (let i = 0; i < allRunningSkipTaskbarApps.length; i++) {
2675+
let meta_win = allRunningSkipTaskbarApps[i];
2676+
let show_skiptb = !cfg.skiptaskbar_shall_hide(meta_win);
2677+
if (meta_win.is_skip_taskbar() && !show_skiptb) continue;
2678+
let appIcon = new AppIcon(windowTracker.get_window_app(meta_win));
2679+
appIcon.cachedWindows = allWindows.filter(
2680+
w => windowTracker.get_window_app(w) === appIcon.app);
2681+
if (appIcon.cachedWindows.length > 0)
2682+
this._addIcon(appIcon);
2683+
}
26702684

2671-
this._curApp = -1;
2672-
this._altTabPopup = altTabPopup;
2673-
this._mouseTimeOutId = 0;
2685+
this._curApp = -1;
2686+
this._altTabPopup = altTabPopup;
2687+
this._mouseTimeOutId = 0;
26742688

2675-
this.connect('destroy', this._onDestroy.bind(this));
2689+
this.connect('destroy', this._onDestroy.bind(this));
2690+
}
26762691
}
26772692

26782693
// Handle switch-windows
2679-
if (!default_getwindowlist_windowswitcher)
2694+
if (!default_getwindowlist_windowswitcher) {
26802695
default_getwindowlist_windowswitcher = WindowSwitcherPopup.prototype._getWindowList;
2681-
WindowSwitcherPopup.prototype._getWindowList = function() {
2682-
let workspace = null;
2683-
2684-
if (this._settings.get_boolean('current-workspace-only')) {
2685-
let workspaceManager = global.workspace_manager;
2686-
workspace = workspaceManager.get_active_workspace();
2687-
}
2688-
2689-
let windows = global.display.get_tab_list(Meta.TabList.NORMAL_ALL,
2690-
workspace);
2691-
return windows.map(w => {
2692-
let show_skiptb = !cfg.skiptaskbar_shall_hide(w);
2693-
let meta_window = w.is_attached_dialog() ? w.get_transient_for() : w;
2694-
if (meta_window) {
2695-
if (!meta_window.is_skip_taskbar() ||
2696-
meta_window.is_skip_taskbar() && show_skiptb) {
2697-
return meta_window;
2698-
}
2696+
WindowSwitcherPopup.prototype._getWindowList = function() {
2697+
let workspace = null;
2698+
2699+
if (this._settings.get_boolean('current-workspace-only')) {
2700+
let workspaceManager = global.workspace_manager;
2701+
workspace = workspaceManager.get_active_workspace();
26992702
}
2700-
return null;
2701-
}).filter((w, i, a) => w != null && a.indexOf(w) == i);
2703+
2704+
let windows = global.display.get_tab_list(Meta.TabList.NORMAL_ALL,
2705+
workspace);
2706+
return windows.map(w => {
2707+
let show_skiptb = !cfg.skiptaskbar_shall_hide(w);
2708+
let meta_window = w.is_attached_dialog() ? w.get_transient_for() : w;
2709+
if (meta_window) {
2710+
if (!meta_window.is_skip_taskbar() ||
2711+
meta_window.is_skip_taskbar() && show_skiptb) {
2712+
return meta_window;
2713+
}
2714+
}
2715+
return null;
2716+
}).filter((w, i, a) => w != null && a.indexOf(w) == i);
2717+
}
27022718
}
27032719
}
27042720

0 commit comments

Comments
 (0)