[gnome-shell/wip/carlosg/no-event-source: 1/8] grabHelper: Query stage for target actor instead of event.get_source()




commit 1825776f38f85c1c444dfc8b153d47423e559d03
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Feb 25 13:07:49 2022 +0100

    grabHelper: Query stage for target actor instead of event.get_source()
    
    Events are going to stop containing the destinatary, so stop using this
    API. Querying the stage is equivalent and ensured to be up-to-date.

 js/ui/grabHelper.js | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/grabHelper.js b/js/ui/grabHelper.js
index 05fe82a31a..6d77cc9ec9 100644
--- a/js/ui/grabHelper.js
+++ b/js/ui/grabHelper.js
@@ -261,9 +261,17 @@ var GrabHelper = class GrabHelper {
             return Clutter.EVENT_PROPAGATE;
         }
 
+        if ((type === Clutter.EventType.KEY_PRESS ||
+             type === Clutter.EventType.KEY_RELEASE) &&
+            this.currentGrab.actor.contains(global.stage.get_key_focus()))
+            return Clutter.EVENT_PROPAGATE;
+
+        const targetActor = global.stage.get_device_actor(
+            event.get_device(), event.get_event_sequence());
+
         if (type === Clutter.EventType.ENTER ||
             type === Clutter.EventType.LEAVE ||
-            this.currentGrab.actor.contains(event.get_source()))
+            this.currentGrab.actor.contains(targetActor))
             return Clutter.EVENT_PROPAGATE;
 
         if (Main.keyboard.shouldTakeEvent(event))
@@ -275,7 +283,7 @@ var GrabHelper = class GrabHelper {
             if (press || touchBegin)
                 this._ignoreUntilRelease = true;
 
-            let i = this._actorInGrabStack(event.get_source()) + 1;
+            let i = this._actorInGrabStack(targetActor) + 1;
             this.ungrab({ actor: this._grabStack[i].actor, isUser: true });
             return Clutter.EVENT_STOP;
         }


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