Skip to content

Commit b1b73f6

Browse files
jmmarananmmstick
authored andcommitted
feat: add exception rules for skip taskbar
Initial window exception for Conky, Guake and DDterm
1 parent 90b1ac7 commit b1b73f6

File tree

4 files changed

+84
-13
lines changed

4 files changed

+84
-13
lines changed

schemas/org.gnome.shell.extensions.pop-shell.gschema.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
</key>
2424

2525
<key type="b" name="show-skip-taskbar">
26-
<default>false</default>
27-
<summary>Handle skip taskbar windows or windows with minimized to tray option</summary>
26+
<default>true</default>
27+
<summary>Handle minimized to tray windows</summary>
2828
</key>
2929

3030
<!-- Tiling Options -->

src/config.ts

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ interface Error {
2121

2222
type Result<T> = Ok<T> | Error;
2323

24-
export const DEFAULT_RULES: Array<FloatRule> = [
24+
export const DEFAULT_FLOAT_RULES: Array<FloatRule> = [
2525
{ class: "Floating Window Exceptions"},
2626
{ class: "Authy Desktop", },
2727
{ class: "Enpass", title: "Enpass Assistant" },
2828
{ class: "Zotero", title: "Quick Format Citation" },
2929
{ class: "Com.github.donadigo.eddy", },
3030
{ class: "Conky", },
31+
{ class: "Guake", },
32+
{ class: "Com.github.amezin.ddterm", },
3133
{ class: "gnome-screenshot", },
3234
{ class: "jetbrains-toolbox", },
3335
{ class: "jetbrains-webstorm", title: "License Activation" },
@@ -45,6 +47,22 @@ export const DEFAULT_RULES: Array<FloatRule> = [
4547
{ class: "Gnome-initial-setup" },
4648
];
4749

50+
export interface WindowRule {
51+
class?: string;
52+
title?: string;
53+
disabled?: boolean;
54+
}
55+
56+
/**
57+
* These windows will skip showing in Overview, Thumbnails or SwitcherList
58+
* And any rule here should be added on the DEFAULT_RULES above
59+
*/
60+
export const SKIPTASKBAR_EXCEPTIONS: Array<WindowRule> = [
61+
{ class: "Conky", },
62+
{ class: "Guake", },
63+
{ class: "Com.github.amezin.ddterm", },
64+
];
65+
4866
export interface FloatRule {
4967
class?: string;
5068
title?: string;
@@ -62,6 +80,12 @@ export class Config {
6280
/** List of windows that should float, regardless of their WM hints */
6381
float: Array<FloatRule> = [];
6482

83+
/**
84+
* List of Windows with skip taskbar true but still hidden in Overview,
85+
* Switchers, Workspace Thumbnails
86+
*/
87+
skiptaskbarhidden: Array<WindowRule> = [];
88+
6589
/** Logs window details on focus of window */
6690
log_on_focus: boolean = false;
6791

@@ -92,7 +116,7 @@ export class Config {
92116
}
93117

94118
window_shall_float(wclass: string, title: string): boolean {
95-
for (const rule of this.float.concat(DEFAULT_RULES)) {
119+
for (const rule of this.float.concat(DEFAULT_FLOAT_RULES)) {
96120
if (rule.class) {
97121
if (!new RegExp(rule.class, 'i').test(wclass)) {
98122
continue
@@ -111,6 +135,31 @@ export class Config {
111135
return false;
112136
}
113137

138+
skiptaskbar_shall_hide(meta_window: any) {
139+
let wmclass = meta_window.get_wm_class();
140+
let wmtitle = meta_window.get_title();
141+
142+
if (!meta_window.is_skip_taskbar()) return false;
143+
144+
for (const rule of this.skiptaskbarhidden.concat(SKIPTASKBAR_EXCEPTIONS)) {
145+
if (rule.class) {
146+
if (!new RegExp(rule.class, 'i').test(wmclass)) {
147+
continue
148+
}
149+
}
150+
151+
if (rule.title) {
152+
if (!new RegExp(rule.title, 'i').test(wmtitle)) {
153+
continue
154+
}
155+
}
156+
157+
return rule.disabled ? false : true;
158+
}
159+
160+
return false;
161+
}
162+
114163
reload() {
115164
const conf = Config.from_config();
116165

@@ -141,7 +190,7 @@ export class Config {
141190

142191
toggle_system_exception(wmclass: string | undefined, wmtitle: string | undefined, disabled: boolean) {
143192
if (disabled) {
144-
for (const value of DEFAULT_RULES) {
193+
for (const value of DEFAULT_FLOAT_RULES) {
145194
if (value.class === wmclass && value.title === wmtitle) {
146195
value.disabled = disabled;
147196
this.float.push(value);

src/extension.ts

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,7 +1748,7 @@ export class Ext extends Ecs.System<ExtEvent> {
17481748
break;
17491749
case 'show-skip-taskbar':
17501750
if (this.settings.show_skiptaskbar()) {
1751-
_show_skip_taskbar_windows();
1751+
_show_skip_taskbar_windows(this);
17521752
} else {
17531753
_hide_skip_taskbar_windows();
17541754
}
@@ -2429,6 +2429,12 @@ function enable() {
24292429
});
24302430
}
24312431

2432+
if (ext.settings.show_skiptaskbar()) {
2433+
_show_skip_taskbar_windows(ext);
2434+
} else {
2435+
_hide_skip_taskbar_windows();
2436+
}
2437+
24322438
if (ext.was_locked) {
24332439
ext.was_locked = false;
24342440
return;
@@ -2478,6 +2484,8 @@ function disable() {
24782484
ext.auto_tiler.destroy(ext);
24792485
ext.auto_tiler = null;
24802486
}
2487+
2488+
_hide_skip_taskbar_windows();
24812489
}
24822490

24832491
if (indicator) {
@@ -2560,7 +2568,8 @@ let default_getcaption_workspace: any;
25602568
* need to added to config.ts as default floating
25612569
*
25622570
*/
2563-
function _show_skip_taskbar_windows() {
2571+
function _show_skip_taskbar_windows(ext: Ext) {
2572+
let cfg = ext.conf;
25642573
if (!GNOME_VERSION?.startsWith("40.")) {
25652574
// TODO GNOME 40 added a call to windowtracker and app var is not checked if null
25662575
// in WindowPreview._init(). Then new WindowPreview() is being called on
@@ -2572,7 +2581,8 @@ function _show_skip_taskbar_windows() {
25722581
Workspace.prototype._isOverviewWindow = function(window: any) {
25732582
// wm_class Gjs needs to be skipped to prevent the ghost window in
25742583
// workspace and overview
2575-
return (window.skip_taskbar && window.get_wm_class() !== "Gjs") ||
2584+
let show_skiptb = !cfg.skiptaskbar_shall_hide(window);
2585+
return (show_skiptb && window.skip_taskbar && window.get_wm_class() !== "Gjs") ||
25762586
default_isoverviewwindow_ws(window);
25772587
};
25782588
}
@@ -2610,7 +2620,8 @@ function _show_skip_taskbar_windows() {
26102620
let meta_win = win.get_meta_window();
26112621
// wm_class Gjs needs to be skipped to prevent the ghost window in
26122622
// workspace and overview
2613-
return (meta_win.skip_taskbar && meta_win.get_wm_class() !== "Gjs") ||
2623+
let show_skiptb = !cfg.skiptaskbar_shall_hide(meta_win);
2624+
return (show_skiptb && meta_win.skip_taskbar && meta_win.get_wm_class() !== "Gjs") ||
26142625
default_isoverviewwindow_ws_thumbnail(win);
26152626
};
26162627

@@ -2648,7 +2659,10 @@ function _show_skip_taskbar_windows() {
26482659
});
26492660

26502661
for (let i = 0; i < allRunningSkipTaskbarApps.length; i++) {
2651-
let appIcon = new AppIcon(windowTracker.get_window_app(allRunningSkipTaskbarApps[i]));
2662+
let meta_win = allRunningSkipTaskbarApps[i];
2663+
let show_skiptb = !cfg.skiptaskbar_shall_hide(meta_win);
2664+
if (meta_win.is_skip_taskbar() && !show_skiptb) continue;
2665+
let appIcon = new AppIcon(windowTracker.get_window_app(meta_win));
26522666
appIcon.cachedWindows = allWindows.filter(
26532667
w => windowTracker.get_window_app(w) === appIcon.app);
26542668
if (appIcon.cachedWindows.length > 0)
@@ -2675,8 +2689,16 @@ function _show_skip_taskbar_windows() {
26752689
let windows = global.display.get_tab_list(Meta.TabList.NORMAL_ALL,
26762690
workspace);
26772691
return windows.map(w => {
2678-
return w.is_attached_dialog() ? w.get_transient_for() : w;
2679-
}).filter((w, i, a) => w != null && a.indexOf(w) == i);
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+
}
2699+
}
2700+
return null;
2701+
}).filter((w, i, a) => w != null && a.indexOf(w) == i);
26802702
}
26812703
}
26822704

src/prefs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ function settings_dialog_view(): [AppWidgets, Gtk.Container] {
100100
});
101101

102102
let show_skip_taskbar_label = new Gtk.Label({
103-
label: "Show Skip Taskbar",
103+
label: "Show Minimize to Tray Windows",
104104
xalign: 0.0
105105
});
106106

0 commit comments

Comments
 (0)