[gnome-shell/wip/carlosg/no-event-source: 14/19] popupMenu: Query stage for target actor instead of event.get_source()




commit 17730fe5c4eed1e6a9add4db22a7e46ff3e52172
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Feb 25 13:09:33 2022 +0100

    popupMenu: 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.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2216>

 js/ui/popupMenu.js | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index 81ba02ce23..4b51a7a9c8 100644
--- a/js/ui/popupMenu.js
+++ b/js/ui/popupMenu.js
@@ -1396,6 +1396,8 @@ var PopupMenuManager = class {
 
     _onCapturedEvent(actor, event) {
         let menu = actor._delegate;
+        const targetActor = global.stage.get_event_actor(event);
+
         if (event.type() === Clutter.EventType.KEY_PRESS) {
             let symbol = event.get_key_symbol();
             if (symbol === Clutter.KEY_Down &&
@@ -1408,13 +1410,13 @@ var PopupMenuManager = class {
             }
         } else if (event.type() === Clutter.EventType.ENTER &&
                    (event.get_flags() & Clutter.EventFlags.GRAB_NOTIFY) === 0) {
-            let hoveredMenu = this._findMenuForSource(event.get_source());
+            let hoveredMenu = this._findMenuForSource(targetActor);
 
             if (hoveredMenu && hoveredMenu !== menu)
                 this._changeMenu(hoveredMenu);
         } else if ((event.type() === Clutter.EventType.BUTTON_PRESS ||
                     event.type() === Clutter.EventType.TOUCH_BEGIN) &&
-                   !actor.contains(event.get_source())) {
+                   !actor.contains(targetActor)) {
             menu.close(BoxPointer.PopupAnimation.FULL);
         }
 


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