[gnome-shell] overviewControls: Add shortcut for shifting through overview



commit f4b88aac04775c3637382f8b997d6502c194dee9
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Jun 13 13:26:09 2020 +0200

    overviewControls: Add shortcut for shifting through overview
    
    This is the same as the vertical swipe gesture, but for keyboard
    junkies: Analoguous to the <super><alt>left/right shortcuts for
    switching between workspaces, add <super><alt>up/down to shift
    between session, window picker and app grid.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1695>

 data/org.gnome.shell.gschema.xml.in | 14 +++++++++++++
 js/ui/overviewControls.js           | 40 +++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
---
diff --git a/data/org.gnome.shell.gschema.xml.in b/data/org.gnome.shell.gschema.xml.in
index 90fce6c1ee..1af4b09a4d 100644
--- a/data/org.gnome.shell.gschema.xml.in
+++ b/data/org.gnome.shell.gschema.xml.in
@@ -135,6 +135,20 @@
         Keybinding to open the application menu.
       </description>
     </key>
+    <key name="shift-overview-up" type="as">
+      <default>["&lt;Super&gt;&lt;Alt&gt;Up"]</default>
+      <summary>Keybinding to shift between overview states</summary>
+      <description>
+        Keybinding to shift between session, window picker and app grid
+      </description>
+    </key>
+    <key name="shift-overview-down" type="as">
+      <default>["&lt;Super&gt;&lt;Alt&gt;Down"]</default>
+      <summary>Keybinding to shift between overview states</summary>
+      <description>
+        Keybinding to shift between app grid, window picker and session
+      </description>
+    </key>
     <key name="toggle-application-view" type="as">
       <default>["&lt;Super&gt;a"]</default>
       <summary>Keybinding to open the “Show Applications” view</summary>
diff --git a/js/ui/overviewControls.js b/js/ui/overviewControls.js
index 14f247b091..96d99403f4 100644
--- a/js/ui/overviewControls.js
+++ b/js/ui/overviewControls.js
@@ -358,6 +358,18 @@ class ControlsManager extends St.Widget {
             Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
             this._toggleAppsPage.bind(this));
 
+        Main.wm.addKeybinding('shift-overview-up',
+            new Gio.Settings({ schema_id: WindowManager.SHELL_KEYBINDINGS_SCHEMA }),
+            Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
+            Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
+            () => this._shiftState(Meta.MotionDirection.UP));
+
+        Main.wm.addKeybinding('shift-overview-down',
+            new Gio.Settings({ schema_id: WindowManager.SHELL_KEYBINDINGS_SCHEMA }),
+            Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
+            Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
+            () => this._shiftState(Meta.MotionDirection.DOWN));
+
         this.connect('destroy', this._onDestroy.bind(this));
 
         this._update();
@@ -513,6 +525,34 @@ class ControlsManager extends St.Widget {
         }
     }
 
+    _shiftState(direction) {
+        let { currentState, finalState } = this._stateAdjustment.getStateTransitionParams();
+
+        if (direction === Meta.MotionDirection.DOWN)
+            finalState = Math.max(finalState - 1, ControlsState.HIDDEN);
+        else if (direction === Meta.MotionDirection.UP)
+            finalState = Math.min(finalState + 1, ControlsState.APP_GRID);
+
+        if (finalState === currentState)
+            return;
+
+        if (currentState === ControlsState.HIDDEN &&
+            finalState === ControlsState.WINDOW_PICKER) {
+            Main.overview.show();
+        } else if (finalState === ControlsState.HIDDEN) {
+            Main.overview.hide();
+        } else {
+            this._stateAdjustment.ease(finalState, {
+                duration: SIDE_CONTROLS_ANIMATION_TIME,
+                mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+                onComplete: () => {
+                    this.dash.showAppsButton.checked =
+                        finalState === ControlsState.APP_GRID;
+                },
+            });
+        }
+    }
+
     _onDestroy() {
         global.workspace_manager.disconnect(this._nWorkspacesNotifyId);
     }


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