[gnome-shell/wip/grab-helper-top-panel: 19/20] grabHelper: Drop to the actor clicked on



commit 50fec9e1f855d42efba2505a35ae3344c4b72d71
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Nov 26 14:55:03 2012 -0500

    grabHelper: Drop to the actor clicked on
    
    This is necessary for child popups in menus, e.g. while in a combo box,
    clicking outside of the user menu should drop the entire menu, but
    clicking on the user menu itself should only drop the combo box.

 js/ui/grabHelper.js |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/js/ui/grabHelper.js b/js/ui/grabHelper.js
index a35ceb4..268f41f 100644
--- a/js/ui/grabHelper.js
+++ b/js/ui/grabHelper.js
@@ -76,6 +76,18 @@ const GrabHelper = new Lang.Class({
         }
     },
 
+    _actorInGrabStack: function(actor) {
+        while (actor) {
+            for (let i = 0; i < this._grabStack.length; i++) {
+                let grab = this._grabStack[i];
+                if (grab.actor == actor)
+                    return i;
+            }
+            actor = actor.get_parent();
+        }
+        return -1;
+    },
+
     _isWithinGrabbedActor: function(actor) {
        let currentActor = this.currentGrab.actor;
         while (actor) {
@@ -330,7 +342,8 @@ const GrabHelper = new Lang.Class({
             // which should be a release event.
             if (press)
                 this._ignoreRelease = true;
-            this.ungrab({ actor: this._grabStack[0].actor });
+            let i = this._actorInGrabStack(event.get_source()) + 1;
+            this.ungrab({ actor: this._grabStack[i].actor });
         }
 
         return this._modalCount > 0;



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