[gnome-shell/gnome-41] overviewControls: Handle keyboard navigation



commit 25049bd1638d95a434078850ada57de4230824a5
Author: Florian Müllner <fmuellner gnome org>
Date:   Mon Jan 24 17:00:36 2022 +0100

    overviewControls: Handle keyboard navigation
    
    The old view selector used to handle initiating keynav into pages.
    That code became inactive when non-search related functionality
    was moved elsewhere, and was finally removed in commit cf41f4a527.
    
    We still want the keynav behavior it provided, so add similar code
    to overview's control manager.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4056
    
    (cherry picked from commit 1cee7e676002a792718bd5a956f7783a8066e57f)
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2180>

 js/ui/overviewControls.js | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
---
diff --git a/js/ui/overviewControls.js b/js/ui/overviewControls.js
index 7a77b32500..2344ad8eb0 100644
--- a/js/ui/overviewControls.js
+++ b/js/ui/overviewControls.js
@@ -435,6 +435,41 @@ class ControlsManager extends St.Widget {
                 Main.overview.toggle();
         });
 
+        // connect_after to give search controller first dibs on the event
+        global.stage.connect_after('key-press-event', (actor, event) => {
+            if (this._searchController.searchActive)
+                return Clutter.EVENT_PROPAGATE;
+
+            if (global.stage.key_focus &&
+                !this.contains(global.stage.key_focus))
+                return Clutter.EVENT_PROPAGATE;
+
+            const { finalState } =
+                this._stateAdjustment.getStateTransitionParams();
+            let keynavDisplay;
+
+            if (finalState === ControlsState.WINDOW_PICKER)
+                keynavDisplay = this._workspacesDisplay;
+            else if (finalState === ControlsState.APP_GRID)
+                keynavDisplay = this._appDisplay;
+
+            if (!keynavDisplay)
+                return Clutter.EVENT_PROPAGATE;
+
+            const symbol = event.get_key_symbol();
+            if (symbol === Clutter.KEY_Tab || symbol === Clutter.KEY_Down) {
+                keynavDisplay.navigate_focus(
+                    null, St.DirectionType.TAB_FORWARD, false);
+                return Clutter.EVENT_STOP;
+            } else if (symbol === Clutter.KEY_ISO_Left_Tab) {
+                keynavDisplay.navigate_focus(
+                    null, St.DirectionType.TAB_BACKWARD, false);
+                return Clutter.EVENT_STOP;
+            }
+
+            return Clutter.EVENT_PROPAGATE;
+        });
+
         Main.wm.addKeybinding(
             'toggle-application-view',
             new Gio.Settings({ schema_id: WindowManager.SHELL_KEYBINDINGS_SCHEMA }),


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