[gnome-shell] popupMenu: Add the ability to block sending events to the source actor



commit bea2d40f79bf17b7736ae0d9c1fc0564df0480f1
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Tue Mar 22 10:29:32 2011 -0400

    popupMenu: Add the ability to block sending events to the source actor
    
    It can be useful to avoid sending enter/leave events to the source actor
    of a menu: this would be the case when the source actor isn't a menu item
    that should participate in menu navigation but rather is some object
    (like an app icon) that we want to indicate corresponds to the menu.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=642871

 js/ui/popupMenu.js |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index 887fb41..7531f77 100644
--- a/js/ui/popupMenu.js
+++ b/js/ui/popupMenu.js
@@ -724,6 +724,11 @@ PopupMenuBase.prototype = {
         }
 
         this.isOpen = false;
+
+        // If set, we don't send events (including crossing events) to the source actor
+        // for the menu which causes its prelight state to freeze
+        this.blockSourceEvents = false;
+
         this._activeMenuItem = null;
     },
 
@@ -1331,14 +1336,20 @@ PopupMenuManager.prototype = {
         return this._activeMenuContains(event.get_source());
     },
 
-    _eventIsOnAnyMenuSource: function(event) {
+    _shouldBlockEvent: function(event) {
         let src = event.get_source();
+
+        if (this._activeMenu != null && this._activeMenu.actor.contains(src))
+            return false;
+
         for (let i = 0; i < this._menus.length; i++) {
             let menu = this._menus[i].menu;
-            if (menu.sourceActor && menu.sourceActor.contains(src))
-                return true;
+            if (menu.sourceActor && !menu.blockSourceEvents && menu.sourceActor.contains(src)) {
+                return false;
+            }
         }
-        return false;
+
+        return true;
     },
 
     _findMenu: function(item) {
@@ -1370,7 +1381,7 @@ PopupMenuManager.prototype = {
         } else if (eventType == Clutter.EventType.BUTTON_PRESS && !activeMenuContains) {
             this._closeMenu();
             return true;
-        } else if (activeMenuContains || this._eventIsOnAnyMenuSource(event)) {
+        } else if (!this._shouldBlockEvent(event)) {
             return false;
         }
 



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