[gnome-shell-extensions/wip/rstrode/heads-up-display: 46/62] window-list: Handle closing window picker with Escape




commit f202bd112b1a87f2efef7f32f25b1d86c8f6884f
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Jul 2 18:12:31 2019 +0200

    window-list: Handle closing window picker with Escape
    
    Just like the overview can be closed with Escape, it makes sense to
    allow the same for the window picker (in addition to pressing super
    repeatedly).
    
    https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/80

 extensions/window-list/windowPicker.js | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
---
diff --git a/extensions/window-list/windowPicker.js b/extensions/window-list/windowPicker.js
index ba0a697..12a7627 100644
--- a/extensions/window-list/windowPicker.js
+++ b/extensions/window-list/windowPicker.js
@@ -68,6 +68,7 @@ var WindowPicker = class {
         this._modal = false;
 
         this._overlayKeyId = 0;
+        this._stageKeyPressId = 0;
 
         this.actor = new Clutter.Actor();
 
@@ -132,6 +133,16 @@ var WindowPicker = class {
         this._fakeOverviewAnimation();
         this._workspacesDisplay.show(false);
 
+        this._stageKeyPressId = global.stage.connect('key-press-event',
+            (a, event) => {
+                let sym = event.get_key_symbol();
+                if (sym == Clutter.KEY_Escape) {
+                    this.close();
+                    return Clutter.EVENT_STOP;
+                }
+                return Clutter.EVENT_PROPAGATE;
+            });
+
         this.emit('open-state-changed', this._visible);
     }
 
@@ -151,6 +162,9 @@ var WindowPicker = class {
             this._fakeOverviewVisible(false);
         });
 
+        global.stage.disconnect(this._stageKeyPressId);
+        this._stageKeyPressId = 0;
+
         this.emit('open-state-changed', this._visible);
     }
 
@@ -203,6 +217,10 @@ var WindowPicker = class {
         if (this._overlayKeyId)
             global.display.disconnect(this._overlayKeyId);
         this._overlayKeyId = 0;
+
+        if (this._stageKeyPressId)
+            global.stage.disconnect(this._stageKeyPressId);
+        this._stageKeyPressId = 0;
     }
 
     _updateBackgrounds() {


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