Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling skip taskbar on LTS and latest #1069

Merged
merged 3 commits into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions schemas/org.gnome.shell.extensions.pop-shell.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
<summary>Show title bars on windows with server-side decorations</summary>
</key>

<key type="b" name="show-skip-taskbar">
<default>false</default>
<summary>Handle skip taskbar windows or windows with minimized to tray option</summary>
</key>

<!-- Tiling Options -->
<key type="u" name="column-size">
<default>64</default>
Expand Down
121 changes: 100 additions & 21 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,13 @@ export class Ext extends Ecs.System<ExtEvent> {
case 'smart-gaps':
this.on_smart_gap();
this.show_border_on_focused();
break;
case 'show-skip-taskbar':
if (this.settings.show_skiptaskbar()) {
_show_skip_taskbar_windows();
} else {
_hide_skip_taskbar_windows();
}
}
});

Expand Down Expand Up @@ -2404,10 +2411,6 @@ export class Ext extends Ecs.System<ExtEvent> {

let ext: Ext | null = null;
let indicator: Indicator | null = null;
let default_isoverviewwindow_ws: any;
let default_isoverviewwindow_ws_thumbnail: any;
let default_init_appswitcher: any;
let default_getwindowlist_windowswitcher: any;

// @ts-ignore
function init() {
Expand All @@ -2418,8 +2421,6 @@ function init() {
function enable() {
log.info("enable");

_show_skip_taskbar_windows();

if (!ext) {
ext = new Ext();

Expand Down Expand Up @@ -2455,8 +2456,6 @@ function enable() {
function disable() {
log.info("disable");

_hide_skip_taskbar_windows();

if (ext) {
if (sessionMode.isLocked) {
ext.was_locked = true;
Expand Down Expand Up @@ -2536,20 +2535,73 @@ function* iter_workspaces(manager: any): IterableIterator<[number, any]> {
}
}

let default_isoverviewwindow_ws: any;
let default_isoverviewwindow_ws_thumbnail: any;
let default_init_appswitcher: any;
let default_getwindowlist_windowswitcher: any;
let default_getcaption_windowpreview: any;
let default_getcaption_workspace: any;

/**
* Decorates the default gnome-shell workspace/overview handling
* of skip_task_bar. And have those window types included in pop-shell.
* Should only be called on extension#enable()
*
* NOTE to future maintainer:
* Skip taskbar has been left out by upstream for a reason. And the
* Shell.WindowTracker seems to skip handling skip taskbar windows, so they are
* null or undefined. GNOME 40+ and lower version checking should be done to
* constantly support having them within pop-shell.
*
* Known skip taskbars ddterm, conky, guake, minimized to tray apps, etc.
*
* While minimize to tray are the target for this feature,
* skip taskbars that float/and avail workspace all
* need to added to config.ts as default floating
*
*/
function _show_skip_taskbar_windows() {
// Handle the overview
default_isoverviewwindow_ws = Workspace.prototype._isOverviewWindow;
Workspace.prototype._isOverviewWindow = function(window: any) {
// wm_class Gjs needs to be skipped to prevent the ghost window in
// workspace and overview
return (window.skip_taskbar && window.get_wm_class() !== "Gjs") ||
default_isoverviewwindow_ws(window);
};
if (!GNOME_VERSION?.startsWith("40.")) {
// TODO GNOME 40 added a call to windowtracker and app var is not checked if null
// in WindowPreview._init(). Then new WindowPreview() is being called on
// _addWindowClone() of workspace.js.
// So it has to be skipped being overriden for now.

// Handle the overview
default_isoverviewwindow_ws = Workspace.prototype._isOverviewWindow;
Workspace.prototype._isOverviewWindow = function(window: any) {
// wm_class Gjs needs to be skipped to prevent the ghost window in
// workspace and overview
return (window.skip_taskbar && window.get_wm_class() !== "Gjs") ||
default_isoverviewwindow_ws(window);
};
}

// Handle _getCaption errors
if (GNOME_VERSION?.startsWith("3.36")) {
// imports.ui.windowPreview is not in 3.36,
// _getCaption() is still in workspace.js
default_getcaption_workspace = Workspace.prototype._getCaption;
Workspace.prototype._getCaption = function() {
if (this.metaWindow.title)
return this.metaWindow.title;

let tracker = Shell.WindowTracker.get_default();
let app = tracker.get_window_app(this.metaWindow);
return app? app.get_name() : "";
}
} else {
const { WindowPreview } = imports.ui.windowPreview;
default_getcaption_windowpreview = WindowPreview.prototype._getCaption;
WindowPreview.prototype._getCaption = function() {
if (this.metaWindow.title)
return this.metaWindow.title;

let tracker = Shell.WindowTracker.get_default();
let app = tracker.get_window_app(this.metaWindow);
return app? app.get_name() : "";
};
}

// Handle the workspace thumbnail
default_isoverviewwindow_ws_thumbnail =
Expand Down Expand Up @@ -2632,11 +2684,38 @@ function _show_skip_taskbar_windows() {
* This is the cleanup/restore of the decorator for skip_taskbar when pop-shell
* is disabled.
* Should only be called on extension#disable()
*
* Default functions should be checked if they exist,
* especially when skip taskbar setting was left on during an update
*
*/
function _hide_skip_taskbar_windows() {
Workspace.prototype._isOverviewWindow = default_isoverviewwindow_ws;
WorkspaceThumbnail.prototype._isOverviewWindow =
default_isoverviewwindow_ws_thumbnail;
AppSwitcher.prototype._init = default_init_appswitcher;
WindowSwitcherPopup.prototype._getWindowList = default_getwindowlist_windowswitcher;
if (!GNOME_VERSION?.startsWith("40.")) {
if (default_isoverviewwindow_ws)
Workspace.prototype._isOverviewWindow = default_isoverviewwindow_ws;
}

if (GNOME_VERSION?.startsWith("3.36")) {
if (default_getcaption_workspace)
Workspace.prototype._getCaption = default_getcaption_workspace;
} else {
if (default_getcaption_windowpreview) {
const { WindowPreview } = imports.ui.windowPreview;
WindowPreview.prototype._getCaption =
default_getcaption_windowpreview;
}
}

if (default_isoverviewwindow_ws_thumbnail) {
WorkspaceThumbnail.prototype._isOverviewWindow =
default_isoverviewwindow_ws_thumbnail;
}

if (default_init_appswitcher)
AppSwitcher.prototype._init = default_init_appswitcher;

if (default_getwindowlist_windowswitcher) {
WindowSwitcherPopup.prototype._getWindowList =
default_getwindowlist_windowswitcher;
}
}
15 changes: 11 additions & 4 deletions src/plugin_shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ const SELECTIONS: Array<Selection> = [
{
id: 4,
name: "Toggle Window Tiling",
description: "Tiled windows are arranged side by side on the screen"
}

description: "Tiled windows are arranged side by side on the screen",
},
{
id: 5,
name: "Toggle Minimized to Tray Windows (Experimental)",
description: "Handle windows with minimized to tray or skip taskbar option",
},
]

export class ShellBuiltin extends plugins.Builtin {
Expand Down Expand Up @@ -64,8 +68,11 @@ export class ShellBuiltin extends plugins.Builtin {
case 4:
ext.toggle_tiling()
break
case 5:
ext.settings.set_show_skiptaskbar(!ext.settings.show_skiptaskbar());
break
}

return { event: "noop" }
}
}
}
24 changes: 19 additions & 5 deletions src/prefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface AppWidgets {
smart_gaps: any,
snap_to_grid: any,
window_titles: any,
show_skip_taskbar: any,
}

// @ts-ignore
Expand Down Expand Up @@ -63,6 +64,12 @@ function settings_dialog_new(): Gtk.Container {
}
});

app.show_skip_taskbar.set_active(ext.show_skiptaskbar());
app.show_skip_taskbar.connect('state-set', (_widget: any, state: boolean) => {
ext.set_show_skiptaskbar(state);
Settings.sync();
});

return grid;
}

Expand Down Expand Up @@ -92,11 +99,15 @@ function settings_dialog_view(): [AppWidgets, Gtk.Container] {
xalign: 0.0
});

let show_skip_taskbar_label = new Gtk.Label({
label: "Show Skip Taskbar",
xalign: 0.0
});

let window_titles = new Gtk.Switch({ halign: Gtk.Align.END });

let snap_to_grid = new Gtk.Switch({ halign: Gtk.Align.END });

let smart_gaps = new Gtk.Switch({ halign: Gtk.Align.END });
let show_skip_taskbar = new Gtk.Switch({ halign: Gtk.Align.END });

grid.attach(win_label, 0, 0, 1, 1);
grid.attach(window_titles, 1, 0, 1, 1);
Expand All @@ -107,11 +118,14 @@ function settings_dialog_view(): [AppWidgets, Gtk.Container] {
grid.attach(smart_label, 0, 2, 1, 1);
grid.attach(smart_gaps, 1, 2, 1, 1);

logging_combo(grid, 3);
grid.attach(show_skip_taskbar_label, 0, 3, 1, 1);
grid.attach(show_skip_taskbar, 1, 3, 1, 1);

logging_combo(grid, 4);

let [inner_gap, outer_gap] = gaps_section(grid, 4);
let [inner_gap, outer_gap] = gaps_section(grid, 5);

let settings = { inner_gap, outer_gap, smart_gaps, snap_to_grid, window_titles };
let settings = { inner_gap, outer_gap, smart_gaps, snap_to_grid, window_titles, show_skip_taskbar };

return [settings, grid];
}
Expand Down
9 changes: 9 additions & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const TILE_BY_DEFAULT = "tile-by-default";
const HINT_COLOR_RGBA = "hint-color-rgba";
const DEFAULT_RGBA_COLOR = "rgba(251, 184, 108, 1)"; //pop-orange
const LOG_LEVEL = "log-level";
const SHOW_SKIPTASKBAR = "show-skip-taskbar";

export class ExtensionSettings {
ext: Settings = settings_new_schema(extension.metadata["settings-schema"]);
Expand Down Expand Up @@ -146,6 +147,10 @@ export class ExtensionSettings {
return this.ext.get_uint(LOG_LEVEL);
}

show_skiptaskbar(): boolean {
return this.ext.get_boolean(SHOW_SKIPTASKBAR);
}

// Setters

set_active_hint(set: boolean) {
Expand Down Expand Up @@ -197,4 +202,8 @@ export class ExtensionSettings {
set_log_level(set: number) {
this.ext.set_uint(LOG_LEVEL, set);
}

set_show_skiptaskbar(set: boolean) {
this.ext.set_boolean(SHOW_SKIPTASKBAR, set);
}
}