[gnome-shell/wip/carlosg/grabs-pt2: 18/19] dialog: Handle key events on self




commit 54bf2b785f310f1277818c064225eb0b50183162
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Jan 28 11:59:51 2022 +0100

    dialog: Handle key events on self
    
    And set the dialog actor reactive. Specifically, we do not know whether
    the parent actor is reactive or not, and we should not be changing that
    from here, so do not use that actor to handle key events.

 js/ui/dialog.js | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/dialog.js b/js/ui/dialog.js
index 9513a8151a..a62a3a35b0 100644
--- a/js/ui/dialog.js
+++ b/js/ui/dialog.js
@@ -13,7 +13,10 @@ function _setLabel(label, value) {
 var Dialog = GObject.registerClass(
 class Dialog extends St.Widget {
     _init(parentActor, styleClass) {
-        super._init({ layout_manager: new Clutter.BinLayout() });
+        super._init({
+            layout_manager: new Clutter.BinLayout(),
+            reactive: true,
+        });
         this.connect('destroy', this._onDestroy.bind(this));
 
         this._initialKeyFocus = null;
@@ -27,7 +30,6 @@ class Dialog extends St.Widget {
             this._dialog.add_style_class_name(styleClass);
 
         this._parentActor = parentActor;
-        this._eventId = this._parentActor.connect('event', this._modalEventHandler.bind(this));
         this._parentActor.add_child(this);
     }
 
@@ -70,7 +72,7 @@ class Dialog extends St.Widget {
         this.makeInactive();
     }
 
-    _modalEventHandler(actor, event) {
+    vfunc_event(event) {
         if (event.type() == Clutter.EventType.KEY_PRESS) {
             this._pressedKey = event.get_key_symbol();
         } else if (event.type() == Clutter.EventType.KEY_RELEASE) {


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