Update to 47.alpha
Resolves: https://issues.redhat.com/browse/RHEL-49584
This commit is contained in:
parent
81ded7a443
commit
30e2a973f6
1
.gitignore
vendored
1
.gitignore
vendored
@ -177,3 +177,4 @@
|
||||
/gnome-shell-extensions-46.0.tar.xz
|
||||
/gnome-shell-extensions-46.1.tar.xz
|
||||
/gnome-shell-extensions-46.2.tar.xz
|
||||
/gnome-shell-extensions-47.alpha.tar.xz
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 714feb8e1646b8a3e60bfd95683622a8f125bcf5 Mon Sep 17 00:00:00 2001
|
||||
From 8a2191519e2431a946aa1be36474bfe323a454a8 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Fri, 23 Feb 2018 16:56:46 +0100
|
||||
Subject: [PATCH] Include top-icons in classic session
|
||||
@ -8,7 +8,7 @@ Subject: [PATCH] Include top-icons in classic session
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/meson.build b/meson.build
|
||||
index 6a94e4e2..56a4bb57 100644
|
||||
index dce1731c..b915b68c 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -34,6 +34,7 @@ classic_extensions = [
|
||||
@ -28,5 +28,5 @@ index 6a94e4e2..56a4bb57 100644
|
||||
'workspace-indicator'
|
||||
]
|
||||
--
|
||||
2.44.0
|
||||
2.45.2
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From b94a924c682081e72b52de5a7c5db5cec18cf0f3 Mon Sep 17 00:00:00 2001
|
||||
From 97d71d4a7ef4b1d4c9c2eab55db62173311f5366 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Tue, 2 Jul 2024 19:04:10 +0200
|
||||
Subject: [PATCH] workspace-indicator: Re-fittsify workspace previews
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 56da93fbbe675144ae8eb60daedb9f9d3e93be0f Mon Sep 17 00:00:00 2001
|
||||
From 778e3f5ec9b8897af89af1919381a14e2e3494f6 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Wed, 20 May 2015 17:44:50 +0200
|
||||
Subject: [PATCH 1/5] Add top-icons extension
|
||||
@ -142,7 +142,7 @@ index 00000000..1d2e0bc2
|
||||
+"url": "@url@"
|
||||
+}
|
||||
diff --git a/meson.build b/meson.build
|
||||
index 6d403512..4d2ca280 100644
|
||||
index 536efe49..a7294c18 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -43,6 +43,7 @@ default_extensions += [
|
||||
@ -154,5 +154,5 @@ index 6d403512..4d2ca280 100644
|
||||
'workspace-indicator'
|
||||
]
|
||||
--
|
||||
2.45.0
|
||||
2.45.2
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 4ca791c4d7872cb51ebc6cc90f906a9fcbb5b995 Mon Sep 17 00:00:00 2001
|
||||
From ff5063cb006a3723f422017d44787cfd908bb147 Mon Sep 17 00:00:00 2001
|
||||
From: Carlos Garnacho <carlosg@gnome.org>
|
||||
Date: Thu, 28 Jan 2021 00:06:12 +0100
|
||||
Subject: [PATCH 2/5] Add gesture-inhibitor extension
|
||||
@ -165,7 +165,7 @@ index 00000000..b06d027a
|
||||
+</schemalist>
|
||||
+
|
||||
diff --git a/meson.build b/meson.build
|
||||
index 4d2ca280..c78d0cc6 100644
|
||||
index a7294c18..e36d948d 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -51,6 +51,7 @@ default_extensions += [
|
||||
@ -177,5 +177,5 @@ index 4d2ca280..c78d0cc6 100644
|
||||
'user-theme'
|
||||
]
|
||||
--
|
||||
2.45.0
|
||||
2.45.2
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From fc39411ecf0431ecc39581bace4217a55ab028e9 Mon Sep 17 00:00:00 2001
|
||||
From d5dd07519ab1fe58717b538c49b3b94c840af67e Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Thu, 2 Dec 2021 19:39:50 +0100
|
||||
Subject: [PATCH 3/5] Add classification-banner
|
||||
@ -672,7 +672,7 @@ index 00000000..fb6a697e
|
||||
+.classification-message { font-weight: bold; }
|
||||
+.classification-banner { font-size: 0.9em; }
|
||||
diff --git a/meson.build b/meson.build
|
||||
index c78d0cc6..b3dac8de 100644
|
||||
index e36d948d..63bd9ee0 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -51,6 +51,7 @@ default_extensions += [
|
||||
@ -684,5 +684,5 @@ index c78d0cc6..b3dac8de 100644
|
||||
'native-window-placement',
|
||||
'user-theme'
|
||||
--
|
||||
2.45.0
|
||||
2.45.2
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 94e0261560490bdfe37df5d9f5ff1cbac9533d6a Mon Sep 17 00:00:00 2001
|
||||
From 271cee0eab89dcbf7b6c307c55cfbbbf843e7a0e Mon Sep 17 00:00:00 2001
|
||||
From: Ray Strode <rstrode@redhat.com>
|
||||
Date: Tue, 24 Aug 2021 15:03:57 -0400
|
||||
Subject: [PATCH 4/5] Add heads-up-display
|
||||
@ -850,7 +850,7 @@ index 00000000..a1a34e3f
|
||||
+ text-align: center;
|
||||
+}
|
||||
diff --git a/meson.build b/meson.build
|
||||
index b3dac8de..b2a5d94d 100644
|
||||
index 63bd9ee0..82269ff5 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -40,6 +40,7 @@ classic_extensions = [
|
||||
@ -862,7 +862,7 @@ index b3dac8de..b2a5d94d 100644
|
||||
'screenshot-window-sizer',
|
||||
'system-monitor',
|
||||
diff --git a/po/POTFILES.in b/po/POTFILES.in
|
||||
index 4abfcfca..b77f6c21 100644
|
||||
index 447465a1..b7cb8a7c 100644
|
||||
--- a/po/POTFILES.in
|
||||
+++ b/po/POTFILES.in
|
||||
@@ -6,6 +6,7 @@ extensions/auto-move-windows/extension.js
|
||||
@ -874,5 +874,5 @@ index 4abfcfca..b77f6c21 100644
|
||||
extensions/native-window-placement/org.gnome.shell.extensions.native-window-placement.gschema.xml
|
||||
extensions/places-menu/extension.js
|
||||
--
|
||||
2.45.0
|
||||
2.45.2
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 2e2bc1032163110993aa3433295b5d8c84978790 Mon Sep 17 00:00:00 2001
|
||||
From b146a94c18e9e9ddbc7f29e8d885768d19fd7d49 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Thu, 12 Jan 2023 19:43:52 +0100
|
||||
Subject: [PATCH 5/5] Add custom-menu extension
|
||||
@ -703,7 +703,7 @@ index 00000000..054f639b
|
||||
+"url": "@url@"
|
||||
+}
|
||||
diff --git a/meson.build b/meson.build
|
||||
index b2a5d94d..bbb72889 100644
|
||||
index 82269ff5..dce1731c 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -53,6 +53,7 @@ all_extensions = default_extensions
|
||||
@ -715,5 +715,5 @@ index b2a5d94d..bbb72889 100644
|
||||
'native-window-placement',
|
||||
'user-theme'
|
||||
--
|
||||
2.45.0
|
||||
2.45.2
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
%endif
|
||||
|
||||
Name: gnome-shell-extensions
|
||||
Version: 46.2
|
||||
Version: 47~alpha
|
||||
Release: %autorelease
|
||||
Summary: Modify and extend GNOME Shell functionality and behavior
|
||||
|
||||
@ -36,35 +36,6 @@ Patch: extra-extensions-0005-Add-custom-menu-extension.patch
|
||||
|
||||
Patch: 0001-Include-top-icons-in-classic-session.patch
|
||||
|
||||
Patch: more-ws-previews-0001-workspace-indicator-Move-indicator-code-into-separat.patch
|
||||
Patch: more-ws-previews-0002-workspace-indicator-Use-descendant-style-selectors.patch
|
||||
Patch: more-ws-previews-0003-window-list-Use-consistent-style-class-prefix.patch
|
||||
Patch: more-ws-previews-0004-workspace-indicator-Allow-overriding-base-style-clas.patch
|
||||
Patch: more-ws-previews-0005-window-list-Override-base-style-class.patch
|
||||
Patch: more-ws-previews-0006-window-list-Externally-adjust-workspace-menu.patch
|
||||
Patch: more-ws-previews-0007-window-list-Handle-changes-to-workspace-menu.patch
|
||||
Patch: more-ws-previews-0008-workspace-indicator-Don-t-use-SCHEMA-KEY-constants.patch
|
||||
Patch: more-ws-previews-0009-workspace-indicator-Use-existing-property.patch
|
||||
Patch: more-ws-previews-0010-workspace-indicator-Don-t-use-menu-section.patch
|
||||
Patch: more-ws-previews-0011-workspace-indicator-Support-showing-tooltips-above.patch
|
||||
Patch: more-ws-previews-0012-workspace-indicator-Only-change-top-bar-redirect-whe.patch
|
||||
Patch: more-ws-previews-0013-workspace-indicator-Small-cleanup.patch
|
||||
Patch: more-ws-previews-0014-workspace-indicator-Simplify-getting-status-text.patch
|
||||
Patch: more-ws-previews-0015-workspace-indicator-Include-n-workspaces-in-status-l.patch
|
||||
Patch: more-ws-previews-0016-workspace-indicator-Tweak-preview-style.patch
|
||||
Patch: more-ws-previews-0017-workspace-indicator-Support-light-style.patch
|
||||
Patch: more-ws-previews-0018-export-zips-Pick-up-non-default-stylesheets.patch
|
||||
Patch: more-ws-previews-0019-window-list-Use-actual-copy-of-workspace-indicator.patch
|
||||
Patch: more-ws-previews-0020-workspace-indicator-Simplify-scroll-handling.patch
|
||||
Patch: more-ws-previews-0021-workspace-indicator-Handle-active-indication-in-thum.patch
|
||||
Patch: more-ws-previews-0022-workspace-indicator-Split-out-WorkspacePreviews.patch
|
||||
Patch: more-ws-previews-0023-workspace-indicator-Handle-preview-overflow.patch
|
||||
Patch: more-ws-previews-0024-workspace-indicator-Support-labels-in-previews.patch
|
||||
Patch: more-ws-previews-0025-workspace-indicator-Stop-handling-vertical-layouts.patch
|
||||
Patch: more-ws-previews-0026-workspace-indicator-Also-show-previews-in-menu.patch
|
||||
Patch: more-ws-previews-0027-workspace-indicator-Make-previews-configurable.patch
|
||||
Patch: more-ws-previews-0028-window-list-Expose-workspace-preview-option.patch
|
||||
|
||||
Patch: 0001-workspace-indicator-Re-fittsify-workspace-previews.patch
|
||||
|
||||
%description
|
||||
|
@ -1,942 +0,0 @@
|
||||
From 1f0681875eefd09df28630a74aabd1bf47f90dab Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Wed, 21 Feb 2024 12:38:33 +0100
|
||||
Subject: [PATCH 01/28] workspace-indicator: Move indicator code into separate
|
||||
file
|
||||
|
||||
Shortly after the window-list extension was added, it gained a
|
||||
workspace switcher based on the workspace indicator extension.
|
||||
|
||||
Duplicating the code wasn't a big issue while the switcher was
|
||||
a simple menu, but since it gained previews with a fair bit of
|
||||
custom styling, syncing changes between the two extensions has
|
||||
become tedious, in particular as the two copies have slightly
|
||||
diverged over time.
|
||||
|
||||
In order to allow the two copies to converge again, the indicator
|
||||
code needs to be separate from the extension boilerplate, so
|
||||
split out the code into a separate module.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/307>
|
||||
---
|
||||
extensions/workspace-indicator/extension.js | 432 +----------------
|
||||
extensions/workspace-indicator/meson.build | 2 +-
|
||||
.../workspace-indicator/workspaceIndicator.js | 438 ++++++++++++++++++
|
||||
po/POTFILES.in | 2 +-
|
||||
4 files changed, 442 insertions(+), 432 deletions(-)
|
||||
create mode 100644 extensions/workspace-indicator/workspaceIndicator.js
|
||||
|
||||
diff --git a/extensions/workspace-indicator/extension.js b/extensions/workspace-indicator/extension.js
|
||||
index f9c7dd9a..b383c919 100644
|
||||
--- a/extensions/workspace-indicator/extension.js
|
||||
+++ b/extensions/workspace-indicator/extension.js
|
||||
@@ -4,439 +4,11 @@
|
||||
//
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
-// -*- mode: js2; indent-tabs-mode: nil; js2-basic-offset: 4 -*-
|
||||
-import Clutter from 'gi://Clutter';
|
||||
-import Gio from 'gi://Gio';
|
||||
-import GObject from 'gi://GObject';
|
||||
-import Meta from 'gi://Meta';
|
||||
-import St from 'gi://St';
|
||||
+import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js';
|
||||
|
||||
-import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js';
|
||||
-
|
||||
-import * as DND from 'resource:///org/gnome/shell/ui/dnd.js';
|
||||
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
||||
-import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
|
||||
-import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';
|
||||
-
|
||||
-const WORKSPACE_SCHEMA = 'org.gnome.desktop.wm.preferences';
|
||||
-const WORKSPACE_KEY = 'workspace-names';
|
||||
-
|
||||
-const TOOLTIP_OFFSET = 6;
|
||||
-const TOOLTIP_ANIMATION_TIME = 150;
|
||||
-
|
||||
-const MAX_THUMBNAILS = 6;
|
||||
-
|
||||
-class WindowPreview extends St.Button {
|
||||
- static {
|
||||
- GObject.registerClass(this);
|
||||
- }
|
||||
-
|
||||
- constructor(window) {
|
||||
- super({
|
||||
- style_class: 'workspace-indicator-window-preview',
|
||||
- });
|
||||
-
|
||||
- this._delegate = this;
|
||||
- DND.makeDraggable(this, {restoreOnSuccess: true});
|
||||
-
|
||||
- this._window = window;
|
||||
-
|
||||
- this._window.connectObject(
|
||||
- 'size-changed', () => this._checkRelayout(),
|
||||
- 'position-changed', () => this._checkRelayout(),
|
||||
- 'notify::minimized', this._updateVisible.bind(this),
|
||||
- 'notify::window-type', this._updateVisible.bind(this),
|
||||
- this);
|
||||
- this._updateVisible();
|
||||
-
|
||||
- global.display.connectObject('notify::focus-window',
|
||||
- this._onFocusChanged.bind(this), this);
|
||||
- this._onFocusChanged();
|
||||
- }
|
||||
-
|
||||
- // needed for DND
|
||||
- get metaWindow() {
|
||||
- return this._window;
|
||||
- }
|
||||
-
|
||||
- _onFocusChanged() {
|
||||
- if (global.display.focus_window === this._window)
|
||||
- this.add_style_class_name('active');
|
||||
- else
|
||||
- this.remove_style_class_name('active');
|
||||
- }
|
||||
-
|
||||
- _checkRelayout() {
|
||||
- const monitor = Main.layoutManager.findIndexForActor(this);
|
||||
- const workArea = Main.layoutManager.getWorkAreaForMonitor(monitor);
|
||||
- if (this._window.get_frame_rect().overlap(workArea))
|
||||
- this.queue_relayout();
|
||||
- }
|
||||
-
|
||||
- _updateVisible() {
|
||||
- this.visible = this._window.window_type !== Meta.WindowType.DESKTOP &&
|
||||
- this._window.showing_on_its_workspace();
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-class WorkspaceLayout extends Clutter.LayoutManager {
|
||||
- static {
|
||||
- GObject.registerClass(this);
|
||||
- }
|
||||
-
|
||||
- vfunc_get_preferred_width() {
|
||||
- return [0, 0];
|
||||
- }
|
||||
-
|
||||
- vfunc_get_preferred_height() {
|
||||
- return [0, 0];
|
||||
- }
|
||||
-
|
||||
- vfunc_allocate(container, box) {
|
||||
- const monitor = Main.layoutManager.findIndexForActor(container);
|
||||
- const workArea = Main.layoutManager.getWorkAreaForMonitor(monitor);
|
||||
- const hscale = box.get_width() / workArea.width;
|
||||
- const vscale = box.get_height() / workArea.height;
|
||||
-
|
||||
- for (const child of container) {
|
||||
- const childBox = new Clutter.ActorBox();
|
||||
- const frameRect = child.metaWindow.get_frame_rect();
|
||||
- childBox.set_size(
|
||||
- Math.round(Math.min(frameRect.width, workArea.width) * hscale),
|
||||
- Math.round(Math.min(frameRect.height, workArea.height) * vscale));
|
||||
- childBox.set_origin(
|
||||
- Math.round((frameRect.x - workArea.x) * hscale),
|
||||
- Math.round((frameRect.y - workArea.y) * vscale));
|
||||
- child.allocate(childBox);
|
||||
- }
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-class WorkspaceThumbnail extends St.Button {
|
||||
- static {
|
||||
- GObject.registerClass(this);
|
||||
- }
|
||||
-
|
||||
- constructor(index) {
|
||||
- super({
|
||||
- style_class: 'workspace',
|
||||
- child: new Clutter.Actor({
|
||||
- layout_manager: new WorkspaceLayout(),
|
||||
- clip_to_allocation: true,
|
||||
- x_expand: true,
|
||||
- y_expand: true,
|
||||
- }),
|
||||
- });
|
||||
-
|
||||
- this._tooltip = new St.Label({
|
||||
- style_class: 'dash-label',
|
||||
- visible: false,
|
||||
- });
|
||||
- Main.uiGroup.add_child(this._tooltip);
|
||||
-
|
||||
- this.connect('destroy', this._onDestroy.bind(this));
|
||||
- this.connect('notify::hover', this._syncTooltip.bind(this));
|
||||
-
|
||||
- this._index = index;
|
||||
- this._delegate = this; // needed for DND
|
||||
-
|
||||
- this._windowPreviews = new Map();
|
||||
-
|
||||
- let workspaceManager = global.workspace_manager;
|
||||
- this._workspace = workspaceManager.get_workspace_by_index(index);
|
||||
-
|
||||
- this._workspace.connectObject(
|
||||
- 'window-added', (ws, window) => this._addWindow(window),
|
||||
- 'window-removed', (ws, window) => this._removeWindow(window),
|
||||
- this);
|
||||
-
|
||||
- global.display.connectObject('restacked',
|
||||
- this._onRestacked.bind(this), this);
|
||||
-
|
||||
- this._workspace.list_windows().forEach(w => this._addWindow(w));
|
||||
- this._onRestacked();
|
||||
- }
|
||||
-
|
||||
- acceptDrop(source) {
|
||||
- if (!source.metaWindow)
|
||||
- return false;
|
||||
-
|
||||
- this._moveWindow(source.metaWindow);
|
||||
- return true;
|
||||
- }
|
||||
-
|
||||
- handleDragOver(source) {
|
||||
- if (source.metaWindow)
|
||||
- return DND.DragMotionResult.MOVE_DROP;
|
||||
- else
|
||||
- return DND.DragMotionResult.CONTINUE;
|
||||
- }
|
||||
-
|
||||
- _addWindow(window) {
|
||||
- if (this._windowPreviews.has(window))
|
||||
- return;
|
||||
-
|
||||
- let preview = new WindowPreview(window);
|
||||
- preview.connect('clicked', (a, btn) => this.emit('clicked', btn));
|
||||
- this._windowPreviews.set(window, preview);
|
||||
- this.child.add_child(preview);
|
||||
- }
|
||||
-
|
||||
- _removeWindow(window) {
|
||||
- let preview = this._windowPreviews.get(window);
|
||||
- if (!preview)
|
||||
- return;
|
||||
-
|
||||
- this._windowPreviews.delete(window);
|
||||
- preview.destroy();
|
||||
- }
|
||||
-
|
||||
- _onRestacked() {
|
||||
- let lastPreview = null;
|
||||
- let windows = global.get_window_actors().map(a => a.meta_window);
|
||||
- for (let i = 0; i < windows.length; i++) {
|
||||
- let preview = this._windowPreviews.get(windows[i]);
|
||||
- if (!preview)
|
||||
- continue;
|
||||
-
|
||||
- this.child.set_child_above_sibling(preview, lastPreview);
|
||||
- lastPreview = preview;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- _moveWindow(window) {
|
||||
- let monitorIndex = Main.layoutManager.findIndexForActor(this);
|
||||
- if (monitorIndex !== window.get_monitor())
|
||||
- window.move_to_monitor(monitorIndex);
|
||||
- window.change_workspace_by_index(this._index, false);
|
||||
- }
|
||||
-
|
||||
- on_clicked() {
|
||||
- let ws = global.workspace_manager.get_workspace_by_index(this._index);
|
||||
- if (ws)
|
||||
- ws.activate(global.get_current_time());
|
||||
- }
|
||||
-
|
||||
- _syncTooltip() {
|
||||
- if (this.hover) {
|
||||
- this._tooltip.set({
|
||||
- text: Meta.prefs_get_workspace_name(this._index),
|
||||
- visible: true,
|
||||
- opacity: 0,
|
||||
- });
|
||||
-
|
||||
- const [stageX, stageY] = this.get_transformed_position();
|
||||
- const thumbWidth = this.allocation.get_width();
|
||||
- const thumbHeight = this.allocation.get_height();
|
||||
- const tipWidth = this._tooltip.width;
|
||||
- const xOffset = Math.floor((thumbWidth - tipWidth) / 2);
|
||||
- const monitor = Main.layoutManager.findMonitorForActor(this);
|
||||
- const x = Math.clamp(
|
||||
- stageX + xOffset,
|
||||
- monitor.x,
|
||||
- monitor.x + monitor.width - tipWidth);
|
||||
- const y = stageY + thumbHeight + TOOLTIP_OFFSET;
|
||||
- this._tooltip.set_position(x, y);
|
||||
- }
|
||||
-
|
||||
- this._tooltip.ease({
|
||||
- opacity: this.hover ? 255 : 0,
|
||||
- duration: TOOLTIP_ANIMATION_TIME,
|
||||
- mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
||||
- onComplete: () => (this._tooltip.visible = this.hover),
|
||||
- });
|
||||
- }
|
||||
-
|
||||
- _onDestroy() {
|
||||
- this._tooltip.destroy();
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-class WorkspaceIndicator extends PanelMenu.Button {
|
||||
- static {
|
||||
- GObject.registerClass(this);
|
||||
- }
|
||||
-
|
||||
- constructor() {
|
||||
- super(0.5, _('Workspace Indicator'));
|
||||
-
|
||||
- let container = new St.Widget({
|
||||
- layout_manager: new Clutter.BinLayout(),
|
||||
- x_expand: true,
|
||||
- y_expand: true,
|
||||
- });
|
||||
- this.add_child(container);
|
||||
-
|
||||
- let workspaceManager = global.workspace_manager;
|
||||
-
|
||||
- this._currentWorkspace = workspaceManager.get_active_workspace_index();
|
||||
- this._statusLabel = new St.Label({
|
||||
- style_class: 'panel-workspace-indicator',
|
||||
- y_align: Clutter.ActorAlign.CENTER,
|
||||
- text: this._labelText(),
|
||||
- });
|
||||
-
|
||||
- container.add_child(this._statusLabel);
|
||||
-
|
||||
- this._thumbnailsBox = new St.BoxLayout({
|
||||
- style_class: 'panel-workspace-indicator-box',
|
||||
- y_expand: true,
|
||||
- reactive: true,
|
||||
- });
|
||||
-
|
||||
- container.add_child(this._thumbnailsBox);
|
||||
-
|
||||
- this._workspacesItems = [];
|
||||
- this._workspaceSection = new PopupMenu.PopupMenuSection();
|
||||
- this.menu.addMenuItem(this._workspaceSection);
|
||||
-
|
||||
- workspaceManager.connectObject(
|
||||
- 'notify::n-workspaces', this._nWorkspacesChanged.bind(this), GObject.ConnectFlags.AFTER,
|
||||
- 'workspace-switched', this._onWorkspaceSwitched.bind(this), GObject.ConnectFlags.AFTER,
|
||||
- 'notify::layout-rows', this._updateThumbnailVisibility.bind(this),
|
||||
- this);
|
||||
-
|
||||
- this.connect('scroll-event', this._onScrollEvent.bind(this));
|
||||
- this._thumbnailsBox.connect('scroll-event', this._onScrollEvent.bind(this));
|
||||
- this._createWorkspacesSection();
|
||||
- this._updateThumbnails();
|
||||
- this._updateThumbnailVisibility();
|
||||
-
|
||||
- this._settings = new Gio.Settings({schema_id: WORKSPACE_SCHEMA});
|
||||
- this._settings.connectObject(`changed::${WORKSPACE_KEY}`,
|
||||
- this._updateMenuLabels.bind(this), this);
|
||||
- }
|
||||
-
|
||||
- _onDestroy() {
|
||||
- Main.panel.set_offscreen_redirect(Clutter.OffscreenRedirect.ALWAYS);
|
||||
-
|
||||
- super._onDestroy();
|
||||
- }
|
||||
-
|
||||
- _updateThumbnailVisibility() {
|
||||
- const {workspaceManager} = global;
|
||||
- const vertical = workspaceManager.layout_rows === -1;
|
||||
- const useMenu =
|
||||
- vertical || workspaceManager.n_workspaces > MAX_THUMBNAILS;
|
||||
- this.reactive = useMenu;
|
||||
-
|
||||
- this._statusLabel.visible = useMenu;
|
||||
- this._thumbnailsBox.visible = !useMenu;
|
||||
-
|
||||
- // Disable offscreen-redirect when showing the workspace switcher
|
||||
- // so that clip-to-allocation works
|
||||
- Main.panel.set_offscreen_redirect(useMenu
|
||||
- ? Clutter.OffscreenRedirect.ALWAYS
|
||||
- : Clutter.OffscreenRedirect.AUTOMATIC_FOR_OPACITY);
|
||||
- }
|
||||
-
|
||||
- _onWorkspaceSwitched() {
|
||||
- this._currentWorkspace = global.workspace_manager.get_active_workspace_index();
|
||||
|
||||
- this._updateMenuOrnament();
|
||||
- this._updateActiveThumbnail();
|
||||
-
|
||||
- this._statusLabel.set_text(this._labelText());
|
||||
- }
|
||||
-
|
||||
- _nWorkspacesChanged() {
|
||||
- this._createWorkspacesSection();
|
||||
- this._updateThumbnails();
|
||||
- this._updateThumbnailVisibility();
|
||||
- }
|
||||
-
|
||||
- _updateMenuOrnament() {
|
||||
- for (let i = 0; i < this._workspacesItems.length; i++) {
|
||||
- this._workspacesItems[i].setOrnament(i === this._currentWorkspace
|
||||
- ? PopupMenu.Ornament.DOT
|
||||
- : PopupMenu.Ornament.NO_DOT);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- _updateActiveThumbnail() {
|
||||
- let thumbs = this._thumbnailsBox.get_children();
|
||||
- for (let i = 0; i < thumbs.length; i++) {
|
||||
- if (i === this._currentWorkspace)
|
||||
- thumbs[i].add_style_class_name('active');
|
||||
- else
|
||||
- thumbs[i].remove_style_class_name('active');
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- _labelText(workspaceIndex) {
|
||||
- if (workspaceIndex === undefined) {
|
||||
- workspaceIndex = this._currentWorkspace;
|
||||
- return (workspaceIndex + 1).toString();
|
||||
- }
|
||||
- return Meta.prefs_get_workspace_name(workspaceIndex);
|
||||
- }
|
||||
-
|
||||
- _updateMenuLabels() {
|
||||
- for (let i = 0; i < this._workspacesItems.length; i++)
|
||||
- this._workspacesItems[i].label.text = this._labelText(i);
|
||||
- }
|
||||
-
|
||||
- _createWorkspacesSection() {
|
||||
- let workspaceManager = global.workspace_manager;
|
||||
-
|
||||
- this._workspaceSection.removeAll();
|
||||
- this._workspacesItems = [];
|
||||
- this._currentWorkspace = workspaceManager.get_active_workspace_index();
|
||||
-
|
||||
- let i = 0;
|
||||
- for (; i < workspaceManager.n_workspaces; i++) {
|
||||
- this._workspacesItems[i] = new PopupMenu.PopupMenuItem(this._labelText(i));
|
||||
- this._workspaceSection.addMenuItem(this._workspacesItems[i]);
|
||||
- this._workspacesItems[i].workspaceId = i;
|
||||
- this._workspacesItems[i].label_actor = this._statusLabel;
|
||||
- this._workspacesItems[i].connect('activate', (actor, _event) => {
|
||||
- this._activate(actor.workspaceId);
|
||||
- });
|
||||
-
|
||||
- this._workspacesItems[i].setOrnament(i === this._currentWorkspace
|
||||
- ? PopupMenu.Ornament.DOT
|
||||
- : PopupMenu.Ornament.NO_DOT);
|
||||
- }
|
||||
-
|
||||
- this._statusLabel.set_text(this._labelText());
|
||||
- }
|
||||
-
|
||||
- _updateThumbnails() {
|
||||
- let workspaceManager = global.workspace_manager;
|
||||
-
|
||||
- this._thumbnailsBox.destroy_all_children();
|
||||
-
|
||||
- for (let i = 0; i < workspaceManager.n_workspaces; i++) {
|
||||
- let thumb = new WorkspaceThumbnail(i);
|
||||
- this._thumbnailsBox.add_child(thumb);
|
||||
- }
|
||||
- this._updateActiveThumbnail();
|
||||
- }
|
||||
-
|
||||
- _activate(index) {
|
||||
- let workspaceManager = global.workspace_manager;
|
||||
-
|
||||
- if (index >= 0 && index < workspaceManager.n_workspaces) {
|
||||
- let metaWorkspace = workspaceManager.get_workspace_by_index(index);
|
||||
- metaWorkspace.activate(global.get_current_time());
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- _onScrollEvent(actor, event) {
|
||||
- let direction = event.get_scroll_direction();
|
||||
- let diff = 0;
|
||||
- if (direction === Clutter.ScrollDirection.DOWN)
|
||||
- diff = 1;
|
||||
- else if (direction === Clutter.ScrollDirection.UP)
|
||||
- diff = -1;
|
||||
- else
|
||||
- return;
|
||||
-
|
||||
-
|
||||
- let newIndex = global.workspace_manager.get_active_workspace_index() + diff;
|
||||
- this._activate(newIndex);
|
||||
- }
|
||||
-}
|
||||
+import {WorkspaceIndicator} from './workspaceIndicator.js';
|
||||
|
||||
export default class WorkspaceIndicatorExtension extends Extension {
|
||||
enable() {
|
||||
diff --git a/extensions/workspace-indicator/meson.build b/extensions/workspace-indicator/meson.build
|
||||
index 36daa535..6dd08dae 100644
|
||||
--- a/extensions/workspace-indicator/meson.build
|
||||
+++ b/extensions/workspace-indicator/meson.build
|
||||
@@ -9,4 +9,4 @@ extension_data += configure_file(
|
||||
)
|
||||
extension_data += files('stylesheet.css')
|
||||
|
||||
-extension_sources += files('prefs.js')
|
||||
+extension_sources += files('prefs.js', 'workspaceIndicator.js')
|
||||
diff --git a/extensions/workspace-indicator/workspaceIndicator.js b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
new file mode 100644
|
||||
index 00000000..6b0903d5
|
||||
--- /dev/null
|
||||
+++ b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
@@ -0,0 +1,438 @@
|
||||
+// SPDX-FileCopyrightText: 2011 Erick Pérez Castellanos <erick.red@gmail.com>
|
||||
+// SPDX-FileCopyrightText: 2011 Giovanni Campagna <gcampagna@src.gnome.org>
|
||||
+// SPDX-FileCopyrightText: 2017 Florian Müllner <fmuellner@gnome.org>
|
||||
+//
|
||||
+// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
+
|
||||
+import Clutter from 'gi://Clutter';
|
||||
+import Gio from 'gi://Gio';
|
||||
+import GObject from 'gi://GObject';
|
||||
+import Meta from 'gi://Meta';
|
||||
+import St from 'gi://St';
|
||||
+
|
||||
+import {gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js';
|
||||
+
|
||||
+import * as DND from 'resource:///org/gnome/shell/ui/dnd.js';
|
||||
+import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
||||
+import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
|
||||
+import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';
|
||||
+
|
||||
+const WORKSPACE_SCHEMA = 'org.gnome.desktop.wm.preferences';
|
||||
+const WORKSPACE_KEY = 'workspace-names';
|
||||
+
|
||||
+const TOOLTIP_OFFSET = 6;
|
||||
+const TOOLTIP_ANIMATION_TIME = 150;
|
||||
+
|
||||
+const MAX_THUMBNAILS = 6;
|
||||
+
|
||||
+class WindowPreview extends St.Button {
|
||||
+ static {
|
||||
+ GObject.registerClass(this);
|
||||
+ }
|
||||
+
|
||||
+ constructor(window) {
|
||||
+ super({
|
||||
+ style_class: 'workspace-indicator-window-preview',
|
||||
+ });
|
||||
+
|
||||
+ this._delegate = this;
|
||||
+ DND.makeDraggable(this, {restoreOnSuccess: true});
|
||||
+
|
||||
+ this._window = window;
|
||||
+
|
||||
+ this._window.connectObject(
|
||||
+ 'size-changed', () => this._checkRelayout(),
|
||||
+ 'position-changed', () => this._checkRelayout(),
|
||||
+ 'notify::minimized', this._updateVisible.bind(this),
|
||||
+ 'notify::window-type', this._updateVisible.bind(this),
|
||||
+ this);
|
||||
+ this._updateVisible();
|
||||
+
|
||||
+ global.display.connectObject('notify::focus-window',
|
||||
+ this._onFocusChanged.bind(this), this);
|
||||
+ this._onFocusChanged();
|
||||
+ }
|
||||
+
|
||||
+ // needed for DND
|
||||
+ get metaWindow() {
|
||||
+ return this._window;
|
||||
+ }
|
||||
+
|
||||
+ _onFocusChanged() {
|
||||
+ if (global.display.focus_window === this._window)
|
||||
+ this.add_style_class_name('active');
|
||||
+ else
|
||||
+ this.remove_style_class_name('active');
|
||||
+ }
|
||||
+
|
||||
+ _checkRelayout() {
|
||||
+ const monitor = Main.layoutManager.findIndexForActor(this);
|
||||
+ const workArea = Main.layoutManager.getWorkAreaForMonitor(monitor);
|
||||
+ if (this._window.get_frame_rect().overlap(workArea))
|
||||
+ this.queue_relayout();
|
||||
+ }
|
||||
+
|
||||
+ _updateVisible() {
|
||||
+ this.visible = this._window.window_type !== Meta.WindowType.DESKTOP &&
|
||||
+ this._window.showing_on_its_workspace();
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+class WorkspaceLayout extends Clutter.LayoutManager {
|
||||
+ static {
|
||||
+ GObject.registerClass(this);
|
||||
+ }
|
||||
+
|
||||
+ vfunc_get_preferred_width() {
|
||||
+ return [0, 0];
|
||||
+ }
|
||||
+
|
||||
+ vfunc_get_preferred_height() {
|
||||
+ return [0, 0];
|
||||
+ }
|
||||
+
|
||||
+ vfunc_allocate(container, box) {
|
||||
+ const monitor = Main.layoutManager.findIndexForActor(container);
|
||||
+ const workArea = Main.layoutManager.getWorkAreaForMonitor(monitor);
|
||||
+ const hscale = box.get_width() / workArea.width;
|
||||
+ const vscale = box.get_height() / workArea.height;
|
||||
+
|
||||
+ for (const child of container) {
|
||||
+ const childBox = new Clutter.ActorBox();
|
||||
+ const frameRect = child.metaWindow.get_frame_rect();
|
||||
+ childBox.set_size(
|
||||
+ Math.round(Math.min(frameRect.width, workArea.width) * hscale),
|
||||
+ Math.round(Math.min(frameRect.height, workArea.height) * vscale));
|
||||
+ childBox.set_origin(
|
||||
+ Math.round((frameRect.x - workArea.x) * hscale),
|
||||
+ Math.round((frameRect.y - workArea.y) * vscale));
|
||||
+ child.allocate(childBox);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+class WorkspaceThumbnail extends St.Button {
|
||||
+ static {
|
||||
+ GObject.registerClass(this);
|
||||
+ }
|
||||
+
|
||||
+ constructor(index) {
|
||||
+ super({
|
||||
+ style_class: 'workspace',
|
||||
+ child: new Clutter.Actor({
|
||||
+ layout_manager: new WorkspaceLayout(),
|
||||
+ clip_to_allocation: true,
|
||||
+ x_expand: true,
|
||||
+ y_expand: true,
|
||||
+ }),
|
||||
+ });
|
||||
+
|
||||
+ this._tooltip = new St.Label({
|
||||
+ style_class: 'dash-label',
|
||||
+ visible: false,
|
||||
+ });
|
||||
+ Main.uiGroup.add_child(this._tooltip);
|
||||
+
|
||||
+ this.connect('destroy', this._onDestroy.bind(this));
|
||||
+ this.connect('notify::hover', this._syncTooltip.bind(this));
|
||||
+
|
||||
+ this._index = index;
|
||||
+ this._delegate = this; // needed for DND
|
||||
+
|
||||
+ this._windowPreviews = new Map();
|
||||
+
|
||||
+ let workspaceManager = global.workspace_manager;
|
||||
+ this._workspace = workspaceManager.get_workspace_by_index(index);
|
||||
+
|
||||
+ this._workspace.connectObject(
|
||||
+ 'window-added', (ws, window) => this._addWindow(window),
|
||||
+ 'window-removed', (ws, window) => this._removeWindow(window),
|
||||
+ this);
|
||||
+
|
||||
+ global.display.connectObject('restacked',
|
||||
+ this._onRestacked.bind(this), this);
|
||||
+
|
||||
+ this._workspace.list_windows().forEach(w => this._addWindow(w));
|
||||
+ this._onRestacked();
|
||||
+ }
|
||||
+
|
||||
+ acceptDrop(source) {
|
||||
+ if (!source.metaWindow)
|
||||
+ return false;
|
||||
+
|
||||
+ this._moveWindow(source.metaWindow);
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ handleDragOver(source) {
|
||||
+ if (source.metaWindow)
|
||||
+ return DND.DragMotionResult.MOVE_DROP;
|
||||
+ else
|
||||
+ return DND.DragMotionResult.CONTINUE;
|
||||
+ }
|
||||
+
|
||||
+ _addWindow(window) {
|
||||
+ if (this._windowPreviews.has(window))
|
||||
+ return;
|
||||
+
|
||||
+ let preview = new WindowPreview(window);
|
||||
+ preview.connect('clicked', (a, btn) => this.emit('clicked', btn));
|
||||
+ this._windowPreviews.set(window, preview);
|
||||
+ this.child.add_child(preview);
|
||||
+ }
|
||||
+
|
||||
+ _removeWindow(window) {
|
||||
+ let preview = this._windowPreviews.get(window);
|
||||
+ if (!preview)
|
||||
+ return;
|
||||
+
|
||||
+ this._windowPreviews.delete(window);
|
||||
+ preview.destroy();
|
||||
+ }
|
||||
+
|
||||
+ _onRestacked() {
|
||||
+ let lastPreview = null;
|
||||
+ let windows = global.get_window_actors().map(a => a.meta_window);
|
||||
+ for (let i = 0; i < windows.length; i++) {
|
||||
+ let preview = this._windowPreviews.get(windows[i]);
|
||||
+ if (!preview)
|
||||
+ continue;
|
||||
+
|
||||
+ this.child.set_child_above_sibling(preview, lastPreview);
|
||||
+ lastPreview = preview;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ _moveWindow(window) {
|
||||
+ let monitorIndex = Main.layoutManager.findIndexForActor(this);
|
||||
+ if (monitorIndex !== window.get_monitor())
|
||||
+ window.move_to_monitor(monitorIndex);
|
||||
+ window.change_workspace_by_index(this._index, false);
|
||||
+ }
|
||||
+
|
||||
+ on_clicked() {
|
||||
+ let ws = global.workspace_manager.get_workspace_by_index(this._index);
|
||||
+ if (ws)
|
||||
+ ws.activate(global.get_current_time());
|
||||
+ }
|
||||
+
|
||||
+ _syncTooltip() {
|
||||
+ if (this.hover) {
|
||||
+ this._tooltip.set({
|
||||
+ text: Meta.prefs_get_workspace_name(this._index),
|
||||
+ visible: true,
|
||||
+ opacity: 0,
|
||||
+ });
|
||||
+
|
||||
+ const [stageX, stageY] = this.get_transformed_position();
|
||||
+ const thumbWidth = this.allocation.get_width();
|
||||
+ const thumbHeight = this.allocation.get_height();
|
||||
+ const tipWidth = this._tooltip.width;
|
||||
+ const xOffset = Math.floor((thumbWidth - tipWidth) / 2);
|
||||
+ const monitor = Main.layoutManager.findMonitorForActor(this);
|
||||
+ const x = Math.clamp(
|
||||
+ stageX + xOffset,
|
||||
+ monitor.x,
|
||||
+ monitor.x + monitor.width - tipWidth);
|
||||
+ const y = stageY + thumbHeight + TOOLTIP_OFFSET;
|
||||
+ this._tooltip.set_position(x, y);
|
||||
+ }
|
||||
+
|
||||
+ this._tooltip.ease({
|
||||
+ opacity: this.hover ? 255 : 0,
|
||||
+ duration: TOOLTIP_ANIMATION_TIME,
|
||||
+ mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
||||
+ onComplete: () => (this._tooltip.visible = this.hover),
|
||||
+ });
|
||||
+ }
|
||||
+
|
||||
+ _onDestroy() {
|
||||
+ this._tooltip.destroy();
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
+ static {
|
||||
+ GObject.registerClass(this);
|
||||
+ }
|
||||
+
|
||||
+ constructor() {
|
||||
+ super(0.5, _('Workspace Indicator'));
|
||||
+
|
||||
+ let container = new St.Widget({
|
||||
+ layout_manager: new Clutter.BinLayout(),
|
||||
+ x_expand: true,
|
||||
+ y_expand: true,
|
||||
+ });
|
||||
+ this.add_child(container);
|
||||
+
|
||||
+ let workspaceManager = global.workspace_manager;
|
||||
+
|
||||
+ this._currentWorkspace = workspaceManager.get_active_workspace_index();
|
||||
+ this._statusLabel = new St.Label({
|
||||
+ style_class: 'panel-workspace-indicator',
|
||||
+ y_align: Clutter.ActorAlign.CENTER,
|
||||
+ text: this._labelText(),
|
||||
+ });
|
||||
+
|
||||
+ container.add_child(this._statusLabel);
|
||||
+
|
||||
+ this._thumbnailsBox = new St.BoxLayout({
|
||||
+ style_class: 'panel-workspace-indicator-box',
|
||||
+ y_expand: true,
|
||||
+ reactive: true,
|
||||
+ });
|
||||
+
|
||||
+ container.add_child(this._thumbnailsBox);
|
||||
+
|
||||
+ this._workspacesItems = [];
|
||||
+ this._workspaceSection = new PopupMenu.PopupMenuSection();
|
||||
+ this.menu.addMenuItem(this._workspaceSection);
|
||||
+
|
||||
+ workspaceManager.connectObject(
|
||||
+ 'notify::n-workspaces', this._nWorkspacesChanged.bind(this), GObject.ConnectFlags.AFTER,
|
||||
+ 'workspace-switched', this._onWorkspaceSwitched.bind(this), GObject.ConnectFlags.AFTER,
|
||||
+ 'notify::layout-rows', this._updateThumbnailVisibility.bind(this),
|
||||
+ this);
|
||||
+
|
||||
+ this.connect('scroll-event', this._onScrollEvent.bind(this));
|
||||
+ this._thumbnailsBox.connect('scroll-event', this._onScrollEvent.bind(this));
|
||||
+ this._createWorkspacesSection();
|
||||
+ this._updateThumbnails();
|
||||
+ this._updateThumbnailVisibility();
|
||||
+
|
||||
+ this._settings = new Gio.Settings({schema_id: WORKSPACE_SCHEMA});
|
||||
+ this._settings.connectObject(`changed::${WORKSPACE_KEY}`,
|
||||
+ this._updateMenuLabels.bind(this), this);
|
||||
+ }
|
||||
+
|
||||
+ _onDestroy() {
|
||||
+ Main.panel.set_offscreen_redirect(Clutter.OffscreenRedirect.ALWAYS);
|
||||
+
|
||||
+ super._onDestroy();
|
||||
+ }
|
||||
+
|
||||
+ _updateThumbnailVisibility() {
|
||||
+ const {workspaceManager} = global;
|
||||
+ const vertical = workspaceManager.layout_rows === -1;
|
||||
+ const useMenu =
|
||||
+ vertical || workspaceManager.n_workspaces > MAX_THUMBNAILS;
|
||||
+ this.reactive = useMenu;
|
||||
+
|
||||
+ this._statusLabel.visible = useMenu;
|
||||
+ this._thumbnailsBox.visible = !useMenu;
|
||||
+
|
||||
+ // Disable offscreen-redirect when showing the workspace switcher
|
||||
+ // so that clip-to-allocation works
|
||||
+ Main.panel.set_offscreen_redirect(useMenu
|
||||
+ ? Clutter.OffscreenRedirect.ALWAYS
|
||||
+ : Clutter.OffscreenRedirect.AUTOMATIC_FOR_OPACITY);
|
||||
+ }
|
||||
+
|
||||
+ _onWorkspaceSwitched() {
|
||||
+ this._currentWorkspace = global.workspace_manager.get_active_workspace_index();
|
||||
+
|
||||
+ this._updateMenuOrnament();
|
||||
+ this._updateActiveThumbnail();
|
||||
+
|
||||
+ this._statusLabel.set_text(this._labelText());
|
||||
+ }
|
||||
+
|
||||
+ _nWorkspacesChanged() {
|
||||
+ this._createWorkspacesSection();
|
||||
+ this._updateThumbnails();
|
||||
+ this._updateThumbnailVisibility();
|
||||
+ }
|
||||
+
|
||||
+ _updateMenuOrnament() {
|
||||
+ for (let i = 0; i < this._workspacesItems.length; i++) {
|
||||
+ this._workspacesItems[i].setOrnament(i === this._currentWorkspace
|
||||
+ ? PopupMenu.Ornament.DOT
|
||||
+ : PopupMenu.Ornament.NO_DOT);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ _updateActiveThumbnail() {
|
||||
+ let thumbs = this._thumbnailsBox.get_children();
|
||||
+ for (let i = 0; i < thumbs.length; i++) {
|
||||
+ if (i === this._currentWorkspace)
|
||||
+ thumbs[i].add_style_class_name('active');
|
||||
+ else
|
||||
+ thumbs[i].remove_style_class_name('active');
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ _labelText(workspaceIndex) {
|
||||
+ if (workspaceIndex === undefined) {
|
||||
+ workspaceIndex = this._currentWorkspace;
|
||||
+ return (workspaceIndex + 1).toString();
|
||||
+ }
|
||||
+ return Meta.prefs_get_workspace_name(workspaceIndex);
|
||||
+ }
|
||||
+
|
||||
+ _updateMenuLabels() {
|
||||
+ for (let i = 0; i < this._workspacesItems.length; i++)
|
||||
+ this._workspacesItems[i].label.text = this._labelText(i);
|
||||
+ }
|
||||
+
|
||||
+ _createWorkspacesSection() {
|
||||
+ let workspaceManager = global.workspace_manager;
|
||||
+
|
||||
+ this._workspaceSection.removeAll();
|
||||
+ this._workspacesItems = [];
|
||||
+ this._currentWorkspace = workspaceManager.get_active_workspace_index();
|
||||
+
|
||||
+ let i = 0;
|
||||
+ for (; i < workspaceManager.n_workspaces; i++) {
|
||||
+ this._workspacesItems[i] = new PopupMenu.PopupMenuItem(this._labelText(i));
|
||||
+ this._workspaceSection.addMenuItem(this._workspacesItems[i]);
|
||||
+ this._workspacesItems[i].workspaceId = i;
|
||||
+ this._workspacesItems[i].label_actor = this._statusLabel;
|
||||
+ this._workspacesItems[i].connect('activate', (actor, _event) => {
|
||||
+ this._activate(actor.workspaceId);
|
||||
+ });
|
||||
+
|
||||
+ this._workspacesItems[i].setOrnament(i === this._currentWorkspace
|
||||
+ ? PopupMenu.Ornament.DOT
|
||||
+ : PopupMenu.Ornament.NO_DOT);
|
||||
+ }
|
||||
+
|
||||
+ this._statusLabel.set_text(this._labelText());
|
||||
+ }
|
||||
+
|
||||
+ _updateThumbnails() {
|
||||
+ let workspaceManager = global.workspace_manager;
|
||||
+
|
||||
+ this._thumbnailsBox.destroy_all_children();
|
||||
+
|
||||
+ for (let i = 0; i < workspaceManager.n_workspaces; i++) {
|
||||
+ let thumb = new WorkspaceThumbnail(i);
|
||||
+ this._thumbnailsBox.add_child(thumb);
|
||||
+ }
|
||||
+ this._updateActiveThumbnail();
|
||||
+ }
|
||||
+
|
||||
+ _activate(index) {
|
||||
+ let workspaceManager = global.workspace_manager;
|
||||
+
|
||||
+ if (index >= 0 && index < workspaceManager.n_workspaces) {
|
||||
+ let metaWorkspace = workspaceManager.get_workspace_by_index(index);
|
||||
+ metaWorkspace.activate(global.get_current_time());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ _onScrollEvent(actor, event) {
|
||||
+ let direction = event.get_scroll_direction();
|
||||
+ let diff = 0;
|
||||
+ if (direction === Clutter.ScrollDirection.DOWN)
|
||||
+ diff = 1;
|
||||
+ else if (direction === Clutter.ScrollDirection.UP)
|
||||
+ diff = -1;
|
||||
+ else
|
||||
+ return;
|
||||
+
|
||||
+
|
||||
+ let newIndex = global.workspace_manager.get_active_workspace_index() + diff;
|
||||
+ this._activate(newIndex);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/po/POTFILES.in b/po/POTFILES.in
|
||||
index b77f6c21..182b2be0 100644
|
||||
--- a/po/POTFILES.in
|
||||
+++ b/po/POTFILES.in
|
||||
@@ -20,5 +20,5 @@ extensions/window-list/org.gnome.shell.extensions.window-list.gschema.xml
|
||||
extensions/window-list/prefs.js
|
||||
extensions/window-list/workspaceIndicator.js
|
||||
extensions/windowsNavigator/extension.js
|
||||
-extensions/workspace-indicator/extension.js
|
||||
extensions/workspace-indicator/prefs.js
|
||||
+extensions/workspace-indicator/workspaceIndicator.js
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,81 +0,0 @@
|
||||
From 5bb91b4303bb0696dce4ad7aeb31035e89c1e9ce Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Wed, 21 Feb 2024 19:09:38 +0100
|
||||
Subject: [PATCH 02/28] workspace-indicator: Use descendant style selectors
|
||||
|
||||
Add a style class to the indicator itself, and only select
|
||||
descendant elements. This allows using the briefer class names
|
||||
from the window-list extension without too much risk of conflicts.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/307>
|
||||
---
|
||||
extensions/workspace-indicator/stylesheet.css | 8 ++++----
|
||||
extensions/workspace-indicator/workspaceIndicator.js | 6 ++++--
|
||||
2 files changed, 8 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/extensions/workspace-indicator/stylesheet.css b/extensions/workspace-indicator/stylesheet.css
|
||||
index 7b53a46f..749878c1 100644
|
||||
--- a/extensions/workspace-indicator/stylesheet.css
|
||||
+++ b/extensions/workspace-indicator/stylesheet.css
|
||||
@@ -5,23 +5,23 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
-.panel-workspace-indicator {
|
||||
+.workspace-indicator .status-label {
|
||||
padding: 0 8px;
|
||||
}
|
||||
|
||||
-.panel-workspace-indicator-box {
|
||||
+.workspace-indicator .workspaces-box {
|
||||
padding: 4px 0;
|
||||
spacing: 4px;
|
||||
}
|
||||
|
||||
-.panel-workspace-indicator-box .workspace {
|
||||
+.workspace-indicator .workspace {
|
||||
width: 40px;
|
||||
border: 2px solid #000;
|
||||
border-radius: 2px;
|
||||
background-color: #595959;
|
||||
}
|
||||
|
||||
-.panel-workspace-indicator-box .workspace.active {
|
||||
+.workspace-indicator .workspace.active {
|
||||
border-color: #fff;
|
||||
}
|
||||
|
||||
diff --git a/extensions/workspace-indicator/workspaceIndicator.js b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
index 6b0903d5..4bf9c0a2 100644
|
||||
--- a/extensions/workspace-indicator/workspaceIndicator.js
|
||||
+++ b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
@@ -259,6 +259,8 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
constructor() {
|
||||
super(0.5, _('Workspace Indicator'));
|
||||
|
||||
+ this.add_style_class_name('workspace-indicator');
|
||||
+
|
||||
let container = new St.Widget({
|
||||
layout_manager: new Clutter.BinLayout(),
|
||||
x_expand: true,
|
||||
@@ -270,7 +272,7 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
|
||||
this._currentWorkspace = workspaceManager.get_active_workspace_index();
|
||||
this._statusLabel = new St.Label({
|
||||
- style_class: 'panel-workspace-indicator',
|
||||
+ style_class: 'status-label',
|
||||
y_align: Clutter.ActorAlign.CENTER,
|
||||
text: this._labelText(),
|
||||
});
|
||||
@@ -278,7 +280,7 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
container.add_child(this._statusLabel);
|
||||
|
||||
this._thumbnailsBox = new St.BoxLayout({
|
||||
- style_class: 'panel-workspace-indicator-box',
|
||||
+ style_class: 'workspaces-box',
|
||||
y_expand: true,
|
||||
reactive: true,
|
||||
});
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,68 +0,0 @@
|
||||
From 962983e8019817afae63807459eeaf3ff50eab03 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Wed, 21 Feb 2024 12:48:43 +0100
|
||||
Subject: [PATCH 03/28] window-list: Use consistent style class prefix
|
||||
|
||||
This will eventually allow us to re-use the workspace-indicator
|
||||
extension without changing anything but the used prefix.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/307>
|
||||
---
|
||||
extensions/window-list/stylesheet-dark.css | 4 ++--
|
||||
extensions/window-list/stylesheet-light.css | 4 ++--
|
||||
extensions/window-list/workspaceIndicator.js | 2 +-
|
||||
3 files changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/extensions/window-list/stylesheet-dark.css b/extensions/window-list/stylesheet-dark.css
|
||||
index b4c0a3b4..fbadf4d0 100644
|
||||
--- a/extensions/window-list/stylesheet-dark.css
|
||||
+++ b/extensions/window-list/stylesheet-dark.css
|
||||
@@ -102,12 +102,12 @@
|
||||
background-color: #3f3f3f;
|
||||
}
|
||||
|
||||
-.window-list-window-preview {
|
||||
+.window-list-workspace-indicator-window-preview {
|
||||
background-color: #bebebe;
|
||||
border-radius: 1px;
|
||||
}
|
||||
|
||||
-.window-list-window-preview.active {
|
||||
+.window-list-workspace-indicator-window-preview.active {
|
||||
background-color: #d4d4d4;
|
||||
}
|
||||
|
||||
diff --git a/extensions/window-list/stylesheet-light.css b/extensions/window-list/stylesheet-light.css
|
||||
index e4d3a36c..e9352362 100644
|
||||
--- a/extensions/window-list/stylesheet-light.css
|
||||
+++ b/extensions/window-list/stylesheet-light.css
|
||||
@@ -61,11 +61,11 @@
|
||||
border-color: #888;
|
||||
}
|
||||
|
||||
-.window-list-window-preview {
|
||||
+.window-list-workspace-indicator-window-preview {
|
||||
background-color: #ededed;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
-.window-list-window-preview.active {
|
||||
+.window-list-workspace-indicator-window-preview.active {
|
||||
background-color: #f6f5f4;
|
||||
}
|
||||
diff --git a/extensions/window-list/workspaceIndicator.js b/extensions/window-list/workspaceIndicator.js
|
||||
index 62ebffbd..5b11fe88 100644
|
||||
--- a/extensions/window-list/workspaceIndicator.js
|
||||
+++ b/extensions/window-list/workspaceIndicator.js
|
||||
@@ -27,7 +27,7 @@ class WindowPreview extends St.Button {
|
||||
|
||||
constructor(window) {
|
||||
super({
|
||||
- style_class: 'window-list-window-preview',
|
||||
+ style_class: 'window-list-workspace-indicator-window-preview',
|
||||
});
|
||||
|
||||
this._delegate = this;
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,57 +0,0 @@
|
||||
From cadf2bb80984ec3b27b2d22ad65ec675230905c4 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Fri, 23 Feb 2024 01:59:15 +0100
|
||||
Subject: [PATCH 04/28] workspace-indicator: Allow overriding base style class
|
||||
|
||||
This will allow reusing the code from the window-list extension
|
||||
without limiting the ability to specify styling that only applies
|
||||
to one of the extensions.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/307>
|
||||
---
|
||||
.../workspace-indicator/workspaceIndicator.js | 13 ++++++++++---
|
||||
1 file changed, 10 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/extensions/workspace-indicator/workspaceIndicator.js b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
index 4bf9c0a2..cdcc67fe 100644
|
||||
--- a/extensions/workspace-indicator/workspaceIndicator.js
|
||||
+++ b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
@@ -25,6 +25,8 @@ const TOOLTIP_ANIMATION_TIME = 150;
|
||||
|
||||
const MAX_THUMBNAILS = 6;
|
||||
|
||||
+let baseStyleClassName = '';
|
||||
+
|
||||
class WindowPreview extends St.Button {
|
||||
static {
|
||||
GObject.registerClass(this);
|
||||
@@ -32,7 +34,7 @@ class WindowPreview extends St.Button {
|
||||
|
||||
constructor(window) {
|
||||
super({
|
||||
- style_class: 'workspace-indicator-window-preview',
|
||||
+ style_class: `${baseStyleClassName}-window-preview`,
|
||||
});
|
||||
|
||||
this._delegate = this;
|
||||
@@ -256,10 +258,15 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
GObject.registerClass(this);
|
||||
}
|
||||
|
||||
- constructor() {
|
||||
+ constructor(params = {}) {
|
||||
super(0.5, _('Workspace Indicator'));
|
||||
|
||||
- this.add_style_class_name('workspace-indicator');
|
||||
+ const {
|
||||
+ baseStyleClass = 'workspace-indicator',
|
||||
+ } = params;
|
||||
+
|
||||
+ baseStyleClassName = baseStyleClass;
|
||||
+ this.add_style_class_name(baseStyleClassName);
|
||||
|
||||
let container = new St.Widget({
|
||||
layout_manager: new Clutter.BinLayout(),
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,78 +0,0 @@
|
||||
From a54815b7e6726af56c9300b9c209bb554c3a4a25 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Fri, 23 Feb 2024 01:58:50 +0100
|
||||
Subject: [PATCH 05/28] window-list: Override base style class
|
||||
|
||||
Apply the changes from the last commit to the workspace-indicator
|
||||
copy, and override the base style class from the extension.
|
||||
|
||||
This will eventually allow us to share the exact same code between
|
||||
the two extensions, but still use individual styling if necessary.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/307>
|
||||
---
|
||||
extensions/window-list/extension.js | 5 ++++-
|
||||
extensions/window-list/workspaceIndicator.js | 15 ++++++++++++---
|
||||
2 files changed, 16 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/extensions/window-list/extension.js b/extensions/window-list/extension.js
|
||||
index 034b72ba..ab5b042c 100644
|
||||
--- a/extensions/window-list/extension.js
|
||||
+++ b/extensions/window-list/extension.js
|
||||
@@ -767,7 +767,10 @@ class WindowList extends St.Widget {
|
||||
let indicatorsBox = new St.BoxLayout({x_align: Clutter.ActorAlign.END});
|
||||
box.add_child(indicatorsBox);
|
||||
|
||||
- this._workspaceIndicator = new WorkspaceIndicator();
|
||||
+ this._workspaceIndicator = new WorkspaceIndicator({
|
||||
+ baseStyleClass: 'window-list-workspace-indicator',
|
||||
+ });
|
||||
+
|
||||
indicatorsBox.add_child(this._workspaceIndicator.container);
|
||||
|
||||
this._mutterSettings = new Gio.Settings({schema_id: 'org.gnome.mutter'});
|
||||
diff --git a/extensions/window-list/workspaceIndicator.js b/extensions/window-list/workspaceIndicator.js
|
||||
index 5b11fe88..2c557e5b 100644
|
||||
--- a/extensions/window-list/workspaceIndicator.js
|
||||
+++ b/extensions/window-list/workspaceIndicator.js
|
||||
@@ -20,6 +20,8 @@ const TOOLTIP_ANIMATION_TIME = 150;
|
||||
|
||||
const MAX_THUMBNAILS = 6;
|
||||
|
||||
+let baseStyleClassName = '';
|
||||
+
|
||||
class WindowPreview extends St.Button {
|
||||
static {
|
||||
GObject.registerClass(this);
|
||||
@@ -27,7 +29,7 @@ class WindowPreview extends St.Button {
|
||||
|
||||
constructor(window) {
|
||||
super({
|
||||
- style_class: 'window-list-workspace-indicator-window-preview',
|
||||
+ style_class: `${baseStyleClassName}-window-preview`,
|
||||
});
|
||||
|
||||
this._delegate = this;
|
||||
@@ -251,10 +253,17 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
GObject.registerClass(this);
|
||||
}
|
||||
|
||||
- constructor() {
|
||||
+ constructor(params = {}) {
|
||||
super(0.5, _('Workspace Indicator'), true);
|
||||
+
|
||||
+ const {
|
||||
+ baseStyleClass = 'workspace-indicator',
|
||||
+ } = params;
|
||||
+
|
||||
+ baseStyleClassName = baseStyleClass;
|
||||
+ this.add_style_class_name(baseStyleClassName);
|
||||
+
|
||||
this.setMenu(new PopupMenu.PopupMenu(this, 0.0, St.Side.BOTTOM));
|
||||
- this.add_style_class_name('window-list-workspace-indicator');
|
||||
this.remove_style_class_name('panel-button');
|
||||
this.menu.actor.remove_style_class_name('panel-menu');
|
||||
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,92 +0,0 @@
|
||||
From b539608940eb5956bbf1cb9083b7171a9d2d6708 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Wed, 21 Feb 2024 12:48:43 +0100
|
||||
Subject: [PATCH 06/28] window-list: Externally adjust workspace menu
|
||||
|
||||
In order to use a PanelMenu.Button in the bottom bar, we have
|
||||
to tweak its menu a bit.
|
||||
|
||||
We currently handle this inside the indicator, but that means the
|
||||
code diverges from the original code in the workspace-indicator
|
||||
extension.
|
||||
|
||||
Avoid this by using a small subclass that handles the adjustments.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/307>
|
||||
---
|
||||
extensions/window-list/extension.js | 25 ++++++++++++++++++--
|
||||
extensions/window-list/workspaceIndicator.js | 6 +----
|
||||
2 files changed, 24 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/extensions/window-list/extension.js b/extensions/window-list/extension.js
|
||||
index ab5b042c..1bb7cf60 100644
|
||||
--- a/extensions/window-list/extension.js
|
||||
+++ b/extensions/window-list/extension.js
|
||||
@@ -767,10 +767,9 @@ class WindowList extends St.Widget {
|
||||
let indicatorsBox = new St.BoxLayout({x_align: Clutter.ActorAlign.END});
|
||||
box.add_child(indicatorsBox);
|
||||
|
||||
- this._workspaceIndicator = new WorkspaceIndicator({
|
||||
+ this._workspaceIndicator = new BottomWorkspaceIndicator({
|
||||
baseStyleClass: 'window-list-workspace-indicator',
|
||||
});
|
||||
-
|
||||
indicatorsBox.add_child(this._workspaceIndicator.container);
|
||||
|
||||
this._mutterSettings = new Gio.Settings({schema_id: 'org.gnome.mutter'});
|
||||
@@ -1100,6 +1099,28 @@ class WindowList extends St.Widget {
|
||||
}
|
||||
}
|
||||
|
||||
+class BottomWorkspaceIndicator extends WorkspaceIndicator {
|
||||
+ static {
|
||||
+ GObject.registerClass(this);
|
||||
+ }
|
||||
+
|
||||
+ constructor(params) {
|
||||
+ super(params);
|
||||
+
|
||||
+ this.remove_style_class_name('panel-button');
|
||||
+ }
|
||||
+
|
||||
+ setMenu(menu) {
|
||||
+ super.setMenu(menu);
|
||||
+
|
||||
+ if (!menu)
|
||||
+ return;
|
||||
+
|
||||
+ this.menu.actor.updateArrowSide(St.Side.BOTTOM);
|
||||
+ this.menu.actor.remove_style_class_name('panel-menu');
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
export default class WindowListExtension extends Extension {
|
||||
constructor(metadata) {
|
||||
super(metadata);
|
||||
diff --git a/extensions/window-list/workspaceIndicator.js b/extensions/window-list/workspaceIndicator.js
|
||||
index 2c557e5b..69167eb6 100644
|
||||
--- a/extensions/window-list/workspaceIndicator.js
|
||||
+++ b/extensions/window-list/workspaceIndicator.js
|
||||
@@ -254,7 +254,7 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
}
|
||||
|
||||
constructor(params = {}) {
|
||||
- super(0.5, _('Workspace Indicator'), true);
|
||||
+ super(0.5, _('Workspace Indicator'));
|
||||
|
||||
const {
|
||||
baseStyleClass = 'workspace-indicator',
|
||||
@@ -263,10 +263,6 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
baseStyleClassName = baseStyleClass;
|
||||
this.add_style_class_name(baseStyleClassName);
|
||||
|
||||
- this.setMenu(new PopupMenu.PopupMenu(this, 0.0, St.Side.BOTTOM));
|
||||
- this.remove_style_class_name('panel-button');
|
||||
- this.menu.actor.remove_style_class_name('panel-menu');
|
||||
-
|
||||
let container = new St.Widget({
|
||||
layout_manager: new Clutter.BinLayout(),
|
||||
x_expand: true,
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,44 +0,0 @@
|
||||
From dca2c8505c770958849fc8dda27715a09ceab3c5 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Thu, 21 Mar 2024 16:49:35 +0100
|
||||
Subject: [PATCH 07/28] window-list: Handle changes to workspace menu
|
||||
|
||||
For now the menu is always set at construction time, however this
|
||||
will change in the future. Prepare for that by handling the
|
||||
`menu-set` signal, similar to the top bar.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/307>
|
||||
---
|
||||
extensions/window-list/extension.js | 9 ++++++++-
|
||||
1 file changed, 8 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/extensions/window-list/extension.js b/extensions/window-list/extension.js
|
||||
index 1bb7cf60..3950c535 100644
|
||||
--- a/extensions/window-list/extension.js
|
||||
+++ b/extensions/window-list/extension.js
|
||||
@@ -782,7 +782,9 @@ class WindowList extends St.Widget {
|
||||
this._updateWorkspaceIndicatorVisibility();
|
||||
|
||||
this._menuManager = new PopupMenu.PopupMenuManager(this);
|
||||
- this._menuManager.addMenu(this._workspaceIndicator.menu);
|
||||
+ this._workspaceIndicator.connectObject('menu-set',
|
||||
+ () => this._onWorkspaceMenuSet(), this);
|
||||
+ this._onWorkspaceMenuSet();
|
||||
|
||||
Main.layoutManager.addChrome(this, {
|
||||
affectsStruts: true,
|
||||
@@ -879,6 +881,11 @@ class WindowList extends St.Widget {
|
||||
children[newActive].activate();
|
||||
}
|
||||
|
||||
+ _onWorkspaceMenuSet() {
|
||||
+ if (this._workspaceIndicator.menu)
|
||||
+ this._menuManager.addMenu(this._workspaceIndicator.menu);
|
||||
+ }
|
||||
+
|
||||
_updatePosition() {
|
||||
this.set_position(
|
||||
this._monitor.x,
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,47 +0,0 @@
|
||||
From c343e1d65ddc538972640e7da86429cbd4cf2829 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Wed, 21 Feb 2024 15:58:39 +0100
|
||||
Subject: [PATCH 08/28] workspace-indicator: Don't use SCHEMA/KEY constants
|
||||
|
||||
Each constant is only used once, so all they do is disconnect
|
||||
the actual value from the code that uses it.
|
||||
|
||||
The copy in the window-list extension just uses the strings directly,
|
||||
do the same here.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/307>
|
||||
---
|
||||
extensions/workspace-indicator/workspaceIndicator.js | 10 ++++------
|
||||
1 file changed, 4 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/extensions/workspace-indicator/workspaceIndicator.js b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
index cdcc67fe..fe54b95c 100644
|
||||
--- a/extensions/workspace-indicator/workspaceIndicator.js
|
||||
+++ b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
@@ -17,9 +17,6 @@ import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
||||
import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
|
||||
import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';
|
||||
|
||||
-const WORKSPACE_SCHEMA = 'org.gnome.desktop.wm.preferences';
|
||||
-const WORKSPACE_KEY = 'workspace-names';
|
||||
-
|
||||
const TOOLTIP_OFFSET = 6;
|
||||
const TOOLTIP_ANIMATION_TIME = 150;
|
||||
|
||||
@@ -310,9 +307,10 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
this._updateThumbnails();
|
||||
this._updateThumbnailVisibility();
|
||||
|
||||
- this._settings = new Gio.Settings({schema_id: WORKSPACE_SCHEMA});
|
||||
- this._settings.connectObject(`changed::${WORKSPACE_KEY}`,
|
||||
- this._updateMenuLabels.bind(this), this);
|
||||
+ const desktopSettings =
|
||||
+ new Gio.Settings({schema_id: 'org.gnome.desktop.wm.preferences'});
|
||||
+ desktopSettings.connectObject('changed::workspace-names',
|
||||
+ () => this._updateMenuLabels(), this);
|
||||
}
|
||||
|
||||
_onDestroy() {
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,29 +0,0 @@
|
||||
From 14ab607a7695297efe98b97ab023973055189cee Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Wed, 21 Feb 2024 18:59:23 +0100
|
||||
Subject: [PATCH 09/28] workspace-indicator: Use existing property
|
||||
|
||||
We already track the current workspace index, use that
|
||||
instead of getting it from the workspace manager again.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/307>
|
||||
---
|
||||
extensions/workspace-indicator/workspaceIndicator.js | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/extensions/workspace-indicator/workspaceIndicator.js b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
index fe54b95c..26c9d7ee 100644
|
||||
--- a/extensions/workspace-indicator/workspaceIndicator.js
|
||||
+++ b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
@@ -439,7 +439,7 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
return;
|
||||
|
||||
|
||||
- let newIndex = global.workspace_manager.get_active_workspace_index() + diff;
|
||||
+ const newIndex = this._currentWorkspace + diff;
|
||||
this._activate(newIndex);
|
||||
}
|
||||
}
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,70 +0,0 @@
|
||||
From c83fd93d2e7cae124a5fddcb87f415688b3a63b6 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Wed, 21 Feb 2024 16:14:24 +0100
|
||||
Subject: [PATCH 10/28] workspace-indicator: Don't use menu section
|
||||
|
||||
We never added anything else to the menu, so we can just operate
|
||||
on the entire menu instead of an intermediate section.
|
||||
|
||||
This removes another difference with the window-list copy.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/307>
|
||||
---
|
||||
extensions/workspace-indicator/workspaceIndicator.js | 12 +++++-------
|
||||
1 file changed, 5 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/extensions/workspace-indicator/workspaceIndicator.js b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
index 26c9d7ee..117c7a65 100644
|
||||
--- a/extensions/workspace-indicator/workspaceIndicator.js
|
||||
+++ b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
@@ -292,8 +292,6 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
container.add_child(this._thumbnailsBox);
|
||||
|
||||
this._workspacesItems = [];
|
||||
- this._workspaceSection = new PopupMenu.PopupMenuSection();
|
||||
- this.menu.addMenuItem(this._workspaceSection);
|
||||
|
||||
workspaceManager.connectObject(
|
||||
'notify::n-workspaces', this._nWorkspacesChanged.bind(this), GObject.ConnectFlags.AFTER,
|
||||
@@ -303,7 +301,7 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
|
||||
this.connect('scroll-event', this._onScrollEvent.bind(this));
|
||||
this._thumbnailsBox.connect('scroll-event', this._onScrollEvent.bind(this));
|
||||
- this._createWorkspacesSection();
|
||||
+ this._updateMenu();
|
||||
this._updateThumbnails();
|
||||
this._updateThumbnailVisibility();
|
||||
|
||||
@@ -346,7 +344,7 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
}
|
||||
|
||||
_nWorkspacesChanged() {
|
||||
- this._createWorkspacesSection();
|
||||
+ this._updateMenu();
|
||||
this._updateThumbnails();
|
||||
this._updateThumbnailVisibility();
|
||||
}
|
||||
@@ -382,17 +380,17 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
this._workspacesItems[i].label.text = this._labelText(i);
|
||||
}
|
||||
|
||||
- _createWorkspacesSection() {
|
||||
+ _updateMenu() {
|
||||
let workspaceManager = global.workspace_manager;
|
||||
|
||||
- this._workspaceSection.removeAll();
|
||||
+ this.menu.removeAll();
|
||||
this._workspacesItems = [];
|
||||
this._currentWorkspace = workspaceManager.get_active_workspace_index();
|
||||
|
||||
let i = 0;
|
||||
for (; i < workspaceManager.n_workspaces; i++) {
|
||||
this._workspacesItems[i] = new PopupMenu.PopupMenuItem(this._labelText(i));
|
||||
- this._workspaceSection.addMenuItem(this._workspacesItems[i]);
|
||||
+ this.menu.addMenuItem(this._workspacesItems[i]);
|
||||
this._workspacesItems[i].workspaceId = i;
|
||||
this._workspacesItems[i].label_actor = this._statusLabel;
|
||||
this._workspacesItems[i].connect('activate', (actor, _event) => {
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,44 +0,0 @@
|
||||
From 8105cdf701db7af78bc2e17da6e01172ce7362c3 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Wed, 21 Feb 2024 13:05:15 +0100
|
||||
Subject: [PATCH 11/28] workspace-indicator: Support showing tooltips above
|
||||
|
||||
The indicator is located in the top bar, so tooltips are always
|
||||
shown below the previews. However supporting showing tooltips
|
||||
above previews when space permits allows the same code to be
|
||||
used in the copy that is included with the window-list extension.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/307>
|
||||
---
|
||||
extensions/workspace-indicator/workspaceIndicator.js | 9 +++++----
|
||||
1 file changed, 5 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/extensions/workspace-indicator/workspaceIndicator.js b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
index 117c7a65..9a1055aa 100644
|
||||
--- a/extensions/workspace-indicator/workspaceIndicator.js
|
||||
+++ b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
@@ -224,16 +224,17 @@ class WorkspaceThumbnail extends St.Button {
|
||||
});
|
||||
|
||||
const [stageX, stageY] = this.get_transformed_position();
|
||||
- const thumbWidth = this.allocation.get_width();
|
||||
- const thumbHeight = this.allocation.get_height();
|
||||
- const tipWidth = this._tooltip.width;
|
||||
+ const [thumbWidth, thumbHeight] = this.allocation.get_size();
|
||||
+ const [tipWidth, tipHeight] = this._tooltip.get_size();
|
||||
const xOffset = Math.floor((thumbWidth - tipWidth) / 2);
|
||||
const monitor = Main.layoutManager.findMonitorForActor(this);
|
||||
const x = Math.clamp(
|
||||
stageX + xOffset,
|
||||
monitor.x,
|
||||
monitor.x + monitor.width - tipWidth);
|
||||
- const y = stageY + thumbHeight + TOOLTIP_OFFSET;
|
||||
+ const y = stageY - monitor.y > thumbHeight + TOOLTIP_OFFSET
|
||||
+ ? stageY - tipHeight - TOOLTIP_OFFSET // show above
|
||||
+ : stageY + thumbHeight + TOOLTIP_OFFSET; // show below
|
||||
this._tooltip.set_position(x, y);
|
||||
}
|
||||
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,67 +0,0 @@
|
||||
From d595d168ed0fccf57b1995a4d36169d978820a7b Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Wed, 21 Feb 2024 17:37:16 +0100
|
||||
Subject: [PATCH 12/28] workspace-indicator: Only change top bar redirect when
|
||||
in top bar
|
||||
|
||||
While this is always the case for the workspace indicator, adding
|
||||
the check will allow to use the same code in the window list.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/307>
|
||||
---
|
||||
.../workspace-indicator/workspaceIndicator.js | 23 +++++++++++++++++--
|
||||
1 file changed, 21 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/extensions/workspace-indicator/workspaceIndicator.js b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
index 9a1055aa..f118654e 100644
|
||||
--- a/extensions/workspace-indicator/workspaceIndicator.js
|
||||
+++ b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
@@ -302,6 +302,16 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
|
||||
this.connect('scroll-event', this._onScrollEvent.bind(this));
|
||||
this._thumbnailsBox.connect('scroll-event', this._onScrollEvent.bind(this));
|
||||
+
|
||||
+ this._inTopBar = false;
|
||||
+ this.connect('notify::realized', () => {
|
||||
+ if (!this.realized)
|
||||
+ return;
|
||||
+
|
||||
+ this._inTopBar = Main.panel.contains(this);
|
||||
+ this._updateTopBarRedirect();
|
||||
+ });
|
||||
+
|
||||
this._updateMenu();
|
||||
this._updateThumbnails();
|
||||
this._updateThumbnailVisibility();
|
||||
@@ -313,7 +323,9 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
}
|
||||
|
||||
_onDestroy() {
|
||||
- Main.panel.set_offscreen_redirect(Clutter.OffscreenRedirect.ALWAYS);
|
||||
+ if (this._inTopBar)
|
||||
+ Main.panel.set_offscreen_redirect(Clutter.OffscreenRedirect.ALWAYS);
|
||||
+ this._inTopBar = false;
|
||||
|
||||
super._onDestroy();
|
||||
}
|
||||
@@ -328,9 +340,16 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
this._statusLabel.visible = useMenu;
|
||||
this._thumbnailsBox.visible = !useMenu;
|
||||
|
||||
+ this._updateTopBarRedirect();
|
||||
+ }
|
||||
+
|
||||
+ _updateTopBarRedirect() {
|
||||
+ if (!this._inTopBar)
|
||||
+ return;
|
||||
+
|
||||
// Disable offscreen-redirect when showing the workspace switcher
|
||||
// so that clip-to-allocation works
|
||||
- Main.panel.set_offscreen_redirect(useMenu
|
||||
+ Main.panel.set_offscreen_redirect(this._thumbnailsBox.visible
|
||||
? Clutter.OffscreenRedirect.ALWAYS
|
||||
: Clutter.OffscreenRedirect.AUTOMATIC_FOR_OPACITY);
|
||||
}
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,49 +0,0 @@
|
||||
From 49bfa46b5981e94b240780240115fcdabd46a178 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Wed, 21 Feb 2024 16:13:00 +0100
|
||||
Subject: [PATCH 13/28] workspace-indicator: Small cleanup
|
||||
|
||||
The code to update the menu labels is a bit cleaner in the
|
||||
window-list extension, so use that.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/307>
|
||||
---
|
||||
.../workspace-indicator/workspaceIndicator.js | 19 +++++++++----------
|
||||
1 file changed, 9 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/extensions/workspace-indicator/workspaceIndicator.js b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
index f118654e..e04e93a4 100644
|
||||
--- a/extensions/workspace-indicator/workspaceIndicator.js
|
||||
+++ b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
@@ -407,19 +407,18 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
this._workspacesItems = [];
|
||||
this._currentWorkspace = workspaceManager.get_active_workspace_index();
|
||||
|
||||
- let i = 0;
|
||||
- for (; i < workspaceManager.n_workspaces; i++) {
|
||||
- this._workspacesItems[i] = new PopupMenu.PopupMenuItem(this._labelText(i));
|
||||
- this.menu.addMenuItem(this._workspacesItems[i]);
|
||||
- this._workspacesItems[i].workspaceId = i;
|
||||
- this._workspacesItems[i].label_actor = this._statusLabel;
|
||||
- this._workspacesItems[i].connect('activate', (actor, _event) => {
|
||||
- this._activate(actor.workspaceId);
|
||||
- });
|
||||
+ for (let i = 0; i < workspaceManager.n_workspaces; i++) {
|
||||
+ const item = new PopupMenu.PopupMenuItem(this._labelText(i));
|
||||
|
||||
- this._workspacesItems[i].setOrnament(i === this._currentWorkspace
|
||||
+ item.connect('activate',
|
||||
+ () => this._activate(i));
|
||||
+
|
||||
+ item.setOrnament(i === this._currentWorkspace
|
||||
? PopupMenu.Ornament.DOT
|
||||
: PopupMenu.Ornament.NO_DOT);
|
||||
+
|
||||
+ this.menu.addMenuItem(item);
|
||||
+ this._workspacesItems[i] = item;
|
||||
}
|
||||
|
||||
this._statusLabel.set_text(this._labelText());
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,87 +0,0 @@
|
||||
From 5455a97a04c6a2925f5113a85c2e09cff215941d Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Wed, 21 Feb 2024 16:13:00 +0100
|
||||
Subject: [PATCH 14/28] workspace-indicator: Simplify getting status text
|
||||
|
||||
Currently the same method is used to get the label text for the
|
||||
indicator itself and for the menu items.
|
||||
|
||||
A method that behaves significantly different depending on whether
|
||||
a parameter is passed is confusing, so only deal with the indicator
|
||||
label and directly use the mutter API to get the workspace names
|
||||
for menu items.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/307>
|
||||
---
|
||||
.../workspace-indicator/workspaceIndicator.js | 24 +++++++++----------
|
||||
1 file changed, 12 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/extensions/workspace-indicator/workspaceIndicator.js b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
index e04e93a4..0538e6b2 100644
|
||||
--- a/extensions/workspace-indicator/workspaceIndicator.js
|
||||
+++ b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
@@ -279,7 +279,7 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
this._statusLabel = new St.Label({
|
||||
style_class: 'status-label',
|
||||
y_align: Clutter.ActorAlign.CENTER,
|
||||
- text: this._labelText(),
|
||||
+ text: this._getStatusText(),
|
||||
});
|
||||
|
||||
container.add_child(this._statusLabel);
|
||||
@@ -360,7 +360,7 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
this._updateMenuOrnament();
|
||||
this._updateActiveThumbnail();
|
||||
|
||||
- this._statusLabel.set_text(this._labelText());
|
||||
+ this._statusLabel.set_text(this._getStatusText());
|
||||
}
|
||||
|
||||
_nWorkspacesChanged() {
|
||||
@@ -387,17 +387,16 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
}
|
||||
}
|
||||
|
||||
- _labelText(workspaceIndex) {
|
||||
- if (workspaceIndex === undefined) {
|
||||
- workspaceIndex = this._currentWorkspace;
|
||||
- return (workspaceIndex + 1).toString();
|
||||
- }
|
||||
- return Meta.prefs_get_workspace_name(workspaceIndex);
|
||||
+ _getStatusText() {
|
||||
+ const current = this._currentWorkspace + 1;
|
||||
+ return `${current}`;
|
||||
}
|
||||
|
||||
_updateMenuLabels() {
|
||||
- for (let i = 0; i < this._workspacesItems.length; i++)
|
||||
- this._workspacesItems[i].label.text = this._labelText(i);
|
||||
+ for (let i = 0; i < this._workspacesItems.length; i++) {
|
||||
+ const item = this._workspacesItems[i];
|
||||
+ item.label.text = Meta.prefs_get_workspace_name(i);
|
||||
+ }
|
||||
}
|
||||
|
||||
_updateMenu() {
|
||||
@@ -408,7 +407,8 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
this._currentWorkspace = workspaceManager.get_active_workspace_index();
|
||||
|
||||
for (let i = 0; i < workspaceManager.n_workspaces; i++) {
|
||||
- const item = new PopupMenu.PopupMenuItem(this._labelText(i));
|
||||
+ const name = Meta.prefs_get_workspace_name(i);
|
||||
+ const item = new PopupMenu.PopupMenuItem(name);
|
||||
|
||||
item.connect('activate',
|
||||
() => this._activate(i));
|
||||
@@ -421,7 +421,7 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
this._workspacesItems[i] = item;
|
||||
}
|
||||
|
||||
- this._statusLabel.set_text(this._labelText());
|
||||
+ this._statusLabel.set_text(this._getStatusText());
|
||||
}
|
||||
|
||||
_updateThumbnails() {
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,37 +0,0 @@
|
||||
From f14ae4e2725b4a98ec2e11151c4162e7a6494604 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Wed, 21 Feb 2024 16:35:09 +0100
|
||||
Subject: [PATCH 15/28] workspace-indicator: Include n-workspaces in status
|
||||
label
|
||||
|
||||
The two extensions currently use a slightly different label
|
||||
in menu mode:
|
||||
The workspace indicator uses the plain workspace number ("2"),
|
||||
while the window list includes the number of workspaces ("2 / 4").
|
||||
|
||||
The additional information seem useful, as well as the slightly
|
||||
bigger click/touch target, so copy the window-list behavior.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/307>
|
||||
---
|
||||
extensions/workspace-indicator/workspaceIndicator.js | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/extensions/workspace-indicator/workspaceIndicator.js b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
index 0538e6b2..594a9e51 100644
|
||||
--- a/extensions/workspace-indicator/workspaceIndicator.js
|
||||
+++ b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
@@ -388,8 +388,9 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
}
|
||||
|
||||
_getStatusText() {
|
||||
+ const {nWorkspaces} = global.workspace_manager;
|
||||
const current = this._currentWorkspace + 1;
|
||||
- return `${current}`;
|
||||
+ return `${current} / ${nWorkspaces}`;
|
||||
}
|
||||
|
||||
_updateMenuLabels() {
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,56 +0,0 @@
|
||||
From aca00d6e3a8b7d1fc59b19e9855685989127d59f Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Thu, 22 Feb 2024 04:45:23 +0100
|
||||
Subject: [PATCH 16/28] workspace-indicator: Tweak preview style
|
||||
|
||||
Sync sizes and padding with the window-list previews.
|
||||
|
||||
Tone down the colors a bit, but less then the current window-list
|
||||
style where workspaces blend too much into the background and
|
||||
the selection is unclear.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/307>
|
||||
---
|
||||
extensions/workspace-indicator/stylesheet.css | 15 ++++++++-------
|
||||
1 file changed, 8 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/extensions/workspace-indicator/stylesheet.css b/extensions/workspace-indicator/stylesheet.css
|
||||
index 749878c1..3e2ba67f 100644
|
||||
--- a/extensions/workspace-indicator/stylesheet.css
|
||||
+++ b/extensions/workspace-indicator/stylesheet.css
|
||||
@@ -10,24 +10,25 @@
|
||||
}
|
||||
|
||||
.workspace-indicator .workspaces-box {
|
||||
- padding: 4px 0;
|
||||
- spacing: 4px;
|
||||
+ padding: 5px;
|
||||
+ spacing: 3px;
|
||||
}
|
||||
|
||||
.workspace-indicator .workspace {
|
||||
- width: 40px;
|
||||
- border: 2px solid #000;
|
||||
- border-radius: 2px;
|
||||
- background-color: #595959;
|
||||
+ width: 52px;
|
||||
+ border: 2px solid transparent;
|
||||
+ border-radius: 4px;
|
||||
+ background-color: #3f3f3f;
|
||||
}
|
||||
|
||||
.workspace-indicator .workspace.active {
|
||||
- border-color: #fff;
|
||||
+ border-color: #9f9f9f;
|
||||
}
|
||||
|
||||
.workspace-indicator-window-preview {
|
||||
background-color: #bebebe;
|
||||
border: 1px solid #828282;
|
||||
+ border-radius: 1px;
|
||||
}
|
||||
|
||||
.workspace-indicator-window-preview.active {
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,71 +0,0 @@
|
||||
From 5d7cd70f55a3da9454bffaf0bbcb32dacc8e1971 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Wed, 21 Feb 2024 23:22:58 +0100
|
||||
Subject: [PATCH 17/28] workspace-indicator: Support light style
|
||||
|
||||
The window-list extension already includes light styling for
|
||||
its copy of the workspace indicator. Just copy that over to
|
||||
support the light variant here as well.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/307>
|
||||
---
|
||||
extensions/workspace-indicator/meson.build | 5 +++-
|
||||
.../{stylesheet.css => stylesheet-dark.css} | 0
|
||||
.../workspace-indicator/stylesheet-light.css | 25 +++++++++++++++++++
|
||||
3 files changed, 29 insertions(+), 1 deletion(-)
|
||||
rename extensions/workspace-indicator/{stylesheet.css => stylesheet-dark.css} (100%)
|
||||
create mode 100644 extensions/workspace-indicator/stylesheet-light.css
|
||||
|
||||
diff --git a/extensions/workspace-indicator/meson.build b/extensions/workspace-indicator/meson.build
|
||||
index 6dd08dae..dada5408 100644
|
||||
--- a/extensions/workspace-indicator/meson.build
|
||||
+++ b/extensions/workspace-indicator/meson.build
|
||||
@@ -7,6 +7,9 @@ extension_data += configure_file(
|
||||
output: metadata_name,
|
||||
configuration: metadata_conf
|
||||
)
|
||||
-extension_data += files('stylesheet.css')
|
||||
+extension_data += files(
|
||||
+ 'stylesheet-dark.css',
|
||||
+ 'stylesheet-light.css',
|
||||
+)
|
||||
|
||||
extension_sources += files('prefs.js', 'workspaceIndicator.js')
|
||||
diff --git a/extensions/workspace-indicator/stylesheet.css b/extensions/workspace-indicator/stylesheet-dark.css
|
||||
similarity index 100%
|
||||
rename from extensions/workspace-indicator/stylesheet.css
|
||||
rename to extensions/workspace-indicator/stylesheet-dark.css
|
||||
diff --git a/extensions/workspace-indicator/stylesheet-light.css b/extensions/workspace-indicator/stylesheet-light.css
|
||||
new file mode 100644
|
||||
index 00000000..049b6a38
|
||||
--- /dev/null
|
||||
+++ b/extensions/workspace-indicator/stylesheet-light.css
|
||||
@@ -0,0 +1,25 @@
|
||||
+/*
|
||||
+ * SPDX-FileCopyrightText: 2013 Florian Müllner <fmuellner@gnome.org>
|
||||
+ * SPDX-FileCopyrightText: 2015 Jakub Steiner <jimmac@gmail.com>
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: GPL-2.0-or-later
|
||||
+ */
|
||||
+
|
||||
+@import url("stylesheet-dark.css");
|
||||
+
|
||||
+.workspace-indicator .workspace {
|
||||
+ background-color: #ccc;
|
||||
+}
|
||||
+
|
||||
+.workspace-indicator .workspace.active {
|
||||
+ border-color: #888;
|
||||
+}
|
||||
+
|
||||
+.workspace-indicator-window-preview {
|
||||
+ background-color: #ededed;
|
||||
+ border: 1px solid #ccc;
|
||||
+}
|
||||
+
|
||||
+.workspace-indicator-window-preview.active {
|
||||
+ background-color: #f6f5f4;
|
||||
+}
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,30 +0,0 @@
|
||||
From d0730c0d9314963bb784ebce408c29b8c2610fc4 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Mon, 15 Apr 2024 20:18:34 +0200
|
||||
Subject: [PATCH 18/28] export-zips: Pick up non-default stylesheets
|
||||
|
||||
The window-list extension is about to import the workspace-indicator
|
||||
stylesheet. Explicitly pack css files, so the stylesheet is included
|
||||
in the bundle.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/307>
|
||||
---
|
||||
export-zips.sh | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/export-zips.sh b/export-zips.sh
|
||||
index 57c62860..2d7383c3 100755
|
||||
--- a/export-zips.sh
|
||||
+++ b/export-zips.sh
|
||||
@@ -39,7 +39,7 @@ for f in $extensiondir/*; do
|
||||
fi
|
||||
|
||||
cp $srcdir/NEWS $srcdir/COPYING $f
|
||||
- sources=(NEWS COPYING $(cd $f; ls *.js))
|
||||
+ sources=(NEWS COPYING $(cd $f; ls *.js *.css 2>/dev/null))
|
||||
|
||||
[ -d $f/icons ] && sources+=(icons)
|
||||
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,589 +0,0 @@
|
||||
From b15212a2d62ff93c1652ef717f778dda3a70f5e8 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Wed, 21 Feb 2024 13:08:52 +0100
|
||||
Subject: [PATCH 19/28] window-list: Use actual copy of workspace-indicator
|
||||
|
||||
We are now at a point where the code from the workspace-indicator
|
||||
extension is usable from the window-list.
|
||||
|
||||
However instead of updating the copy, go one step further and
|
||||
remove it altogether, and copy the required files at build time.
|
||||
|
||||
This ensures that future changes are picked up by both extensions
|
||||
without duplicating any work.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/307>
|
||||
---
|
||||
extensions/window-list/meson.build | 29 +-
|
||||
extensions/window-list/stylesheet-dark.css | 31 +-
|
||||
extensions/window-list/stylesheet-light.css | 20 +-
|
||||
extensions/window-list/workspaceIndicator.js | 435 -------------------
|
||||
4 files changed, 30 insertions(+), 485 deletions(-)
|
||||
delete mode 100644 extensions/window-list/workspaceIndicator.js
|
||||
|
||||
diff --git a/extensions/window-list/meson.build b/extensions/window-list/meson.build
|
||||
index 718cdf7a..6fd17007 100644
|
||||
--- a/extensions/window-list/meson.build
|
||||
+++ b/extensions/window-list/meson.build
|
||||
@@ -12,5 +12,32 @@ extension_data += files(
|
||||
'stylesheet-light.css'
|
||||
)
|
||||
|
||||
-extension_sources += files('prefs.js', 'workspaceIndicator.js')
|
||||
+transform_stylesheet = [
|
||||
+ 'sed', '-E',
|
||||
+ '-e', 's:^\.(workspace-indicator):.window-list-\\1:',
|
||||
+ '-e', '/^@import/d',
|
||||
+ '@INPUT@',
|
||||
+ ]
|
||||
+
|
||||
+workspaceIndicatorSources = [
|
||||
+ configure_file(
|
||||
+ input: '../workspace-indicator/workspaceIndicator.js',
|
||||
+ output: '@PLAINNAME@',
|
||||
+ copy: true,
|
||||
+ ),
|
||||
+ configure_file(
|
||||
+ input: '../workspace-indicator/stylesheet-dark.css',
|
||||
+ output: 'stylesheet-workspace-switcher-dark.css',
|
||||
+ command: transform_stylesheet,
|
||||
+ capture: true,
|
||||
+ ),
|
||||
+ configure_file(
|
||||
+ input: '../workspace-indicator/stylesheet-light.css',
|
||||
+ output: 'stylesheet-workspace-switcher-light.css',
|
||||
+ command: transform_stylesheet,
|
||||
+ capture: true,
|
||||
+ ),
|
||||
+]
|
||||
+
|
||||
+extension_sources += files('prefs.js') + workspaceIndicatorSources
|
||||
extension_schemas += files(metadata_conf.get('gschemaname') + '.gschema.xml')
|
||||
diff --git a/extensions/window-list/stylesheet-dark.css b/extensions/window-list/stylesheet-dark.css
|
||||
index fbadf4d0..9e024f2c 100644
|
||||
--- a/extensions/window-list/stylesheet-dark.css
|
||||
+++ b/extensions/window-list/stylesheet-dark.css
|
||||
@@ -4,6 +4,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
+@import url("stylesheet-workspace-switcher-dark.css");
|
||||
|
||||
.window-list {
|
||||
spacing: 2px;
|
||||
@@ -81,36 +82,6 @@
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
-.window-list-workspace-indicator .status-label-bin {
|
||||
- background-color: rgba(200, 200, 200, 0.3);
|
||||
- padding: 5px;
|
||||
- margin: 3px;
|
||||
-}
|
||||
-
|
||||
-.window-list-workspace-indicator .workspaces-box {
|
||||
- spacing: 3px;
|
||||
- padding: 5px;
|
||||
-}
|
||||
-
|
||||
-.window-list-workspace-indicator .workspace {
|
||||
- width: 52px;
|
||||
- border-radius: 4px;
|
||||
- background-color: #1e1e1e;
|
||||
-}
|
||||
-
|
||||
-.window-list-workspace-indicator .workspace.active {
|
||||
- background-color: #3f3f3f;
|
||||
-}
|
||||
-
|
||||
-.window-list-workspace-indicator-window-preview {
|
||||
- background-color: #bebebe;
|
||||
- border-radius: 1px;
|
||||
-}
|
||||
-
|
||||
-.window-list-workspace-indicator-window-preview.active {
|
||||
- background-color: #d4d4d4;
|
||||
-}
|
||||
-
|
||||
.notification {
|
||||
font-weight: normal;
|
||||
}
|
||||
diff --git a/extensions/window-list/stylesheet-light.css b/extensions/window-list/stylesheet-light.css
|
||||
index e9352362..93a96581 100644
|
||||
--- a/extensions/window-list/stylesheet-light.css
|
||||
+++ b/extensions/window-list/stylesheet-light.css
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
@import url("stylesheet-dark.css");
|
||||
+@import url("stylesheet-workspace-switcher-light.css");
|
||||
|
||||
#panel.bottom-panel {
|
||||
border-top-width: 1px;
|
||||
@@ -50,22 +51,3 @@
|
||||
color: #888;
|
||||
box-shadow: none;
|
||||
}
|
||||
-
|
||||
-/* workspace switcher */
|
||||
-.window-list-workspace-indicator .workspace {
|
||||
- border: 2px solid #f6f5f4;
|
||||
- background-color: #ccc;
|
||||
-}
|
||||
-
|
||||
-.window-list-workspace-indicator .workspace.active {
|
||||
- border-color: #888;
|
||||
-}
|
||||
-
|
||||
-.window-list-workspace-indicator-window-preview {
|
||||
- background-color: #ededed;
|
||||
- border: 1px solid #ccc;
|
||||
-}
|
||||
-
|
||||
-.window-list-workspace-indicator-window-preview.active {
|
||||
- background-color: #f6f5f4;
|
||||
-}
|
||||
diff --git a/extensions/window-list/workspaceIndicator.js b/extensions/window-list/workspaceIndicator.js
|
||||
deleted file mode 100644
|
||||
index 69167eb6..00000000
|
||||
--- a/extensions/window-list/workspaceIndicator.js
|
||||
+++ /dev/null
|
||||
@@ -1,435 +0,0 @@
|
||||
-// SPDX-FileCopyrightText: 2019 Florian Müllner <fmuellner@gnome.org>
|
||||
-//
|
||||
-// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
-
|
||||
-import Clutter from 'gi://Clutter';
|
||||
-import Gio from 'gi://Gio';
|
||||
-import GObject from 'gi://GObject';
|
||||
-import Meta from 'gi://Meta';
|
||||
-import St from 'gi://St';
|
||||
-
|
||||
-import {gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js';
|
||||
-
|
||||
-import * as DND from 'resource:///org/gnome/shell/ui/dnd.js';
|
||||
-import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
||||
-import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
|
||||
-import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';
|
||||
-
|
||||
-const TOOLTIP_OFFSET = 6;
|
||||
-const TOOLTIP_ANIMATION_TIME = 150;
|
||||
-
|
||||
-const MAX_THUMBNAILS = 6;
|
||||
-
|
||||
-let baseStyleClassName = '';
|
||||
-
|
||||
-class WindowPreview extends St.Button {
|
||||
- static {
|
||||
- GObject.registerClass(this);
|
||||
- }
|
||||
-
|
||||
- constructor(window) {
|
||||
- super({
|
||||
- style_class: `${baseStyleClassName}-window-preview`,
|
||||
- });
|
||||
-
|
||||
- this._delegate = this;
|
||||
- DND.makeDraggable(this, {restoreOnSuccess: true});
|
||||
-
|
||||
- this._window = window;
|
||||
-
|
||||
- this._window.connectObject(
|
||||
- 'size-changed', () => this._checkRelayout(),
|
||||
- 'position-changed', () => this._checkRelayout(),
|
||||
- 'notify::minimized', this._updateVisible.bind(this),
|
||||
- 'notify::window-type', this._updateVisible.bind(this),
|
||||
- this);
|
||||
- this._updateVisible();
|
||||
-
|
||||
- global.display.connectObject('notify::focus-window',
|
||||
- this._onFocusChanged.bind(this), this);
|
||||
- this._onFocusChanged();
|
||||
- }
|
||||
-
|
||||
- // needed for DND
|
||||
- get metaWindow() {
|
||||
- return this._window;
|
||||
- }
|
||||
-
|
||||
- _onFocusChanged() {
|
||||
- if (global.display.focus_window === this._window)
|
||||
- this.add_style_class_name('active');
|
||||
- else
|
||||
- this.remove_style_class_name('active');
|
||||
- }
|
||||
-
|
||||
- _checkRelayout() {
|
||||
- const monitor = Main.layoutManager.findIndexForActor(this);
|
||||
- const workArea = Main.layoutManager.getWorkAreaForMonitor(monitor);
|
||||
- if (this._window.get_frame_rect().overlap(workArea))
|
||||
- this.queue_relayout();
|
||||
- }
|
||||
-
|
||||
- _updateVisible() {
|
||||
- this.visible = this._window.window_type !== Meta.WindowType.DESKTOP &&
|
||||
- this._window.showing_on_its_workspace();
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-class WorkspaceLayout extends Clutter.LayoutManager {
|
||||
- static {
|
||||
- GObject.registerClass(this);
|
||||
- }
|
||||
-
|
||||
- vfunc_get_preferred_width() {
|
||||
- return [0, 0];
|
||||
- }
|
||||
-
|
||||
- vfunc_get_preferred_height() {
|
||||
- return [0, 0];
|
||||
- }
|
||||
-
|
||||
- vfunc_allocate(container, box) {
|
||||
- const monitor = Main.layoutManager.findIndexForActor(container);
|
||||
- const workArea = Main.layoutManager.getWorkAreaForMonitor(monitor);
|
||||
- const hscale = box.get_width() / workArea.width;
|
||||
- const vscale = box.get_height() / workArea.height;
|
||||
-
|
||||
- for (const child of container) {
|
||||
- const childBox = new Clutter.ActorBox();
|
||||
- const frameRect = child.metaWindow.get_frame_rect();
|
||||
- childBox.set_size(
|
||||
- Math.round(Math.min(frameRect.width, workArea.width) * hscale),
|
||||
- Math.round(Math.min(frameRect.height, workArea.height) * vscale));
|
||||
- childBox.set_origin(
|
||||
- Math.round((frameRect.x - workArea.x) * hscale),
|
||||
- Math.round((frameRect.y - workArea.y) * vscale));
|
||||
- child.allocate(childBox);
|
||||
- }
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-class WorkspaceThumbnail extends St.Button {
|
||||
- static {
|
||||
- GObject.registerClass(this);
|
||||
- }
|
||||
-
|
||||
- constructor(index) {
|
||||
- super({
|
||||
- style_class: 'workspace',
|
||||
- child: new Clutter.Actor({
|
||||
- layout_manager: new WorkspaceLayout(),
|
||||
- clip_to_allocation: true,
|
||||
- x_expand: true,
|
||||
- y_expand: true,
|
||||
- }),
|
||||
- });
|
||||
-
|
||||
- this._tooltip = new St.Label({
|
||||
- style_class: 'dash-label',
|
||||
- visible: false,
|
||||
- });
|
||||
- Main.uiGroup.add_child(this._tooltip);
|
||||
-
|
||||
- this.connect('destroy', this._onDestroy.bind(this));
|
||||
- this.connect('notify::hover', this._syncTooltip.bind(this));
|
||||
-
|
||||
- this._index = index;
|
||||
- this._delegate = this; // needed for DND
|
||||
-
|
||||
- this._windowPreviews = new Map();
|
||||
-
|
||||
- let workspaceManager = global.workspace_manager;
|
||||
- this._workspace = workspaceManager.get_workspace_by_index(index);
|
||||
-
|
||||
- this._workspace.connectObject(
|
||||
- 'window-added', (ws, window) => this._addWindow(window),
|
||||
- 'window-removed', (ws, window) => this._removeWindow(window),
|
||||
- this);
|
||||
-
|
||||
- global.display.connectObject('restacked',
|
||||
- this._onRestacked.bind(this), this);
|
||||
-
|
||||
- this._workspace.list_windows().forEach(w => this._addWindow(w));
|
||||
- this._onRestacked();
|
||||
- }
|
||||
-
|
||||
- acceptDrop(source) {
|
||||
- if (!source.metaWindow)
|
||||
- return false;
|
||||
-
|
||||
- this._moveWindow(source.metaWindow);
|
||||
- return true;
|
||||
- }
|
||||
-
|
||||
- handleDragOver(source) {
|
||||
- if (source.metaWindow)
|
||||
- return DND.DragMotionResult.MOVE_DROP;
|
||||
- else
|
||||
- return DND.DragMotionResult.CONTINUE;
|
||||
- }
|
||||
-
|
||||
- _addWindow(window) {
|
||||
- if (this._windowPreviews.has(window))
|
||||
- return;
|
||||
-
|
||||
- let preview = new WindowPreview(window);
|
||||
- preview.connect('clicked', (a, btn) => this.emit('clicked', btn));
|
||||
- this._windowPreviews.set(window, preview);
|
||||
- this.child.add_child(preview);
|
||||
- }
|
||||
-
|
||||
- _removeWindow(window) {
|
||||
- let preview = this._windowPreviews.get(window);
|
||||
- if (!preview)
|
||||
- return;
|
||||
-
|
||||
- this._windowPreviews.delete(window);
|
||||
- preview.destroy();
|
||||
- }
|
||||
-
|
||||
- _onRestacked() {
|
||||
- let lastPreview = null;
|
||||
- let windows = global.get_window_actors().map(a => a.meta_window);
|
||||
- for (let i = 0; i < windows.length; i++) {
|
||||
- let preview = this._windowPreviews.get(windows[i]);
|
||||
- if (!preview)
|
||||
- continue;
|
||||
-
|
||||
- this.child.set_child_above_sibling(preview, lastPreview);
|
||||
- lastPreview = preview;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- _moveWindow(window) {
|
||||
- let monitorIndex = Main.layoutManager.findIndexForActor(this);
|
||||
- if (monitorIndex !== window.get_monitor())
|
||||
- window.move_to_monitor(monitorIndex);
|
||||
- window.change_workspace_by_index(this._index, false);
|
||||
- }
|
||||
-
|
||||
- on_clicked() {
|
||||
- let ws = global.workspace_manager.get_workspace_by_index(this._index);
|
||||
- if (ws)
|
||||
- ws.activate(global.get_current_time());
|
||||
- }
|
||||
-
|
||||
- _syncTooltip() {
|
||||
- if (this.hover) {
|
||||
- this._tooltip.set({
|
||||
- text: Meta.prefs_get_workspace_name(this._index),
|
||||
- visible: true,
|
||||
- opacity: 0,
|
||||
- });
|
||||
-
|
||||
- const [stageX, stageY] = this.get_transformed_position();
|
||||
- const thumbWidth = this.allocation.get_width();
|
||||
- const tipWidth = this._tooltip.width;
|
||||
- const tipHeight = this._tooltip.height;
|
||||
- const xOffset = Math.floor((thumbWidth - tipWidth) / 2);
|
||||
- const monitor = Main.layoutManager.findMonitorForActor(this);
|
||||
- const x = Math.clamp(
|
||||
- stageX + xOffset,
|
||||
- monitor.x,
|
||||
- monitor.x + monitor.width - tipWidth);
|
||||
- const y = stageY - tipHeight - TOOLTIP_OFFSET;
|
||||
- this._tooltip.set_position(x, y);
|
||||
- }
|
||||
-
|
||||
- this._tooltip.ease({
|
||||
- opacity: this.hover ? 255 : 0,
|
||||
- duration: TOOLTIP_ANIMATION_TIME,
|
||||
- mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
||||
- onComplete: () => (this._tooltip.visible = this.hover),
|
||||
- });
|
||||
- }
|
||||
-
|
||||
- _onDestroy() {
|
||||
- this._tooltip.destroy();
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
- static {
|
||||
- GObject.registerClass(this);
|
||||
- }
|
||||
-
|
||||
- constructor(params = {}) {
|
||||
- super(0.5, _('Workspace Indicator'));
|
||||
-
|
||||
- const {
|
||||
- baseStyleClass = 'workspace-indicator',
|
||||
- } = params;
|
||||
-
|
||||
- baseStyleClassName = baseStyleClass;
|
||||
- this.add_style_class_name(baseStyleClassName);
|
||||
-
|
||||
- let container = new St.Widget({
|
||||
- layout_manager: new Clutter.BinLayout(),
|
||||
- x_expand: true,
|
||||
- y_expand: true,
|
||||
- });
|
||||
- this.add_child(container);
|
||||
-
|
||||
- let workspaceManager = global.workspace_manager;
|
||||
-
|
||||
- this._currentWorkspace = workspaceManager.get_active_workspace_index();
|
||||
- this._statusLabel = new St.Label({text: this._getStatusText()});
|
||||
-
|
||||
- this._statusBin = new St.Bin({
|
||||
- style_class: 'status-label-bin',
|
||||
- x_expand: true,
|
||||
- y_expand: true,
|
||||
- child: this._statusLabel,
|
||||
- });
|
||||
- container.add_child(this._statusBin);
|
||||
-
|
||||
- this._thumbnailsBox = new St.BoxLayout({
|
||||
- style_class: 'workspaces-box',
|
||||
- y_expand: true,
|
||||
- reactive: true,
|
||||
- });
|
||||
- this._thumbnailsBox.connect('scroll-event',
|
||||
- this._onScrollEvent.bind(this));
|
||||
- container.add_child(this._thumbnailsBox);
|
||||
-
|
||||
- this._workspacesItems = [];
|
||||
-
|
||||
- workspaceManager.connectObject(
|
||||
- 'notify::n-workspaces', this._nWorkspacesChanged.bind(this), GObject.ConnectFlags.AFTER,
|
||||
- 'workspace-switched', this._onWorkspaceSwitched.bind(this), GObject.ConnectFlags.AFTER,
|
||||
- 'notify::layout-rows', this._updateThumbnailVisibility.bind(this),
|
||||
- this);
|
||||
-
|
||||
- this.connect('scroll-event', this._onScrollEvent.bind(this));
|
||||
- this._updateMenu();
|
||||
- this._updateThumbnails();
|
||||
- this._updateThumbnailVisibility();
|
||||
-
|
||||
- this._settings = new Gio.Settings({schema_id: 'org.gnome.desktop.wm.preferences'});
|
||||
- this._settings.connectObject('changed::workspace-names',
|
||||
- () => this._updateMenuLabels(), this);
|
||||
- }
|
||||
-
|
||||
- _updateThumbnailVisibility() {
|
||||
- const {workspaceManager} = global;
|
||||
- const vertical = workspaceManager.layout_rows === -1;
|
||||
- const useMenu =
|
||||
- vertical || workspaceManager.n_workspaces > MAX_THUMBNAILS;
|
||||
- this.reactive = useMenu;
|
||||
-
|
||||
- this._statusBin.visible = useMenu;
|
||||
- this._thumbnailsBox.visible = !useMenu;
|
||||
- }
|
||||
-
|
||||
- _onWorkspaceSwitched() {
|
||||
- let workspaceManager = global.workspace_manager;
|
||||
- this._currentWorkspace = workspaceManager.get_active_workspace_index();
|
||||
-
|
||||
- this._updateMenuOrnament();
|
||||
- this._updateActiveThumbnail();
|
||||
-
|
||||
- this._statusLabel.set_text(this._getStatusText());
|
||||
- }
|
||||
-
|
||||
- _nWorkspacesChanged() {
|
||||
- this._updateMenu();
|
||||
- this._updateThumbnails();
|
||||
- this._updateThumbnailVisibility();
|
||||
- }
|
||||
-
|
||||
- _updateMenuOrnament() {
|
||||
- for (let i = 0; i < this._workspacesItems.length; i++) {
|
||||
- this._workspacesItems[i].setOrnament(i === this._currentWorkspace
|
||||
- ? PopupMenu.Ornament.DOT
|
||||
- : PopupMenu.Ornament.NO_DOT);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- _updateActiveThumbnail() {
|
||||
- let thumbs = this._thumbnailsBox.get_children();
|
||||
- for (let i = 0; i < thumbs.length; i++) {
|
||||
- if (i === this._currentWorkspace)
|
||||
- thumbs[i].add_style_class_name('active');
|
||||
- else
|
||||
- thumbs[i].remove_style_class_name('active');
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- _getStatusText() {
|
||||
- let workspaceManager = global.workspace_manager;
|
||||
- let current = workspaceManager.get_active_workspace_index();
|
||||
- let total = workspaceManager.n_workspaces;
|
||||
-
|
||||
- return '%d / %d'.format(current + 1, total);
|
||||
- }
|
||||
-
|
||||
- _updateMenuLabels() {
|
||||
- for (let i = 0; i < this._workspacesItems.length; i++) {
|
||||
- let item = this._workspacesItems[i];
|
||||
- let name = Meta.prefs_get_workspace_name(i);
|
||||
- item.label.text = name;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- _updateMenu() {
|
||||
- let workspaceManager = global.workspace_manager;
|
||||
-
|
||||
- this.menu.removeAll();
|
||||
- this._workspacesItems = [];
|
||||
- this._currentWorkspace = workspaceManager.get_active_workspace_index();
|
||||
-
|
||||
- for (let i = 0; i < workspaceManager.n_workspaces; i++) {
|
||||
- let name = Meta.prefs_get_workspace_name(i);
|
||||
- let item = new PopupMenu.PopupMenuItem(name);
|
||||
- item.workspaceId = i;
|
||||
-
|
||||
- item.connect('activate', () => {
|
||||
- this._activate(item.workspaceId);
|
||||
- });
|
||||
-
|
||||
- item.setOrnament(i === this._currentWorkspace
|
||||
- ? PopupMenu.Ornament.DOT
|
||||
- : PopupMenu.Ornament.NO_DOT);
|
||||
-
|
||||
- this.menu.addMenuItem(item);
|
||||
- this._workspacesItems[i] = item;
|
||||
- }
|
||||
-
|
||||
- this._statusLabel.set_text(this._getStatusText());
|
||||
- }
|
||||
-
|
||||
- _updateThumbnails() {
|
||||
- let workspaceManager = global.workspace_manager;
|
||||
-
|
||||
- this._thumbnailsBox.destroy_all_children();
|
||||
-
|
||||
- for (let i = 0; i < workspaceManager.n_workspaces; i++) {
|
||||
- let thumb = new WorkspaceThumbnail(i);
|
||||
- this._thumbnailsBox.add_child(thumb);
|
||||
- }
|
||||
- this._updateActiveThumbnail();
|
||||
- }
|
||||
-
|
||||
- _activate(index) {
|
||||
- let workspaceManager = global.workspace_manager;
|
||||
-
|
||||
- if (index >= 0 && index < workspaceManager.n_workspaces) {
|
||||
- let metaWorkspace = workspaceManager.get_workspace_by_index(index);
|
||||
- metaWorkspace.activate(global.get_current_time());
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- _onScrollEvent(actor, event) {
|
||||
- let direction = event.get_scroll_direction();
|
||||
- let diff = 0;
|
||||
- if (direction === Clutter.ScrollDirection.DOWN)
|
||||
- diff = 1;
|
||||
- else if (direction === Clutter.ScrollDirection.UP)
|
||||
- diff = -1;
|
||||
- else
|
||||
- return;
|
||||
-
|
||||
- let newIndex = this._currentWorkspace + diff;
|
||||
- this._activate(newIndex);
|
||||
- }
|
||||
-}
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,53 +0,0 @@
|
||||
From 3c1638195b33f9dfdd3df7847e88fab97188520a Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Tue, 20 Feb 2024 17:39:49 +0100
|
||||
Subject: [PATCH 20/28] workspace-indicator: Simplify scroll handling
|
||||
|
||||
gnome-shell already includes a method for switching workspaces
|
||||
via scroll events. Use that instead of implementing our own.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/316>
|
||||
---
|
||||
.../workspace-indicator/workspaceIndicator.js | 21 ++++---------------
|
||||
1 file changed, 4 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/extensions/workspace-indicator/workspaceIndicator.js b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
index 594a9e51..14dd81d0 100644
|
||||
--- a/extensions/workspace-indicator/workspaceIndicator.js
|
||||
+++ b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
@@ -300,8 +300,10 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
'notify::layout-rows', this._updateThumbnailVisibility.bind(this),
|
||||
this);
|
||||
|
||||
- this.connect('scroll-event', this._onScrollEvent.bind(this));
|
||||
- this._thumbnailsBox.connect('scroll-event', this._onScrollEvent.bind(this));
|
||||
+ this.connect('scroll-event',
|
||||
+ (a, event) => Main.wm.handleWorkspaceScroll(event));
|
||||
+ this._thumbnailsBox.connect('scroll-event',
|
||||
+ (a, event) => Main.wm.handleWorkspaceScroll(event));
|
||||
|
||||
this._inTopBar = false;
|
||||
this.connect('notify::realized', () => {
|
||||
@@ -445,19 +447,4 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
metaWorkspace.activate(global.get_current_time());
|
||||
}
|
||||
}
|
||||
-
|
||||
- _onScrollEvent(actor, event) {
|
||||
- let direction = event.get_scroll_direction();
|
||||
- let diff = 0;
|
||||
- if (direction === Clutter.ScrollDirection.DOWN)
|
||||
- diff = 1;
|
||||
- else if (direction === Clutter.ScrollDirection.UP)
|
||||
- diff = -1;
|
||||
- else
|
||||
- return;
|
||||
-
|
||||
-
|
||||
- const newIndex = this._currentWorkspace + diff;
|
||||
- this._activate(newIndex);
|
||||
- }
|
||||
}
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,99 +0,0 @@
|
||||
From 13dce7fcc1013a3cbb3a1e521e123a5d4ede75c5 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Tue, 27 Feb 2024 21:20:45 +0100
|
||||
Subject: [PATCH 21/28] workspace-indicator: Handle active indication in
|
||||
thumbnail
|
||||
|
||||
Meta.Workspace has had an `active` property for a while now, so
|
||||
we can use a property binding instead of tracking the active
|
||||
workspace ourselves.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/316>
|
||||
---
|
||||
.../workspace-indicator/workspaceIndicator.js | 35 ++++++++++++-------
|
||||
1 file changed, 23 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/extensions/workspace-indicator/workspaceIndicator.js b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
index 14dd81d0..bf6511a0 100644
|
||||
--- a/extensions/workspace-indicator/workspaceIndicator.js
|
||||
+++ b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
@@ -111,6 +111,13 @@ class WorkspaceLayout extends Clutter.LayoutManager {
|
||||
}
|
||||
|
||||
class WorkspaceThumbnail extends St.Button {
|
||||
+ static [GObject.properties] = {
|
||||
+ 'active': GObject.ParamSpec.boolean(
|
||||
+ 'active', '', '',
|
||||
+ GObject.ParamFlags.READWRITE,
|
||||
+ false),
|
||||
+ };
|
||||
+
|
||||
static {
|
||||
GObject.registerClass(this);
|
||||
}
|
||||
@@ -143,6 +150,10 @@ class WorkspaceThumbnail extends St.Button {
|
||||
let workspaceManager = global.workspace_manager;
|
||||
this._workspace = workspaceManager.get_workspace_by_index(index);
|
||||
|
||||
+ this._workspace.bind_property('active',
|
||||
+ this, 'active',
|
||||
+ GObject.BindingFlags.SYNC_CREATE);
|
||||
+
|
||||
this._workspace.connectObject(
|
||||
'window-added', (ws, window) => this._addWindow(window),
|
||||
'window-removed', (ws, window) => this._removeWindow(window),
|
||||
@@ -155,6 +166,18 @@ class WorkspaceThumbnail extends St.Button {
|
||||
this._onRestacked();
|
||||
}
|
||||
|
||||
+ get active() {
|
||||
+ return this.has_style_class_name('active');
|
||||
+ }
|
||||
+
|
||||
+ set active(active) {
|
||||
+ if (active)
|
||||
+ this.add_style_class_name('active');
|
||||
+ else
|
||||
+ this.remove_style_class_name('active');
|
||||
+ this.notify('active');
|
||||
+ }
|
||||
+
|
||||
acceptDrop(source) {
|
||||
if (!source.metaWindow)
|
||||
return false;
|
||||
@@ -360,7 +383,6 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
this._currentWorkspace = global.workspace_manager.get_active_workspace_index();
|
||||
|
||||
this._updateMenuOrnament();
|
||||
- this._updateActiveThumbnail();
|
||||
|
||||
this._statusLabel.set_text(this._getStatusText());
|
||||
}
|
||||
@@ -379,16 +401,6 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
}
|
||||
}
|
||||
|
||||
- _updateActiveThumbnail() {
|
||||
- let thumbs = this._thumbnailsBox.get_children();
|
||||
- for (let i = 0; i < thumbs.length; i++) {
|
||||
- if (i === this._currentWorkspace)
|
||||
- thumbs[i].add_style_class_name('active');
|
||||
- else
|
||||
- thumbs[i].remove_style_class_name('active');
|
||||
- }
|
||||
- }
|
||||
-
|
||||
_getStatusText() {
|
||||
const {nWorkspaces} = global.workspace_manager;
|
||||
const current = this._currentWorkspace + 1;
|
||||
@@ -436,7 +448,6 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
let thumb = new WorkspaceThumbnail(i);
|
||||
this._thumbnailsBox.add_child(thumb);
|
||||
}
|
||||
- this._updateActiveThumbnail();
|
||||
}
|
||||
|
||||
_activate(index) {
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,150 +0,0 @@
|
||||
From 6b508c92c4996771cf79eb4d81e5d285b598fe96 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Tue, 20 Feb 2024 17:27:57 +0100
|
||||
Subject: [PATCH 22/28] workspace-indicator: Split out WorkspacePreviews
|
||||
|
||||
The previews will become a bit more complex soon, so spit them out
|
||||
into a dedicated class.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/316>
|
||||
---
|
||||
.../workspace-indicator/workspaceIndicator.js | 72 ++++++++++++-------
|
||||
1 file changed, 47 insertions(+), 25 deletions(-)
|
||||
|
||||
diff --git a/extensions/workspace-indicator/workspaceIndicator.js b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
index bf6511a0..73ebca6f 100644
|
||||
--- a/extensions/workspace-indicator/workspaceIndicator.js
|
||||
+++ b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
@@ -274,6 +274,49 @@ class WorkspaceThumbnail extends St.Button {
|
||||
}
|
||||
}
|
||||
|
||||
+class WorkspacePreviews extends Clutter.Actor {
|
||||
+ static {
|
||||
+ GObject.registerClass(this);
|
||||
+ }
|
||||
+
|
||||
+ constructor(params) {
|
||||
+ super({
|
||||
+ ...params,
|
||||
+ layout_manager: new Clutter.BinLayout(),
|
||||
+ reactive: true,
|
||||
+ y_expand: true,
|
||||
+ });
|
||||
+
|
||||
+ this.connect('scroll-event',
|
||||
+ (a, event) => Main.wm.handleWorkspaceScroll(event));
|
||||
+
|
||||
+ const {workspaceManager} = global;
|
||||
+
|
||||
+ workspaceManager.connectObject(
|
||||
+ 'notify::n-workspaces', () => this._updateThumbnails(), GObject.ConnectFlags.AFTER,
|
||||
+ this);
|
||||
+
|
||||
+ this._thumbnailsBox = new St.BoxLayout({
|
||||
+ style_class: 'workspaces-box',
|
||||
+ y_expand: true,
|
||||
+ });
|
||||
+ this.add_child(this._thumbnailsBox);
|
||||
+
|
||||
+ this._updateThumbnails();
|
||||
+ }
|
||||
+
|
||||
+ _updateThumbnails() {
|
||||
+ const {nWorkspaces} = global.workspace_manager;
|
||||
+
|
||||
+ this._thumbnailsBox.destroy_all_children();
|
||||
+
|
||||
+ for (let i = 0; i < nWorkspaces; i++) {
|
||||
+ const thumb = new WorkspaceThumbnail(i);
|
||||
+ this._thumbnailsBox.add_child(thumb);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
static {
|
||||
GObject.registerClass(this);
|
||||
@@ -304,16 +347,10 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
y_align: Clutter.ActorAlign.CENTER,
|
||||
text: this._getStatusText(),
|
||||
});
|
||||
-
|
||||
container.add_child(this._statusLabel);
|
||||
|
||||
- this._thumbnailsBox = new St.BoxLayout({
|
||||
- style_class: 'workspaces-box',
|
||||
- y_expand: true,
|
||||
- reactive: true,
|
||||
- });
|
||||
-
|
||||
- container.add_child(this._thumbnailsBox);
|
||||
+ this._thumbnails = new WorkspacePreviews();
|
||||
+ container.add_child(this._thumbnails);
|
||||
|
||||
this._workspacesItems = [];
|
||||
|
||||
@@ -325,8 +362,6 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
|
||||
this.connect('scroll-event',
|
||||
(a, event) => Main.wm.handleWorkspaceScroll(event));
|
||||
- this._thumbnailsBox.connect('scroll-event',
|
||||
- (a, event) => Main.wm.handleWorkspaceScroll(event));
|
||||
|
||||
this._inTopBar = false;
|
||||
this.connect('notify::realized', () => {
|
||||
@@ -338,7 +373,6 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
});
|
||||
|
||||
this._updateMenu();
|
||||
- this._updateThumbnails();
|
||||
this._updateThumbnailVisibility();
|
||||
|
||||
const desktopSettings =
|
||||
@@ -363,7 +397,7 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
this.reactive = useMenu;
|
||||
|
||||
this._statusLabel.visible = useMenu;
|
||||
- this._thumbnailsBox.visible = !useMenu;
|
||||
+ this._thumbnails.visible = !useMenu;
|
||||
|
||||
this._updateTopBarRedirect();
|
||||
}
|
||||
@@ -374,7 +408,7 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
|
||||
// Disable offscreen-redirect when showing the workspace switcher
|
||||
// so that clip-to-allocation works
|
||||
- Main.panel.set_offscreen_redirect(this._thumbnailsBox.visible
|
||||
+ Main.panel.set_offscreen_redirect(this._thumbnails.visible
|
||||
? Clutter.OffscreenRedirect.ALWAYS
|
||||
: Clutter.OffscreenRedirect.AUTOMATIC_FOR_OPACITY);
|
||||
}
|
||||
@@ -389,7 +423,6 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
|
||||
_nWorkspacesChanged() {
|
||||
this._updateMenu();
|
||||
- this._updateThumbnails();
|
||||
this._updateThumbnailVisibility();
|
||||
}
|
||||
|
||||
@@ -439,17 +472,6 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
this._statusLabel.set_text(this._getStatusText());
|
||||
}
|
||||
|
||||
- _updateThumbnails() {
|
||||
- let workspaceManager = global.workspace_manager;
|
||||
-
|
||||
- this._thumbnailsBox.destroy_all_children();
|
||||
-
|
||||
- for (let i = 0; i < workspaceManager.n_workspaces; i++) {
|
||||
- let thumb = new WorkspaceThumbnail(i);
|
||||
- this._thumbnailsBox.add_child(thumb);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
_activate(index) {
|
||||
let workspaceManager = global.workspace_manager;
|
||||
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,133 +0,0 @@
|
||||
From 8d3d9ef8d8688999d959f1062a62e9f3b7f489fe Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Mon, 19 Feb 2024 14:42:04 +0100
|
||||
Subject: [PATCH 23/28] workspace-indicator: Handle preview overflow
|
||||
|
||||
We currently avoid previews from overflowing in most setups by
|
||||
artificially limiting them to a maximum of six workspaces.
|
||||
|
||||
Add some proper handling to also cover cases where space is more
|
||||
limited, and to allow removing the restriction in the future.
|
||||
|
||||
For that, wrap the previews in an auto-scrolling scroll view
|
||||
and add overflow indicators on each side.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/316>
|
||||
---
|
||||
.../workspace-indicator/stylesheet-dark.css | 4 ++
|
||||
.../workspace-indicator/workspaceIndicator.js | 64 ++++++++++++++++++-
|
||||
2 files changed, 67 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/extensions/workspace-indicator/stylesheet-dark.css b/extensions/workspace-indicator/stylesheet-dark.css
|
||||
index 3e2ba67f..22d13370 100644
|
||||
--- a/extensions/workspace-indicator/stylesheet-dark.css
|
||||
+++ b/extensions/workspace-indicator/stylesheet-dark.css
|
||||
@@ -9,6 +9,10 @@
|
||||
padding: 0 8px;
|
||||
}
|
||||
|
||||
+.workspace-indicator .workspaces-view.hfade {
|
||||
+ -st-hfade-offset: 20px;
|
||||
+}
|
||||
+
|
||||
.workspace-indicator .workspaces-box {
|
||||
padding: 5px;
|
||||
spacing: 3px;
|
||||
diff --git a/extensions/workspace-indicator/workspaceIndicator.js b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
index 73ebca6f..314b9f45 100644
|
||||
--- a/extensions/workspace-indicator/workspaceIndicator.js
|
||||
+++ b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
@@ -20,6 +20,8 @@ import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';
|
||||
const TOOLTIP_OFFSET = 6;
|
||||
const TOOLTIP_ANIMATION_TIME = 150;
|
||||
|
||||
+const SCROLL_TIME = 100;
|
||||
+
|
||||
const MAX_THUMBNAILS = 6;
|
||||
|
||||
let baseStyleClassName = '';
|
||||
@@ -294,13 +296,29 @@ class WorkspacePreviews extends Clutter.Actor {
|
||||
|
||||
workspaceManager.connectObject(
|
||||
'notify::n-workspaces', () => this._updateThumbnails(), GObject.ConnectFlags.AFTER,
|
||||
+ 'workspace-switched', () => this._updateScrollPosition(),
|
||||
this);
|
||||
|
||||
+ this.connect('notify::mapped', () => {
|
||||
+ if (this.mapped)
|
||||
+ this._updateScrollPosition();
|
||||
+ });
|
||||
+
|
||||
this._thumbnailsBox = new St.BoxLayout({
|
||||
style_class: 'workspaces-box',
|
||||
y_expand: true,
|
||||
});
|
||||
- this.add_child(this._thumbnailsBox);
|
||||
+
|
||||
+ this._scrollView = new St.ScrollView({
|
||||
+ style_class: 'workspaces-view hfade',
|
||||
+ enable_mouse_scrolling: false,
|
||||
+ hscrollbar_policy: St.PolicyType.EXTERNAL,
|
||||
+ vscrollbar_policy: St.PolicyType.NEVER,
|
||||
+ y_expand: true,
|
||||
+ child: this._thumbnailsBox,
|
||||
+ });
|
||||
+
|
||||
+ this.add_child(this._scrollView);
|
||||
|
||||
this._updateThumbnails();
|
||||
}
|
||||
@@ -314,6 +332,50 @@ class WorkspacePreviews extends Clutter.Actor {
|
||||
const thumb = new WorkspaceThumbnail(i);
|
||||
this._thumbnailsBox.add_child(thumb);
|
||||
}
|
||||
+
|
||||
+ if (this.mapped)
|
||||
+ this._updateScrollPosition();
|
||||
+ }
|
||||
+
|
||||
+ _updateScrollPosition() {
|
||||
+ const adjustment = this._scrollView.hadjustment;
|
||||
+ const {upper, pageSize} = adjustment;
|
||||
+ let {value} = adjustment;
|
||||
+
|
||||
+ const activeWorkspace =
|
||||
+ [...this._thumbnailsBox].find(a => a.active);
|
||||
+
|
||||
+ if (!activeWorkspace)
|
||||
+ return;
|
||||
+
|
||||
+ let offset = 0;
|
||||
+ const hfade = this._scrollView.get_effect('fade');
|
||||
+ if (hfade)
|
||||
+ offset = hfade.fade_margins.left;
|
||||
+
|
||||
+ let {x1, x2} = activeWorkspace.get_allocation_box();
|
||||
+ let parent = activeWorkspace.get_parent();
|
||||
+ while (parent !== this._scrollView) {
|
||||
+ if (!parent)
|
||||
+ throw new Error('actor not in scroll view');
|
||||
+
|
||||
+ const box = parent.get_allocation_box();
|
||||
+ x1 += box.x1;
|
||||
+ x2 += box.x1;
|
||||
+ parent = parent.get_parent();
|
||||
+ }
|
||||
+
|
||||
+ if (x1 < value + offset)
|
||||
+ value = Math.max(0, x1 - offset);
|
||||
+ else if (x2 > value + pageSize - offset)
|
||||
+ value = Math.min(upper, x2 + offset - pageSize);
|
||||
+ else
|
||||
+ return;
|
||||
+
|
||||
+ adjustment.ease(value, {
|
||||
+ mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
||||
+ duration: SCROLL_TIME,
|
||||
+ });
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,157 +0,0 @@
|
||||
From 3affa2e422de26862b4e473cfeeb89aea638df66 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Sun, 3 Mar 2024 15:05:23 +0100
|
||||
Subject: [PATCH 24/28] workspace-indicator: Support labels in previews
|
||||
|
||||
The space in the top bar is too limited to include the workspace
|
||||
names. However we'll soon replace the textual menu with a preview
|
||||
popover. We can use bigger previews there, so we can include the
|
||||
names to not lose functionality with regards to the current menu.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/316>
|
||||
---
|
||||
.../workspace-indicator/workspaceIndicator.js | 56 +++++++++++++++++--
|
||||
1 file changed, 50 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/extensions/workspace-indicator/workspaceIndicator.js b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
index 314b9f45..e6aa68bf 100644
|
||||
--- a/extensions/workspace-indicator/workspaceIndicator.js
|
||||
+++ b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
@@ -118,6 +118,10 @@ class WorkspaceThumbnail extends St.Button {
|
||||
'active', '', '',
|
||||
GObject.ParamFlags.READWRITE,
|
||||
false),
|
||||
+ 'show-label': GObject.ParamSpec.boolean(
|
||||
+ 'show-label', '', '',
|
||||
+ GObject.ParamFlags.READWRITE,
|
||||
+ false),
|
||||
};
|
||||
|
||||
static {
|
||||
@@ -125,7 +129,16 @@ class WorkspaceThumbnail extends St.Button {
|
||||
}
|
||||
|
||||
constructor(index) {
|
||||
- super({
|
||||
+ super();
|
||||
+
|
||||
+ const box = new St.BoxLayout({
|
||||
+ style_class: 'workspace-box',
|
||||
+ y_expand: true,
|
||||
+ vertical: true,
|
||||
+ });
|
||||
+ this.set_child(box);
|
||||
+
|
||||
+ this._preview = new St.Bin({
|
||||
style_class: 'workspace',
|
||||
child: new Clutter.Actor({
|
||||
layout_manager: new WorkspaceLayout(),
|
||||
@@ -133,7 +146,15 @@ class WorkspaceThumbnail extends St.Button {
|
||||
x_expand: true,
|
||||
y_expand: true,
|
||||
}),
|
||||
+ y_expand: true,
|
||||
+ });
|
||||
+ box.add_child(this._preview);
|
||||
+
|
||||
+ this._label = new St.Label({
|
||||
+ x_align: Clutter.ActorAlign.CENTER,
|
||||
+ text: Meta.prefs_get_workspace_name(index),
|
||||
});
|
||||
+ box.add_child(this._label);
|
||||
|
||||
this._tooltip = new St.Label({
|
||||
style_class: 'dash-label',
|
||||
@@ -141,9 +162,19 @@ class WorkspaceThumbnail extends St.Button {
|
||||
});
|
||||
Main.uiGroup.add_child(this._tooltip);
|
||||
|
||||
+ this.bind_property('show-label',
|
||||
+ this._label, 'visible',
|
||||
+ GObject.BindingFlags.SYNC_CREATE);
|
||||
+
|
||||
this.connect('destroy', this._onDestroy.bind(this));
|
||||
this.connect('notify::hover', this._syncTooltip.bind(this));
|
||||
|
||||
+ const desktopSettings =
|
||||
+ new Gio.Settings({schema_id: 'org.gnome.desktop.wm.preferences'});
|
||||
+ desktopSettings.connectObject('changed::workspace-names', () => {
|
||||
+ this._label.text = Meta.prefs_get_workspace_name(index);
|
||||
+ }, this);
|
||||
+
|
||||
this._index = index;
|
||||
this._delegate = this; // needed for DND
|
||||
|
||||
@@ -169,14 +200,14 @@ class WorkspaceThumbnail extends St.Button {
|
||||
}
|
||||
|
||||
get active() {
|
||||
- return this.has_style_class_name('active');
|
||||
+ return this._preview.has_style_class_name('active');
|
||||
}
|
||||
|
||||
set active(active) {
|
||||
if (active)
|
||||
- this.add_style_class_name('active');
|
||||
+ this._preview.add_style_class_name('active');
|
||||
else
|
||||
- this.remove_style_class_name('active');
|
||||
+ this._preview.remove_style_class_name('active');
|
||||
this.notify('active');
|
||||
}
|
||||
|
||||
@@ -202,7 +233,7 @@ class WorkspaceThumbnail extends St.Button {
|
||||
let preview = new WindowPreview(window);
|
||||
preview.connect('clicked', (a, btn) => this.emit('clicked', btn));
|
||||
this._windowPreviews.set(window, preview);
|
||||
- this.child.add_child(preview);
|
||||
+ this._preview.child.add_child(preview);
|
||||
}
|
||||
|
||||
_removeWindow(window) {
|
||||
@@ -222,7 +253,7 @@ class WorkspaceThumbnail extends St.Button {
|
||||
if (!preview)
|
||||
continue;
|
||||
|
||||
- this.child.set_child_above_sibling(preview, lastPreview);
|
||||
+ this._preview.child.set_child_above_sibling(preview, lastPreview);
|
||||
lastPreview = preview;
|
||||
}
|
||||
}
|
||||
@@ -241,6 +272,9 @@ class WorkspaceThumbnail extends St.Button {
|
||||
}
|
||||
|
||||
_syncTooltip() {
|
||||
+ if (this.showLabel)
|
||||
+ return;
|
||||
+
|
||||
if (this.hover) {
|
||||
this._tooltip.set({
|
||||
text: Meta.prefs_get_workspace_name(this._index),
|
||||
@@ -277,6 +311,13 @@ class WorkspaceThumbnail extends St.Button {
|
||||
}
|
||||
|
||||
class WorkspacePreviews extends Clutter.Actor {
|
||||
+ static [GObject.properties] = {
|
||||
+ 'show-labels': GObject.ParamSpec.boolean(
|
||||
+ 'show-labels', '', '',
|
||||
+ GObject.ParamFlags.READWRITE | GObject.ParamFlags.CONSTRUCT_ONLY,
|
||||
+ false),
|
||||
+ };
|
||||
+
|
||||
static {
|
||||
GObject.registerClass(this);
|
||||
}
|
||||
@@ -330,6 +371,9 @@ class WorkspacePreviews extends Clutter.Actor {
|
||||
|
||||
for (let i = 0; i < nWorkspaces; i++) {
|
||||
const thumb = new WorkspaceThumbnail(i);
|
||||
+ this.bind_property('show-labels',
|
||||
+ thumb, 'show-label',
|
||||
+ GObject.BindingFlags.SYNC_CREATE);
|
||||
this._thumbnailsBox.add_child(thumb);
|
||||
}
|
||||
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,44 +0,0 @@
|
||||
From 1805cceb598d1ed6fd2039453242b28e44e079e0 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Tue, 20 Feb 2024 21:43:55 +0100
|
||||
Subject: [PATCH 25/28] workspace-indicator: Stop handling vertical layouts
|
||||
|
||||
Both the regular session and GNOME classic use a horizontal layout
|
||||
nowadays, so it doesn't seem worth to specifically handle vertical
|
||||
layouts anymore.
|
||||
|
||||
The extension will still work when the layout is changed (by some
|
||||
other extension), there will simply be a mismatch between horizontal
|
||||
previews and the actual layout.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/316>
|
||||
---
|
||||
extensions/workspace-indicator/workspaceIndicator.js | 5 +----
|
||||
1 file changed, 1 insertion(+), 4 deletions(-)
|
||||
|
||||
diff --git a/extensions/workspace-indicator/workspaceIndicator.js b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
index e6aa68bf..087d2d89 100644
|
||||
--- a/extensions/workspace-indicator/workspaceIndicator.js
|
||||
+++ b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
@@ -463,7 +463,6 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
workspaceManager.connectObject(
|
||||
'notify::n-workspaces', this._nWorkspacesChanged.bind(this), GObject.ConnectFlags.AFTER,
|
||||
'workspace-switched', this._onWorkspaceSwitched.bind(this), GObject.ConnectFlags.AFTER,
|
||||
- 'notify::layout-rows', this._updateThumbnailVisibility.bind(this),
|
||||
this);
|
||||
|
||||
this.connect('scroll-event',
|
||||
@@ -497,9 +496,7 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
|
||||
_updateThumbnailVisibility() {
|
||||
const {workspaceManager} = global;
|
||||
- const vertical = workspaceManager.layout_rows === -1;
|
||||
- const useMenu =
|
||||
- vertical || workspaceManager.n_workspaces > MAX_THUMBNAILS;
|
||||
+ const useMenu = workspaceManager.n_workspaces > MAX_THUMBNAILS;
|
||||
this.reactive = useMenu;
|
||||
|
||||
this._statusLabel.visible = useMenu;
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,190 +0,0 @@
|
||||
From f72c6ed223c3d348bdf32c25b54b6c44a826eb7d Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Sun, 3 Mar 2024 15:05:23 +0100
|
||||
Subject: [PATCH 26/28] workspace-indicator: Also show previews in menu
|
||||
|
||||
Since the regular session also switched to horizontal workspaces,
|
||||
using a vertical menu has been a bit awkward.
|
||||
|
||||
Now that our previews have become more flexible, we can use them
|
||||
in the collapsed state as well as when embedded into the top bar.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/316>
|
||||
---
|
||||
.../workspace-indicator/stylesheet-dark.css | 25 ++++++-
|
||||
.../workspace-indicator/workspaceIndicator.js | 74 +++----------------
|
||||
2 files changed, 36 insertions(+), 63 deletions(-)
|
||||
|
||||
diff --git a/extensions/workspace-indicator/stylesheet-dark.css b/extensions/workspace-indicator/stylesheet-dark.css
|
||||
index 22d13370..b4a716b8 100644
|
||||
--- a/extensions/workspace-indicator/stylesheet-dark.css
|
||||
+++ b/extensions/workspace-indicator/stylesheet-dark.css
|
||||
@@ -13,18 +13,41 @@
|
||||
-st-hfade-offset: 20px;
|
||||
}
|
||||
|
||||
+.workspace-indicator-menu .workspaces-view {
|
||||
+ max-width: 480px;
|
||||
+}
|
||||
+
|
||||
.workspace-indicator .workspaces-box {
|
||||
padding: 5px;
|
||||
spacing: 3px;
|
||||
}
|
||||
|
||||
+.workspace-indicator-menu .workspaces-box {
|
||||
+ padding: 5px;
|
||||
+ spacing: 6px;
|
||||
+}
|
||||
+
|
||||
+.workspace-indicator-menu .workspace-box {
|
||||
+ spacing: 6px;
|
||||
+}
|
||||
+
|
||||
+.workspace-indicator-menu .workspace,
|
||||
.workspace-indicator .workspace {
|
||||
- width: 52px;
|
||||
border: 2px solid transparent;
|
||||
border-radius: 4px;
|
||||
background-color: #3f3f3f;
|
||||
}
|
||||
|
||||
+.workspace-indicator .workspace {
|
||||
+ width: 52px;
|
||||
+}
|
||||
+
|
||||
+.workspace-indicator-menu .workspace {
|
||||
+ height: 80px;
|
||||
+ width: 160px;
|
||||
+}
|
||||
+
|
||||
+.workspace-indicator-menu .workspace.active,
|
||||
.workspace-indicator .workspace.active {
|
||||
border-color: #9f9f9f;
|
||||
}
|
||||
diff --git a/extensions/workspace-indicator/workspaceIndicator.js b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
index 087d2d89..a4d3bbee 100644
|
||||
--- a/extensions/workspace-indicator/workspaceIndicator.js
|
||||
+++ b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
@@ -429,7 +429,7 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
}
|
||||
|
||||
constructor(params = {}) {
|
||||
- super(0.5, _('Workspace Indicator'));
|
||||
+ super(0.5, _('Workspace Indicator'), true);
|
||||
|
||||
const {
|
||||
baseStyleClass = 'workspace-indicator',
|
||||
@@ -461,7 +461,7 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
this._workspacesItems = [];
|
||||
|
||||
workspaceManager.connectObject(
|
||||
- 'notify::n-workspaces', this._nWorkspacesChanged.bind(this), GObject.ConnectFlags.AFTER,
|
||||
+ 'notify::n-workspaces', this._updateThumbnailVisibility.bind(this), GObject.ConnectFlags.AFTER,
|
||||
'workspace-switched', this._onWorkspaceSwitched.bind(this), GObject.ConnectFlags.AFTER,
|
||||
this);
|
||||
|
||||
@@ -477,13 +477,7 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
this._updateTopBarRedirect();
|
||||
});
|
||||
|
||||
- this._updateMenu();
|
||||
this._updateThumbnailVisibility();
|
||||
-
|
||||
- const desktopSettings =
|
||||
- new Gio.Settings({schema_id: 'org.gnome.desktop.wm.preferences'});
|
||||
- desktopSettings.connectObject('changed::workspace-names',
|
||||
- () => this._updateMenuLabels(), this);
|
||||
}
|
||||
|
||||
_onDestroy() {
|
||||
@@ -502,6 +496,10 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
this._statusLabel.visible = useMenu;
|
||||
this._thumbnails.visible = !useMenu;
|
||||
|
||||
+ this.setMenu(useMenu
|
||||
+ ? this._createPreviewMenu()
|
||||
+ : null);
|
||||
+
|
||||
this._updateTopBarRedirect();
|
||||
}
|
||||
|
||||
@@ -518,69 +516,21 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
|
||||
_onWorkspaceSwitched() {
|
||||
this._currentWorkspace = global.workspace_manager.get_active_workspace_index();
|
||||
-
|
||||
- this._updateMenuOrnament();
|
||||
-
|
||||
this._statusLabel.set_text(this._getStatusText());
|
||||
}
|
||||
|
||||
- _nWorkspacesChanged() {
|
||||
- this._updateMenu();
|
||||
- this._updateThumbnailVisibility();
|
||||
- }
|
||||
-
|
||||
- _updateMenuOrnament() {
|
||||
- for (let i = 0; i < this._workspacesItems.length; i++) {
|
||||
- this._workspacesItems[i].setOrnament(i === this._currentWorkspace
|
||||
- ? PopupMenu.Ornament.DOT
|
||||
- : PopupMenu.Ornament.NO_DOT);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
_getStatusText() {
|
||||
const {nWorkspaces} = global.workspace_manager;
|
||||
const current = this._currentWorkspace + 1;
|
||||
return `${current} / ${nWorkspaces}`;
|
||||
}
|
||||
|
||||
- _updateMenuLabels() {
|
||||
- for (let i = 0; i < this._workspacesItems.length; i++) {
|
||||
- const item = this._workspacesItems[i];
|
||||
- item.label.text = Meta.prefs_get_workspace_name(i);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- _updateMenu() {
|
||||
- let workspaceManager = global.workspace_manager;
|
||||
-
|
||||
- this.menu.removeAll();
|
||||
- this._workspacesItems = [];
|
||||
- this._currentWorkspace = workspaceManager.get_active_workspace_index();
|
||||
+ _createPreviewMenu() {
|
||||
+ const menu = new PopupMenu.PopupMenu(this, 0.5, St.Side.TOP);
|
||||
|
||||
- for (let i = 0; i < workspaceManager.n_workspaces; i++) {
|
||||
- const name = Meta.prefs_get_workspace_name(i);
|
||||
- const item = new PopupMenu.PopupMenuItem(name);
|
||||
-
|
||||
- item.connect('activate',
|
||||
- () => this._activate(i));
|
||||
-
|
||||
- item.setOrnament(i === this._currentWorkspace
|
||||
- ? PopupMenu.Ornament.DOT
|
||||
- : PopupMenu.Ornament.NO_DOT);
|
||||
-
|
||||
- this.menu.addMenuItem(item);
|
||||
- this._workspacesItems[i] = item;
|
||||
- }
|
||||
-
|
||||
- this._statusLabel.set_text(this._getStatusText());
|
||||
- }
|
||||
-
|
||||
- _activate(index) {
|
||||
- let workspaceManager = global.workspace_manager;
|
||||
-
|
||||
- if (index >= 0 && index < workspaceManager.n_workspaces) {
|
||||
- let metaWorkspace = workspaceManager.get_workspace_by_index(index);
|
||||
- metaWorkspace.activate(global.get_current_time());
|
||||
- }
|
||||
+ const previews = new WorkspacePreviews({show_labels: true});
|
||||
+ menu.box.add_child(previews);
|
||||
+ menu.actor.add_style_class_name(`${baseStyleClassName}-menu`);
|
||||
+ return menu;
|
||||
}
|
||||
}
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,215 +0,0 @@
|
||||
From 8d2b24290204be98423b3a952939895133bdc036 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Tue, 20 Feb 2024 22:00:57 +0100
|
||||
Subject: [PATCH 27/28] workspace-indicator: Make previews configurable
|
||||
|
||||
Now that previews scroll when there are too many workspaces,
|
||||
there is no longer a reason for the 6-workspace limit.
|
||||
|
||||
However some users do prefer the menu, so rather than drop it,
|
||||
turn it into a proper preference.
|
||||
|
||||
Closes
|
||||
https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/issues/336
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/316>
|
||||
---
|
||||
extensions/window-list/extension.js | 1 +
|
||||
...e.shell.extensions.window-list.gschema.xml | 4 +++
|
||||
extensions/workspace-indicator/extension.js | 4 ++-
|
||||
extensions/workspace-indicator/meson.build | 1 +
|
||||
extensions/workspace-indicator/prefs.js | 26 +++++++++++++++++--
|
||||
...extensions.workspace-indicator.gschema.xml | 15 +++++++++++
|
||||
.../workspace-indicator/workspaceIndicator.js | 11 ++++----
|
||||
po/POTFILES.in | 1 +
|
||||
8 files changed, 55 insertions(+), 8 deletions(-)
|
||||
create mode 100644 extensions/workspace-indicator/schemas/org.gnome.shell.extensions.workspace-indicator.gschema.xml
|
||||
|
||||
diff --git a/extensions/window-list/extension.js b/extensions/window-list/extension.js
|
||||
index 3950c535..227625e5 100644
|
||||
--- a/extensions/window-list/extension.js
|
||||
+++ b/extensions/window-list/extension.js
|
||||
@@ -769,6 +769,7 @@ class WindowList extends St.Widget {
|
||||
|
||||
this._workspaceIndicator = new BottomWorkspaceIndicator({
|
||||
baseStyleClass: 'window-list-workspace-indicator',
|
||||
+ settings,
|
||||
});
|
||||
indicatorsBox.add_child(this._workspaceIndicator.container);
|
||||
|
||||
diff --git a/extensions/window-list/org.gnome.shell.extensions.window-list.gschema.xml b/extensions/window-list/org.gnome.shell.extensions.window-list.gschema.xml
|
||||
index 2ed680a5..46ff25cb 100644
|
||||
--- a/extensions/window-list/org.gnome.shell.extensions.window-list.gschema.xml
|
||||
+++ b/extensions/window-list/org.gnome.shell.extensions.window-list.gschema.xml
|
||||
@@ -36,5 +36,9 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
||||
only on the primary one.
|
||||
</description>
|
||||
</key>
|
||||
+ <key name="embed-previews" type="b">
|
||||
+ <default>true</default>
|
||||
+ <summary>Show workspace previews in window list</summary>
|
||||
+ </key>
|
||||
</schema>
|
||||
</schemalist>
|
||||
diff --git a/extensions/workspace-indicator/extension.js b/extensions/workspace-indicator/extension.js
|
||||
index b383c919..ef24a750 100644
|
||||
--- a/extensions/workspace-indicator/extension.js
|
||||
+++ b/extensions/workspace-indicator/extension.js
|
||||
@@ -12,7 +12,9 @@ import {WorkspaceIndicator} from './workspaceIndicator.js';
|
||||
|
||||
export default class WorkspaceIndicatorExtension extends Extension {
|
||||
enable() {
|
||||
- this._indicator = new WorkspaceIndicator();
|
||||
+ this._indicator = new WorkspaceIndicator({
|
||||
+ settings: this.getSettings(),
|
||||
+ });
|
||||
Main.panel.addToStatusArea('workspace-indicator', this._indicator);
|
||||
}
|
||||
|
||||
diff --git a/extensions/workspace-indicator/meson.build b/extensions/workspace-indicator/meson.build
|
||||
index dada5408..9388085c 100644
|
||||
--- a/extensions/workspace-indicator/meson.build
|
||||
+++ b/extensions/workspace-indicator/meson.build
|
||||
@@ -11,5 +11,6 @@ extension_data += files(
|
||||
'stylesheet-dark.css',
|
||||
'stylesheet-light.css',
|
||||
)
|
||||
+extension_schemas += files('schemas/' + metadata_conf.get('gschemaname') + '.gschema.xml')
|
||||
|
||||
extension_sources += files('prefs.js', 'workspaceIndicator.js')
|
||||
diff --git a/extensions/workspace-indicator/prefs.js b/extensions/workspace-indicator/prefs.js
|
||||
index ea0546bf..b828ab8f 100644
|
||||
--- a/extensions/workspace-indicator/prefs.js
|
||||
+++ b/extensions/workspace-indicator/prefs.js
|
||||
@@ -18,6 +18,25 @@ const N_ = e => e;
|
||||
const WORKSPACE_SCHEMA = 'org.gnome.desktop.wm.preferences';
|
||||
const WORKSPACE_KEY = 'workspace-names';
|
||||
|
||||
+class GeneralGroup extends Adw.PreferencesGroup {
|
||||
+ static {
|
||||
+ GObject.registerClass(this);
|
||||
+ }
|
||||
+
|
||||
+ constructor(settings) {
|
||||
+ super();
|
||||
+
|
||||
+ const row = new Adw.SwitchRow({
|
||||
+ title: _('Show Previews In Top Bar'),
|
||||
+ });
|
||||
+ this.add(row);
|
||||
+
|
||||
+ settings.bind('embed-previews',
|
||||
+ row, 'active',
|
||||
+ Gio.SettingsBindFlags.DEFAULT);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
class NewItem extends GObject.Object {}
|
||||
GObject.registerClass(NewItem);
|
||||
|
||||
@@ -119,7 +138,7 @@ class WorkspacesList extends GObject.Object {
|
||||
}
|
||||
}
|
||||
|
||||
-class WorkspaceSettingsWidget extends Adw.PreferencesGroup {
|
||||
+class WorkspacesGroup extends Adw.PreferencesGroup {
|
||||
static {
|
||||
GObject.registerClass(this);
|
||||
|
||||
@@ -265,6 +284,9 @@ class NewWorkspaceRow extends Adw.PreferencesRow {
|
||||
|
||||
export default class WorkspaceIndicatorPrefs extends ExtensionPreferences {
|
||||
getPreferencesWidget() {
|
||||
- return new WorkspaceSettingsWidget();
|
||||
+ const page = new Adw.PreferencesPage();
|
||||
+ page.add(new GeneralGroup(this.getSettings()));
|
||||
+ page.add(new WorkspacesGroup());
|
||||
+ return page;
|
||||
}
|
||||
}
|
||||
diff --git a/extensions/workspace-indicator/schemas/org.gnome.shell.extensions.workspace-indicator.gschema.xml b/extensions/workspace-indicator/schemas/org.gnome.shell.extensions.workspace-indicator.gschema.xml
|
||||
new file mode 100644
|
||||
index 00000000..c7c634ca
|
||||
--- /dev/null
|
||||
+++ b/extensions/workspace-indicator/schemas/org.gnome.shell.extensions.workspace-indicator.gschema.xml
|
||||
@@ -0,0 +1,15 @@
|
||||
+<!--
|
||||
+SPDX-FileCopyrightText: 2024 Florian Müllner <fmuellner@gnome.org>
|
||||
+
|
||||
+SPDX-License-Identifier: GPL-2.0-or-later
|
||||
+-->
|
||||
+
|
||||
+<schemalist gettext-domain="gnome-shell-extensions">
|
||||
+ <schema id="org.gnome.shell.extensions.workspace-indicator"
|
||||
+ path="/org/gnome/shell/extensions/workspace-indicator/">
|
||||
+ <key name="embed-previews" type="b">
|
||||
+ <default>true</default>
|
||||
+ <summary>Show workspace previews in top bar</summary>
|
||||
+ </key>
|
||||
+ </schema>
|
||||
+</schemalist>
|
||||
diff --git a/extensions/workspace-indicator/workspaceIndicator.js b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
index a4d3bbee..20d4caa2 100644
|
||||
--- a/extensions/workspace-indicator/workspaceIndicator.js
|
||||
+++ b/extensions/workspace-indicator/workspaceIndicator.js
|
||||
@@ -22,8 +22,6 @@ const TOOLTIP_ANIMATION_TIME = 150;
|
||||
|
||||
const SCROLL_TIME = 100;
|
||||
|
||||
-const MAX_THUMBNAILS = 6;
|
||||
-
|
||||
let baseStyleClassName = '';
|
||||
|
||||
class WindowPreview extends St.Button {
|
||||
@@ -433,8 +431,11 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
|
||||
const {
|
||||
baseStyleClass = 'workspace-indicator',
|
||||
+ settings,
|
||||
} = params;
|
||||
|
||||
+ this._settings = settings;
|
||||
+
|
||||
baseStyleClassName = baseStyleClass;
|
||||
this.add_style_class_name(baseStyleClassName);
|
||||
|
||||
@@ -461,7 +462,6 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
this._workspacesItems = [];
|
||||
|
||||
workspaceManager.connectObject(
|
||||
- 'notify::n-workspaces', this._updateThumbnailVisibility.bind(this), GObject.ConnectFlags.AFTER,
|
||||
'workspace-switched', this._onWorkspaceSwitched.bind(this), GObject.ConnectFlags.AFTER,
|
||||
this);
|
||||
|
||||
@@ -477,6 +477,8 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
this._updateTopBarRedirect();
|
||||
});
|
||||
|
||||
+ this._settings.connect('changed::embed-previews',
|
||||
+ () => this._updateThumbnailVisibility());
|
||||
this._updateThumbnailVisibility();
|
||||
}
|
||||
|
||||
@@ -489,8 +491,7 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||||
}
|
||||
|
||||
_updateThumbnailVisibility() {
|
||||
- const {workspaceManager} = global;
|
||||
- const useMenu = workspaceManager.n_workspaces > MAX_THUMBNAILS;
|
||||
+ const useMenu = !this._settings.get_boolean('embed-previews');
|
||||
this.reactive = useMenu;
|
||||
|
||||
this._statusLabel.visible = useMenu;
|
||||
diff --git a/po/POTFILES.in b/po/POTFILES.in
|
||||
index 182b2be0..e6e76039 100644
|
||||
--- a/po/POTFILES.in
|
||||
+++ b/po/POTFILES.in
|
||||
@@ -21,4 +21,5 @@ extensions/window-list/prefs.js
|
||||
extensions/window-list/workspaceIndicator.js
|
||||
extensions/windowsNavigator/extension.js
|
||||
extensions/workspace-indicator/prefs.js
|
||||
+extensions/workspace-indicator/schemas/org.gnome.shell.extensions.workspace-indicator.gschema.xml
|
||||
extensions/workspace-indicator/workspaceIndicator.js
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,40 +0,0 @@
|
||||
From 2e7aa8ccd266b66c9641b7e7239e45e7317ff431 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Thu, 21 Mar 2024 17:27:09 +0100
|
||||
Subject: [PATCH 28/28] window-list: Expose workspace preview option
|
||||
|
||||
Now that we have the option, the window-list should expose it
|
||||
in its preference window like the workspace-indicator.
|
||||
|
||||
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/316>
|
||||
---
|
||||
extensions/window-list/prefs.js | 13 +++++++++++++
|
||||
1 file changed, 13 insertions(+)
|
||||
|
||||
diff --git a/extensions/window-list/prefs.js b/extensions/window-list/prefs.js
|
||||
index 6b2d5958..194d1f9d 100644
|
||||
--- a/extensions/window-list/prefs.js
|
||||
+++ b/extensions/window-list/prefs.js
|
||||
@@ -81,6 +81,19 @@ class WindowListPrefsWidget extends Adw.PreferencesPage {
|
||||
});
|
||||
row.add_suffix(toggle);
|
||||
miscGroup.add(row);
|
||||
+
|
||||
+ toggle = new Gtk.Switch({
|
||||
+ action_name: 'window-list.embed-previews',
|
||||
+ valign: Gtk.Align.CENTER,
|
||||
+ });
|
||||
+ this._settings.bind('embed-previews',
|
||||
+ toggle, 'active', Gio.SettingsBindFlags.DEFAULT);
|
||||
+ row = new Adw.ActionRow({
|
||||
+ title: _('Show workspace previews'),
|
||||
+ activatable_widget: toggle,
|
||||
+ });
|
||||
+ row.add_suffix(toggle);
|
||||
+ miscGroup.add(row);
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
2.44.0
|
||||
|
2
sources
2
sources
@ -1 +1 @@
|
||||
SHA512 (gnome-shell-extensions-46.2.tar.xz) = 81a12ff2f13e4b4cbc3ab75920ca6c4a2cdac9df42a1b1a04120fe8ede02b3b3cf3b9d93e6fdec0b4b8db0ce8e355eefdad79a7e4e40c1759f54c06d37edf370
|
||||
SHA512 (gnome-shell-extensions-47.alpha.tar.xz) = a9d464ba6c792708b348d2b7f8b0a8c5ce00eff9b0cb9645d0594989c7ff944a310c3cd3b6fbdaa4eb236770bd7659118c85fca89d56138670ee22c1b64ff41d
|
||||
|
Loading…
Reference in New Issue
Block a user