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