From cffc73a74b9c4c3f837763b32218282e4cc4eba0 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Wed, 19 Feb 2025 00:29:40 -0500 Subject: [PATCH] Add option to persist intellihide state gh-2242 --- ...shell.extensions.dash-to-panel.gschema.xml | 4 + src/intellihide.js | 32 ++++- src/panel.js | 18 ++- src/prefs.js | 54 ++++++--- ui/BoxIntellihideOptions.ui | 111 ++++++++---------- 5 files changed, 128 insertions(+), 91 deletions(-) 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 4a964d0..ebeafaa 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -391,6 +391,10 @@ Keybinding toggle intellihide Keybinding to reveal the panel while in intellihide mode + + -1 + Persisted intellihide hold status. -1 means the option is disabled + 2000 Intellihide enable start delay diff --git a/src/intellihide.js b/src/intellihide.js index 3a76f5a..0790e61 100644 --- a/src/intellihide.js +++ b/src/intellihide.js @@ -40,6 +40,7 @@ const MIN_UPDATE_MS = 250 const T1 = 'checkGrabTimeout' const T2 = 'limitUpdateTimeout' const T3 = 'postAnimateTimeout' +const T4 = 'enableStartTimeout' const SIDE_CONTROLS_ANIMATION_TIME = OverviewControls.SIDE_CONTROLS_ANIMATION_TIME / @@ -105,7 +106,26 @@ export const Intellihide = class { } this._setRevealMechanism() - this._queueUpdatePanelPosition() + + let lastState = SETTINGS.get_int('intellihide-persisted-state') + + if (lastState > -1) { + this._holdStatus = lastState + + if (lastState == Hold.NONE && Main.layoutManager._startingUp) + this._signalsHandler.add([ + this._panelBox, + 'notify::mapped', + () => this._hidePanel(true), + ]) + else this._queueUpdatePanelPosition() + } else + // -1 means that the option to persist hold isn't activated, so normal start + this._timeoutsHandler.add([ + T4, + SETTINGS.get_int('intellihide-enable-start-delay'), + () => this._queueUpdatePanelPosition(), + ]) } disable(reset) { @@ -146,12 +166,14 @@ export const Intellihide = class { } this._holdStatus |= holdStatus + this._maybePersistHoldStatus() } release(holdStatus) { this._holdStatus -= holdStatus if (this.enabled && !this._holdStatus) { + this._maybePersistHoldStatus() this._queueUpdatePanelPosition() } } @@ -171,6 +193,14 @@ export const Intellihide = class { } } + _maybePersistHoldStatus() { + if (SETTINGS.get_int('intellihide-persisted-state') > -1) + SETTINGS.set_int( + 'intellihide-persisted-state', + this._holdStatus & Hold.PERMANENT ? Hold.PERMANENT : Hold.NONE, + ) + } + _bindGeneralSignals() { this._signalsHandler.add( [ diff --git a/src/panel.js b/src/panel.js index ba5a09e..195301b 100644 --- a/src/panel.js +++ b/src/panel.js @@ -28,6 +28,7 @@ */ import Clutter from 'gi://Clutter' +import GLib from 'gi://GLib' import GObject from 'gi://GObject' import * as AppIcons from './appIcons.js' import * as Utils from './utils.js' @@ -61,7 +62,6 @@ let tracker = Shell.WindowTracker.get_default() export const panelBoxes = ['_leftBox', '_centerBox', '_rightBox'] //timeout names -const T2 = 'startIntellihideTimeout' const T4 = 'showDesktopTimeout' const T5 = 'trackerFocusAppTimeout' const T6 = 'scrollPanelDelayTimeout' @@ -278,11 +278,7 @@ export const Panel = GObject.registerClass( 'dashtopanelMainPanel ' + this.getOrientation(), ) - this._timeoutsHandler.add([ - T2, - SETTINGS.get_int('intellihide-enable-start-delay'), - () => (this.intellihide = new Intellihide.Intellihide(this)), - ]) + this.intellihide = new Intellihide.Intellihide(this) this._signalsHandler.add( // this is to catch changes to the theme or window scale factor @@ -366,7 +362,11 @@ export const Panel = GObject.registerClass( // This saves significant CPU when repainting the screen. this.set_offscreen_redirect(Clutter.OffscreenRedirect.ALWAYS) - if (!Main.layoutManager._startingUp) this._resetGeometry() + if (!Main.layoutManager._startingUp) + GLib.idle_add(GLib.PRIORITY_LOW, () => { + this._resetGeometry() + return GLib.SOURCE_REMOVE + }) } disable() { @@ -696,10 +696,6 @@ export const Panel = GObject.registerClass( this.taskbar.resetAppIcons(true) this.dynamicTransparency.updateExternalStyle() - if (this.intellihide && this.intellihide.enabled) { - this.intellihide.reset() - } - if (this.checkIfVertical()) { this.showAppsIconWrapper.realShowAppsIcon.toggleButton.set_width( this.geom.w, diff --git a/src/prefs.js b/src/prefs.js index 52be36d..7bda652 100644 --- a/src/prefs.js +++ b/src/prefs.js @@ -1659,6 +1659,30 @@ const Preferences = class { setShortcut(this._settings, 'intellihide-key-toggle'), ) + let intellihidePersistStateSwitch = this._builder.get_object( + 'intellihide_persist_state_switch', + ) + let intellihideStartDelayButton = this._builder.get_object( + 'intellihide_enable_start_delay_spinbutton', + ) + + intellihidePersistStateSwitch.set_active( + this._settings.get_int('intellihide-persisted-state') > -1, + ) + + intellihideStartDelayButton.set_sensitive( + this._settings.get_int('intellihide-persisted-state') == -1, + ) + + intellihidePersistStateSwitch.connect('notify::active', (widget) => { + intellihideStartDelayButton.set_sensitive(!widget.get_active()) + + this._settings.set_int( + 'intellihide-persisted-state', + widget.get_active() ? 0 : -1, + ) + }) + this._builder .get_object('intellihide_animation_time_spinbutton') .set_value(this._settings.get_int('intellihide-animation-time')) @@ -1677,17 +1701,15 @@ const Preferences = class { this._settings.set_int('intellihide-close-delay', widget.get_value()) }) - this._builder - .get_object('intellihide_enable_start_delay_spinbutton') - .set_value(this._settings.get_int('intellihide-enable-start-delay')) - this._builder - .get_object('intellihide_enable_start_delay_spinbutton') - .connect('value-changed', (widget) => { - this._settings.set_int( - 'intellihide-enable-start-delay', - widget.get_value(), - ) - }) + intellihideStartDelayButton.set_value( + this._settings.get_int('intellihide-enable-start-delay'), + ) + intellihideStartDelayButton.connect('value-changed', (widget) => { + this._settings.set_int( + 'intellihide-enable-start-delay', + widget.get_value(), + ) + }) this._builder .get_object('intellihide_options_button') @@ -1747,6 +1769,8 @@ const Preferences = class { this._settings.get_default_value('intellihide-key-toggle-text'), ) + intellihidePersistStateSwitch.set_active(false) + this._settings.set_value( 'intellihide-animation-time', this._settings.get_default_value('intellihide-animation-time'), @@ -1769,11 +1793,9 @@ const Preferences = class { 'intellihide-enable-start-delay', ), ) - this._builder - .get_object('intellihide_enable_start_delay_spinbutton') - .set_value( - this._settings.get_int('intellihide-enable-start-delay'), - ) + intellihideStartDelayButton.set_value( + this._settings.get_int('intellihide-enable-start-delay'), + ) }, ) diff --git a/ui/BoxIntellihideOptions.ui b/ui/BoxIntellihideOptions.ui index 0da3ec2..a141604 100644 --- a/ui/BoxIntellihideOptions.ui +++ b/ui/BoxIntellihideOptions.ui @@ -1,53 +1,47 @@ - + + - + 1 + 100 + 10 9990 - 10 - 100 - 1 + 100 + 10 5000 - 10 - 100 - 10 + 100 + 10 2000 - 10 - 100 - 10 + 100 + 10 4000 - 10 - 100 - + 100 + 10 10000 - 10 - 100 - - vertical - 600 - 24 - 32 32 - 32 32 - + 32 + 32 + vertical + 24 + 600 - Only hide the panel when it is obstructed by windows @@ -58,7 +52,6 @@ - The panel hides from @@ -74,13 +67,10 @@ - - - Require pressure at the edge of the screen to reveal the panel @@ -91,43 +81,38 @@ - Required pressure threshold (px) - center - 4 - 0 intellihide_pressure_threshold_adjustment True + 0 + center + 4 - Required pressure timeout (ms) - center - 4 - 0 intellihide_pressure_time_adjustment True + 0 + center + 4 - - - Allow the panel to be revealed while in fullscreen mode @@ -138,11 +123,10 @@ - - Only hide secondary panels (requires multi-monitors option) + Only hide secondary panels center @@ -150,77 +134,78 @@ - - Keyboard shortcut to reveal and hold the panel Syntax: &lt;Shift&gt;, &lt;Ctrl&gt;, &lt;Alt&gt;, &lt;Super&gt; + Keyboard shortcut to reveal and hold the panel + e.g. <Super>i + center + 12 + + + + + + + Persist state across restarts + + center - 12 - e.g. <Super>i - - - Hide and reveal animation duration (ms) - center - 4 - 0 intellihide_animation_time_adjustment True + 0 + center + 4 - Delay before hiding the panel (ms) - center - 4 - 10 intellihide_close_delay_adjustment True + 10 + center 10 + 4 - Delay before enabling intellihide on start (ms) - center - 4 - 10 intellihide_enable_hide_delay_adjustment True + 10 + center 10 + 4 - - - - \ No newline at end of file +