window-list: Support showing windows from all workspaces
gnome-panel's window list applet has such an option, so let's support it as well. https://gitlab.gnome.org/GNOME/gnome-shell-extensions/issues/154
This commit is contained in:
committed by
Florian Müllner
parent
f9b87f9b44
commit
827af154b8
@@ -206,11 +206,18 @@ const WindowTitle = GObject.registerClass({
|
||||
|
||||
const BaseButton = GObject.registerClass({
|
||||
GTypeName: 'WindowListBaseButton',
|
||||
GTypeFlags: GObject.TypeFlags.ABSTRACT
|
||||
GTypeFlags: GObject.TypeFlags.ABSTRACT,
|
||||
Properties: {
|
||||
'ignore-workspace': GObject.ParamSpec.boolean(
|
||||
'ignore-workspace', 'ignore-workspace', 'ignore-workspace',
|
||||
GObject.ParamFlags.READWRITE,
|
||||
false)
|
||||
}
|
||||
}, class BaseButton extends St.Button {
|
||||
_init(perMonitor, monitorIndex) {
|
||||
this._perMonitor = perMonitor;
|
||||
this._monitorIndex = monitorIndex;
|
||||
this._ignoreWorkspace = false;
|
||||
|
||||
super._init({
|
||||
style_class: 'window-button',
|
||||
@@ -245,6 +252,22 @@ const BaseButton = GObject.registerClass({
|
||||
return this.has_style_class_name('focused');
|
||||
}
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
get ignore_workspace() {
|
||||
return this._ignoreWorkspace;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
set ignore_workspace(ignore) {
|
||||
if (this._ignoreWorkspace == ignore)
|
||||
return;
|
||||
|
||||
this._ignoreWorkspace = ignore;
|
||||
this.notify('ignore-workspace');
|
||||
|
||||
this._updateVisibility();
|
||||
}
|
||||
|
||||
activate() {
|
||||
if (this.active)
|
||||
return;
|
||||
@@ -288,7 +311,7 @@ const BaseButton = GObject.registerClass({
|
||||
let workspace = global.workspace_manager.get_active_workspace();
|
||||
|
||||
return !window.skip_taskbar &&
|
||||
window.located_on_workspace(workspace) &&
|
||||
(this._ignoreWorkspace || window.located_on_workspace(workspace)) &&
|
||||
(!this._perMonitor || window.get_monitor() == this._monitorIndex);
|
||||
}
|
||||
|
||||
@@ -533,7 +556,9 @@ const AppButton = GObject.registerClass({
|
||||
}
|
||||
|
||||
_updateVisibility() {
|
||||
if (!this._perMonitor) {
|
||||
if (this._ignoreWorkspace) {
|
||||
this.visible = true;
|
||||
} else if (!this._perMonitor) {
|
||||
// fast path: use ShellApp API to avoid iterating over all windows.
|
||||
let workspace = global.workspace_manager.get_active_workspace();
|
||||
this.visible = this.app.is_on_workspace(workspace);
|
||||
@@ -917,6 +942,8 @@ const WindowList = GObject.registerClass({
|
||||
|
||||
_addApp(app) {
|
||||
let button = new AppButton(app, this._perMonitor, this._monitor.index);
|
||||
this._settings.bind('display-all-workspaces',
|
||||
button, 'ignore-workspace', Gio.SettingsBindFlags.GET);
|
||||
this._windowList.layout_manager.pack(button,
|
||||
true, true, true,
|
||||
Clutter.BoxAlignment.START,
|
||||
@@ -945,6 +972,8 @@ const WindowList = GObject.registerClass({
|
||||
return;
|
||||
|
||||
let button = new WindowButton(win, this._perMonitor, this._monitor.index);
|
||||
this._settings.bind('display-all-workspaces',
|
||||
button, 'ignore-workspace', Gio.SettingsBindFlags.GET);
|
||||
this._windowList.layout_manager.pack(button,
|
||||
true, true, true,
|
||||
Clutter.BoxAlignment.START,
|
||||
|
||||
@@ -15,6 +15,13 @@
|
||||
window list. Possible values are “never”, “auto” and “always”.
|
||||
</description>
|
||||
</key>
|
||||
<key name="display-all-workspaces" type="b">
|
||||
<default>false</default>
|
||||
<summary>Show windows from all workspaces</summary>
|
||||
<description>
|
||||
Whether to show windows from all workspaces or only the current one.
|
||||
</description>
|
||||
</key>
|
||||
<key name="show-on-all-monitors" type="b">
|
||||
<default>false</default>
|
||||
<summary>Show the window list on all monitors</summary>
|
||||
|
||||
@@ -77,6 +77,13 @@ class WindowListPrefsWidget extends Gtk.Grid {
|
||||
});
|
||||
this._settings.bind('show-on-all-monitors', check, 'active', Gio.SettingsBindFlags.DEFAULT);
|
||||
this.add(check);
|
||||
|
||||
check = new Gtk.CheckButton({
|
||||
label: _('Show windows from all workspaces'),
|
||||
margin_top: 6
|
||||
});
|
||||
this._settings.bind('display-all-workspaces', check, 'active', Gio.SettingsBindFlags.DEFAULT);
|
||||
this.add(check);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user