Blame SOURCES/add-workspace-tooltips.patch

204b62
From 1f9f4af38f991b462ee5f872a697d88a9e115499 Mon Sep 17 00:00:00 2001
204b62
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
204b62
Date: Wed, 20 Jan 2021 20:18:39 +0100
204b62
Subject: [PATCH 1/2] workspace-indicator: Add tooltips to workspace thumbnails
204b62
204b62
When showing previews instead of the menu, the workspace names from
204b62
our preferences don't appear anywhere. Some users care strongly about
204b62
those, so expose them as tooltip on hover.
204b62
---
204b62
 extensions/workspace-indicator/extension.js | 40 +++++++++++++++++++++
204b62
 1 file changed, 40 insertions(+)
204b62
204b62
diff --git a/extensions/workspace-indicator/extension.js b/extensions/workspace-indicator/extension.js
204b62
index 69eef88c..b10e37ff 100644
204b62
--- a/extensions/workspace-indicator/extension.js
204b62
+++ b/extensions/workspace-indicator/extension.js
204b62
@@ -8,6 +8,7 @@ const ExtensionUtils = imports.misc.extensionUtils;
204b62
 const Main = imports.ui.main;
204b62
 const PanelMenu = imports.ui.panelMenu;
204b62
 const PopupMenu = imports.ui.popupMenu;
204b62
+const Tweener = imports.ui.tweener;
204b62
 
204b62
 const Gettext = imports.gettext.domain('gnome-shell-extensions');
204b62
 const _ = Gettext.gettext;
204b62
@@ -15,6 +16,9 @@ const _ = Gettext.gettext;
204b62
 const WORKSPACE_SCHEMA = 'org.gnome.desktop.wm.preferences';
204b62
 const WORKSPACE_KEY = 'workspace-names';
204b62
 
204b62
+const TOOLTIP_OFFSET = 6;
204b62
+const TOOLTIP_ANIMATION_TIME = 150;
204b62
+
204b62
 let WindowPreview = GObject.registerClass({
204b62
     GTypeName: 'WorkspaceIndicatorWindowPreview'
204b62
 }, class WindowPreview extends St.Button {
204b62
@@ -117,7 +121,14 @@ let WorkspaceThumbnail = GObject.registerClass({
204b62
             y_fill: true
204b62
         });
204b62
 
204b62
+        this._tooltip = new St.Label({
204b62
+            style_class: 'dash-label',
204b62
+            visible: false,
204b62
+        });
204b62
+        Main.uiGroup.add_child(this._tooltip);
204b62
+
204b62
         this.connect('destroy', this._onDestroy.bind(this));
204b62
+        this.connect('notify::hover', this._syncTooltip.bind(this));
204b62
 
204b62
         this._index = index;
204b62
         this._delegate = this; // needed for DND
204b62
@@ -204,7 +215,36 @@ let WorkspaceThumbnail = GObject.registerClass({
204b62
             ws.activate(global.get_current_time());
204b62
     }
204b62
 
204b62
+    _syncTooltip() {
204b62
+        if (this.hover) {
204b62
+            this._tooltip.text = Meta.prefs_get_workspace_name(this._index);
204b62
+            this._tooltip.opacity = 0;
204b62
+            this._tooltip.show();
204b62
+
204b62
+            const [stageX, stageY] = this.get_transformed_position();
204b62
+            const thumbWidth = this.allocation.get_width();
204b62
+            const thumbHeight = this.allocation.get_height();
204b62
+            const tipWidth = this._tooltip.width;
204b62
+            const xOffset = Math.floor((thumbWidth - tipWidth) / 2);
204b62
+            const monitor = Main.layoutManager.findMonitorForActor(this);
204b62
+            const x = Math.min(
204b62
+                Math.max(stageX + xOffset, monitor.x),
204b62
+                monitor.x + monitor.width - tipWidth);
204b62
+            const y = stageY + thumbHeight + TOOLTIP_OFFSET;
204b62
+            this._tooltip.set_position(x, y);
204b62
+        }
204b62
+
204b62
+        Tweener.addTween(this._tooltip, {
204b62
+            opacity: this.hover ? 255 : 0,
204b62
+            time: TOOLTIP_ANIMATION_TIME * 1000,
204b62
+            transition: 'easeOutQuad',
204b62
+            onComplete: () => (this._tooltip.visible = this.hover),
204b62
+        });
204b62
+    }
204b62
+
204b62
     _onDestroy() {
204b62
+        this._tooltip.destroy();
204b62
+
204b62
         this._workspace.disconnect(this._windowAddedId);
204b62
         this._workspace.disconnect(this._windowRemovedId);
204b62
         global.display.disconnect(this._restackedId);
204b62
-- 
204b62
2.31.1
204b62
204b62
204b62
From 19e19e11214b6b9deae110cd6a4c9232d77c18cb Mon Sep 17 00:00:00 2001
204b62
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
204b62
Date: Wed, 20 Jan 2021 20:29:01 +0100
204b62
Subject: [PATCH 2/2] window-list: Add tooltips to workspace thumbnails
204b62
204b62
When showing previews instead of the menu, the workspace names
204b62
don't appear anywhere. Some users care strongly about those, so
204b62
expose them as tooltip on hover.
204b62
---
204b62
 extensions/window-list/workspaceIndicator.js | 40 ++++++++++++++++++++
204b62
 1 file changed, 40 insertions(+)
204b62
204b62
diff --git a/extensions/window-list/workspaceIndicator.js b/extensions/window-list/workspaceIndicator.js
204b62
index ca476111..33ec9b0e 100644
204b62
--- a/extensions/window-list/workspaceIndicator.js
204b62
+++ b/extensions/window-list/workspaceIndicator.js
204b62
@@ -5,10 +5,14 @@ const DND = imports.ui.dnd;
204b62
 const Main = imports.ui.main;
204b62
 const PanelMenu = imports.ui.panelMenu;
204b62
 const PopupMenu = imports.ui.popupMenu;
204b62
+const Tweener = imports.ui.tweener;
204b62
 
204b62
 const Gettext = imports.gettext.domain('gnome-shell-extensions');
204b62
 const _ = Gettext.gettext;
204b62
 
204b62
+const TOOLTIP_OFFSET = 6;
204b62
+const TOOLTIP_ANIMATION_TIME = 150;
204b62
+
204b62
 let WindowPreview = GObject.registerClass({
204b62
     GTypeName: 'WindowListWindowPreview'
204b62
 }, class WindowPreview extends St.Button {
204b62
@@ -111,7 +115,14 @@ let WorkspaceThumbnail = GObject.registerClass({
204b62
             y_fill: true
204b62
         });
204b62
 
204b62
+        this._tooltip = new St.Label({
204b62
+            style_class: 'dash-label',
204b62
+            visible: false,
204b62
+        });
204b62
+        Main.uiGroup.add_child(this._tooltip);
204b62
+
204b62
         this.connect('destroy', this._onDestroy.bind(this));
204b62
+        this.connect('notify::hover', this._syncTooltip.bind(this));
204b62
 
204b62
         this._index = index;
204b62
         this._delegate = this; // needed for DND
204b62
@@ -198,7 +209,36 @@ let WorkspaceThumbnail = GObject.registerClass({
204b62
             ws.activate(global.get_current_time());
204b62
     }
204b62
 
204b62
+    _syncTooltip() {
204b62
+        if (this.hover) {
204b62
+            this._tooltip.text = Meta.prefs_get_workspace_name(this._index);
204b62
+            this._tooltip.opacity = 0;
204b62
+            this._tooltip.show();
204b62
+
204b62
+            const [stageX, stageY] = this.get_transformed_position();
204b62
+            const thumbWidth = this.allocation.get_width();
204b62
+            const tipWidth = this._tooltip.width;
204b62
+            const tipHeight = this._tooltip.height;
204b62
+            const xOffset = Math.floor((thumbWidth - tipWidth) / 2);
204b62
+            const monitor = Main.layoutManager.findMonitorForActor(this);
204b62
+            const x = Math.min(
204b62
+                Math.max(stageX + xOffset, monitor.x),
204b62
+                monitor.x + monitor.width - tipWidth);
204b62
+            const y = stageY - tipHeight - TOOLTIP_OFFSET;
204b62
+            this._tooltip.set_position(x, y);
204b62
+        }
204b62
+
204b62
+        Tweener.addTween(this._tooltip, {
204b62
+            opacity: this.hover ? 255 : 0,
204b62
+            time: TOOLTIP_ANIMATION_TIME * 1000,
204b62
+            transition: 'easeOutQuad',
204b62
+            onComplete: () => (this._tooltip.visible = this.hover),
204b62
+        });
204b62
+    }
204b62
+
204b62
     _onDestroy() {
204b62
+        this._tooltip.destroy();
204b62
+
204b62
         this._workspace.disconnect(this._windowAddedId);
204b62
         this._workspace.disconnect(this._windowRemovedId);
204b62
         global.display.disconnect(this._restackedId);
204b62
-- 
204b62
2.31.1
204b62