From fb3165447d4dac048d0b085bf0266027da66df2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 21 Jun 2018 18:03:31 +0200 Subject: [PATCH] appDisplay: Show full app name on hover --- data/theme/gnome-shell-sass/_common.scss | 8 ++++ js/ui/appDisplay.js | 48 ++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/data/theme/gnome-shell-sass/_common.scss b/data/theme/gnome-shell-sass/_common.scss index f1aaea689..5bf01a540 100644 --- a/data/theme/gnome-shell-sass/_common.scss +++ b/data/theme/gnome-shell-sass/_common.scss @@ -1402,6 +1402,14 @@ StScrollBar { } + .app-well-hover-text { + text-align: center; + color: $osd_fg_color; + background-color: $osd_bg_color; + border-radius: 5px; + padding: 3px; + } + .app-well-app-running-dot { //running apps indicator width: 10px; height: 3px; background-color: $selected_bg_color; diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index 74c772d50..070057c69 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -1628,6 +1628,20 @@ var AppIcon = new Lang.Class({ this.actor.connect('clicked', this._onClicked.bind(this)); this.actor.connect('popup-menu', this._onKeyboardPopupMenu.bind(this)); + this._hoverText = null; + this._hoverTimeoutId = 0; + + if (this.icon.label) { + this._hoverText = new St.Label({ style_class: 'app-well-hover-text', + text: this.icon.label.text, + visible: false }); + this._hoverText.clutter_text.line_wrap = true; + Main.layoutManager.addChrome(this._hoverText); + + this.actor.connect('notify::hover', this._syncHoverText.bind(this)); + this.connect('sync-tooltip', this._syncHoverText.bind(this)); + } + this._menu = null; this._menuManager = new PopupMenu.PopupMenuManager(this); @@ -1659,12 +1673,39 @@ var AppIcon = new Lang.Class({ this.app.disconnect(this._stateChangedId); this._stateChangedId = 0; this._removeMenuTimeout(); + this._removeHoverTimeout(); + if (this._hoverText) + this._hoverText.destroy(); + this._hoverText = null; }, _createIcon(iconSize) { return this.app.create_icon_texture(iconSize); }, + _syncHoverText() { + if (this.shouldShowTooltip()) { + if (this._hoverTimeoutId) + return; + + this._hoverTimeoutId = Mainloop.timeout_add(300, () => { + this._hoverText.style = `max-width: ${2 * this.icon.iconSize}px;`; + this._hoverText.ensure_style(); + + let [x, y] = this.icon.label.get_transformed_position(); + let offset = (this._hoverText.width - this.icon.label.width) / 2; + this._hoverText.set_position(Math.floor(x - offset), Math.floor(y)); + this._hoverText.show(); + + this._hoverTimeoutId = 0; + return GLib.SOURCE_REMOVE; + }); + } else { + this._removeHoverTimeout(); + this._hoverText.hide(); + } + }, + _removeMenuTimeout() { if (this._menuTimeoutId > 0) { Mainloop.source_remove(this._menuTimeoutId); @@ -1672,6 +1713,13 @@ var AppIcon = new Lang.Class({ } }, + _removeHoverTimeout() { + if (this._hoverTimeoutId > 0) { + Mainloop.source_remove(this._hoverTimeoutId); + this._hoverTimeoutId = 0; + } + }, + _updateRunningStyle() { if (this.app.state != Shell.AppState.STOPPED) this._dot.show(); -- 2.20.1