diff --git a/Settings.ui b/Settings.ui index 97fa7b6..c7baa2b 100644 --- a/Settings.ui +++ b/Settings.ui @@ -1378,11 +1378,15 @@ 12 32 - + True - True - end + False center + + Never + Show temporarily + Always visible + 1 @@ -1485,7 +1489,7 @@ 32 - False + True center 12 diff --git a/appIcons.js b/appIcons.js index e3e0c21..8dc5c94 100644 --- a/appIcons.js +++ b/appIcons.js @@ -719,10 +719,14 @@ const taskbarAppIcon = new Lang.Class({ }, updateNumberOverlay: function() { + // We apply an overall scale factor that might come from a HiDPI monitor. + // Clutter dimensions are in physical pixels, but CSS measures are in logical + // pixels, so make sure to consider the scale. + let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor; // Set the font size to something smaller than the whole icon so it is // still visible. The border radius is large to make the shape circular let [minWidth, natWidth] = this._iconContainer.get_preferred_width(-1); - let font_size = Math.round(Math.max(12, 0.3*natWidth)); + let font_size = Math.round(Math.max(12, 0.3*natWidth) / scaleFactor); let size = Math.round(font_size*1.2); this._numberOverlayLabel.set_style( this._numberOverlayStyle + diff --git a/overview.js b/overview.js index 899b06e..d9a8001 100644 --- a/overview.js +++ b/overview.js @@ -201,6 +201,9 @@ const dtpOverview = new Lang.Class({ }, this); this._hotKeysEnabled = true; + + if (this._dtpSettings.get_string('hotkeys-overlay-combo') === 'ALWAYS') + this.taskbar.toggleNumberOverlay(true); }, _disableHotKeys: function() { @@ -215,6 +218,8 @@ const dtpOverview = new Lang.Class({ }, this); this._hotKeysEnabled = false; + + this.taskbar.toggleNumberOverlay(false); }, _optionalNumberOverlay: function() { @@ -229,12 +234,13 @@ const dtpOverview = new Lang.Class({ Lang.bind(this, this._checkHotkeysOptions) ], [ this._dtpSettings, - 'changed::hotkeys-overlay', - Lang.bind(this, this._checkHotkeysOptions) - ], [ - this._dtpSettings, - 'changed::shortcut-text', - Lang.bind(this, this._checkHotkeysOptions) + 'changed::hotkeys-overlay-combo', + Lang.bind(this, function() { + if (this._dtpSettings.get_string('hotkeys-overlay-combo') === 'ALWAYS') + this.taskbar.toggleNumberOverlay(true); + else + this.taskbar.toggleNumberOverlay(false); + }) ]); }, @@ -246,9 +252,7 @@ const dtpOverview = new Lang.Class({ }, _enableExtraShortcut: function() { - let shortcut_is_valid = this._setShortcut(); - - if (shortcut_is_valid && !this._shortcutIsSet) { + if (!this._shortcutIsSet) { Main.wm.addKeybinding('shortcut', this._dtpSettings, Meta.KeyBindingFlags.NONE, Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW, @@ -260,21 +264,6 @@ const dtpOverview = new Lang.Class({ } }, - _setShortcut: function() { - let shortcut_text = this._dtpSettings.get_string('shortcut-text'); - let [key, mods] = Gtk.accelerator_parse(shortcut_text); - - if (Gtk.accelerator_valid(key, mods)) { - let shortcut = Gtk.accelerator_name(key, mods); - this._dtpSettings.set_strv('shortcut', [shortcut]); - return true; - } - else { - this._dtpSettings.set_strv('shortcut', []); - return false; - } - }, - _disableExtraShortcut: function() { if (this._shortcutIsSet) { Main.wm.removeKeybinding('shortcut'); @@ -283,15 +272,21 @@ const dtpOverview = new Lang.Class({ }, _showOverlay: function() { - if (this._dtpSettings.get_boolean('hotkeys-overlay') || this._overlayFromShortcut) - this.taskbar.toggleNumberOverlay(true); - // Restart the counting if the shortcut is pressed again if (this._numberOverlayTimeoutId) { Mainloop.source_remove(this._numberOverlayTimeoutId); this._numberOverlayTimeoutId = 0; } + let hotkey_option = this._dtpSettings.get_string('hotkeys-overlay-combo'); + + // Set to true and exit if the overlay is always visible + if (hotkey_option === 'ALWAYS') + return; + + if (hotkey_option === 'TEMPORARILY' || this._overlayFromShortcut) + this.taskbar.toggleNumberOverlay(true); + let timeout = this._dtpSettings.get_int('overlay-timeout'); if (this._overlayFromShortcut) { timeout = this._dtpSettings.get_int('shortcut-timeout'); diff --git a/prefs.js b/prefs.js index 60353d0..ff4090d 100644 --- a/prefs.js +++ b/prefs.js @@ -74,6 +74,19 @@ function cssHexString(css) { return rrggbb; } +function setShortcut(settings) { + let shortcut_text = settings.get_string('shortcut-text'); + let [key, mods] = Gtk.accelerator_parse(shortcut_text); + + if (Gtk.accelerator_valid(key, mods)) { + let shortcut = Gtk.accelerator_name(key, mods); + settings.set_strv('shortcut', [shortcut]); + } + else { + settings.set_strv('shortcut', []); + } +} + function checkHotkeyPrefix(settings) { settings.delay(); @@ -549,6 +562,10 @@ const Settings = new Lang.Class({ 'sensitive', Gio.SettingsBindFlags.DEFAULT); + this._builder.get_object('overlay_combo').connect('changed', Lang.bind (this, function(widget) { + this._settings.set_string('hotkeys-overlay-combo', widget.get_active_id()); + })); + // Create dialog for number overlay options this._builder.get_object('overlay_button').connect('clicked', Lang.bind(this, function() { @@ -564,8 +581,6 @@ const Settings = new Lang.Class({ let box = this._builder.get_object('box_overlay_shortcut'); dialog.get_content_area().add(box); - this._builder.get_object('overlay_switch').set_active(this._settings.get_boolean('hotkeys-overlay')); - this._settings.bind('hotkey-prefix-text', this._builder.get_object('hotkey_prefix_combo'), 'text', @@ -580,28 +595,38 @@ const Settings = new Lang.Class({ 'active-id', Gio.SettingsBindFlags.DEFAULT); - this._settings.bind('hotkeys-overlay', - this._builder.get_object('overlay_switch'), - 'active', + this._builder.get_object('overlay_combo').set_active_id(this._settings.get_string('hotkeys-overlay-combo')); + + this._settings.bind('hotkeys-overlay-combo', + this._builder.get_object('overlay_combo'), + 'active-id', Gio.SettingsBindFlags.DEFAULT); + this._settings.bind('overlay-timeout', this._builder.get_object('timeout_spinbutton'), 'value', Gio.SettingsBindFlags.DEFAULT); - this._settings.bind('hotkeys-overlay', - this._builder.get_object('timeout_spinbutton'), - 'sensitive', - Gio.SettingsBindFlags.DEFAULT); + if (this._settings.get_string('hotkeys-overlay-combo') !== 'TEMPORARILY') { + this._builder.get_object('timeout_spinbutton').set_sensitive(false); + } + + this._settings.connect('changed::hotkeys-overlay-combo', Lang.bind(this, function() { + if (this._settings.get_string('hotkeys-overlay-combo') !== 'TEMPORARILY') + this._builder.get_object('timeout_spinbutton').set_sensitive(false); + else + this._builder.get_object('timeout_spinbutton').set_sensitive(true); + })); this._settings.bind('shortcut-text', this._builder.get_object('shortcut_entry'), 'text', Gio.SettingsBindFlags.DEFAULT); + this._settings.connect('changed::shortcut-text', Lang.bind(this, function() {setShortcut(this._settings);})); dialog.connect('response', Lang.bind(this, function(dialog, id) { if (id == 1) { // restore default settings for the relevant keys - let keys = ['hotkey-prefix-text', 'shortcut-text', 'hotkeys-overlay', 'overlay-timeout']; + let keys = ['hotkey-prefix-text', 'shortcut-text', 'hotkeys-overlay-combo', 'overlay-timeout']; keys.forEach(function(val) { this._settings.set_value(val, this._settings.get_default_value(val)); }, this); diff --git a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml index d01bf89..b46f8f5 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -26,6 +26,11 @@ + + + + + @@ -286,10 +291,10 @@ Timeout to hide the dock, in seconds Sets the time duration before the dock is hidden again. - - true - Show the dock when using the hotkeys - The dock will be quickly shown so that the number-overlay is visible and app activation is easier + + 'TEMPORARILY' + Transitivity of the number overlay + You can choose between NEVER, TEMPORARILY and ALWAYS. false diff --git a/taskbar.js b/taskbar.js index fde02d9..b25fa11 100644 --- a/taskbar.js +++ b/taskbar.js @@ -865,6 +865,9 @@ const taskbar = new Lang.Class({ icon.updateNumberOverlay(); }); + if (this._dtpSettings.get_boolean('hot-keys') && + this._dtpSettings.get_string('hotkeys-overlay-combo') === 'ALWAYS') + this.toggleNumberOverlay(true); }, toggleNumberOverlay: function(activate) {