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