[gnome-shell] overviewControls: Support double-super when animations are off



commit 28723ac088835cccd23447c8d718bdca8e6aebf0
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Apr 15 12:00:12 2021 +0200

    overviewControls: Support double-super when animations are off
    
    When super is pressed again during the overview transition, we shift
    up to the app grid. That means that the feature currently doesn't
    work when animations are disabled (like in a VM), because there is
    no transition in that case.
    
    Address this by adding a time-based fallback in that case, i.e.
    shift up when a second super-press occurs within 250ms after the
    first one.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4121
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1811>

 js/ui/overviewControls.js | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/overviewControls.js b/js/ui/overviewControls.js
index 3b5ec583f9..811d7c2023 100644
--- a/js/ui/overviewControls.js
+++ b/js/ui/overviewControls.js
@@ -1,7 +1,7 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 /* exported ControlsManager */
 
-const { Clutter, Gio, GObject, Meta, Shell, St } = imports.gi;
+const { Clutter, Gio, GLib, GObject, Meta, Shell, St } = imports.gi;
 
 const AppDisplay = imports.ui.appDisplay;
 const Dash = imports.ui.dash;
@@ -407,6 +407,7 @@ class ControlsManager extends St.Widget {
 
         this._a11ySettings = new Gio.Settings({ schema_id: A11Y_SCHEMA });
 
+        this._lastOverlayKeyTime = 0;
         global.display.connect('overlay-key', () => {
             if (this._a11ySettings.get_boolean('stickykeys-enable'))
                 return;
@@ -414,7 +415,15 @@ class ControlsManager extends St.Widget {
             const { initialState, finalState, transitioning } =
                 this._stateAdjustment.getStateTransitionParams();
 
-            if (transitioning && finalState > initialState)
+            const time = GLib.get_monotonic_time() / 1000;
+            const timeDiff = time - this._lastOverlayKeyTime;
+            this._lastOverlayKeyTime = time;
+
+            const shouldShift = St.Settings.get().enable_animations
+                ? transitioning && finalState > initialState
+                : Main.overview.visible && timeDiff < Overview.ANIMATION_TIME;
+
+            if (shouldShift)
                 this._shiftState(Meta.MotionDirection.UP);
             else
                 Main.overview.toggle();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]