gnome-shell-extensions/more-ws-previews-0022-workspace-indicator-Split-out-WorkspacePreviews.patch
Florian Müllner e6414d8afc
Re-apply downstream patches
Re-apply rebased and updated version of the RHEL 9 downstream
patches, with some exceptions:

Branding is still TBD, so has been left out for now.

The desktop-icons extension will be replaced by an upstreamed
version of desktop-icons-ng, which is still work-in-progress.

Both dash-to-dock and dash-to-panel will be moved to separate
packages, based on the existing Fedora package.

It was decided to drop the panel-favorites and updates-dialog
extensions.

Resolves: RHEL-34255
2024-05-15 02:56:19 +02:00

151 lines
4.9 KiB
Diff

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