[gnome-shell/T29763: 78/249] viewSelector: Allow triggering the desktop search on key presses



commit 80a57e10130dc458b073459566cee1455cf7e7fe
Author: Mario Sanchez Prada <mario endlessm com>
Date:   Wed Feb 14 10:42:44 2018 +0000

    viewSelector: Allow triggering the desktop search on key presses
    
    This implements the necessary hooks to start searching when typing
    from the APPS page (icon grid mode).
    
     * 2020-03-17: Code style cleanups

 js/ui/overview.js     |  1 +
 js/ui/viewSelector.js | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+)
---
diff --git a/js/ui/overview.js b/js/ui/overview.js
index 2805dc42c0..d493197601 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -520,6 +520,7 @@ var Overview = class {
 
     focusSearch() {
         this.show();
+        this.viewSelector.focusSearch();
     }
 
     _showOrSwitchPage(page) {
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index ea8c6301c5..c43b0b375f 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -446,6 +446,7 @@ var ViewSelector = GObject.registerClass({
         }));
 
         this.appDisplay = this._viewsDisplay.appDisplay;
+        this._entry = this._viewsDisplay.entry;
 
         this._stageKeyPressId = 0;
         Main.overview.connect('showing', () => {
@@ -525,7 +526,14 @@ var ViewSelector = GObject.registerClass({
         Main.overview.show();
     }
 
+    _clearSearch() {
+        this._entry.resetSearch();
+        this._viewsDisplay.showPage(ViewsDisplayPage.APP_GRID, false);
+    }
+
     show(viewPage) {
+        this._clearSearch();
+
         // We're always starting up to the APPS page, so avoid making the workspacesDisplay
         // (used for the Windows picker) visible to prevent situations where that actor
         // would intercept clicks meant for the desktop's icons grid.
@@ -551,6 +559,11 @@ var ViewSelector = GObject.registerClass({
         this._workspacesDisplay.hide();
     }
 
+    focusSearch() {
+        if (this._activePage === this._appsPage)
+            this._entry.grab_key_focus();
+    }
+
     _addPage(actor, name, a11yIcon, params) {
         params = Params.parse(params, { a11yFocus: null });
 
@@ -617,6 +630,13 @@ var ViewSelector = GObject.registerClass({
         }
     }
 
+    _pageChanged() {
+        if (this._activePage !== this._appsPage)
+            this._clearSearch();
+
+        this._pageChanged();
+    }
+
     _showPage(page) {
         if (!Main.overview.visible)
             return;
@@ -651,6 +671,12 @@ var ViewSelector = GObject.registerClass({
             return Clutter.EVENT_STOP;
         }
 
+        if (this._entry.handleStageEvent(event))
+            return Clutter.EVENT_STOP;
+
+        if (this._entry.active)
+            return Clutter.EVENT_PROPAGATE;
+
         if (!global.stage.key_focus) {
             if (symbol === Clutter.KEY_Tab || symbol === Clutter.KEY_Down) {
                 this._activePage.navigate_focus(null, St.DirectionType.TAB_FORWARD, false);


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