Blame SOURCES/add-workspace-tooltips.patch

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