[gnome-shell/wip/message-tray-menu: 7/25] popupMenu: Allow PopupMenuManager to take an existing grab helper



commit e3673a9ae3eb462e9711657fb371906320721b37
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri Apr 19 11:52:55 2013 -0400

    popupMenu: Allow PopupMenuManager to take an existing grab helper
    
    We want to use PopupMenuManager for the message tray menu, but in
    order to prevent interference with having two GrabHelpers manage
    the tray, simply modify PopupMenuManager to allow the existing
    GrabHelper used in the message tray.

 js/ui/appDisplay.js |    2 +-
 js/ui/panel.js      |    2 +-
 js/ui/popupMenu.js  |   16 ++++++++++++----
 3 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index bcfb57a..c7b84d2 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -693,7 +693,7 @@ const AppIcon = new Lang.Class({
         this.actor.connect('popup-menu', Lang.bind(this, this._onKeyboardPopupMenu));
 
         this._menu = null;
-        this._menuManager = new PopupMenu.PopupMenuManager(this);
+        this._menuManager = new PopupMenu.PopupMenuManager({ actor: this.actor });
 
         this._draggable = DND.makeDraggable(this.actor);
         this._draggable.connect('drag-begin', Lang.bind(this,
diff --git a/js/ui/panel.js b/js/ui/panel.js
index 332be12..c36b140 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -958,7 +958,7 @@ const Panel = new Lang.Class({
 
         this.statusArea = {};
 
-        this.menuManager = new PopupMenu.PopupMenuManager(this);
+        this.menuManager = new PopupMenu.PopupMenuManager({ actor: this.actor });
 
         this._leftBox = new St.BoxLayout({ name: 'panelLeft' });
         this.actor.add_actor(this._leftBox);
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index 3391657..6388b60 100644
--- a/js/ui/popupMenu.js
+++ b/js/ui/popupMenu.js
@@ -2001,9 +2001,15 @@ const RemoteMenu = new Lang.Class({
 const PopupMenuManager = new Lang.Class({
     Name: 'PopupMenuManager',
 
-    _init: function(owner) {
-        this._owner = owner;
-        this._grabHelper = new GrabHelper.GrabHelper(owner.actor);
+    _init: function(params) {
+        params = Params.parse(params, { grabHelper: null,
+                                        actor: null });
+
+        if (params.grabHelper)
+            this._grabHelper = params.grabHelper;
+        else
+            this._grabHelper = new GrabHelper.GrabHelper(params.actor);
+
         this._menus = [];
     },
 
@@ -2061,7 +2067,7 @@ const PopupMenuManager = new Lang.Class({
 
     get activeMenu() {
         let firstGrab = this._grabHelper.grabStack[0];
-        if (firstGrab)
+        if (firstGrab && firstGrab.actor && firstGrab.actor._delegate)
             return firstGrab.actor._delegate;
         else
             return null;
@@ -2106,6 +2112,8 @@ const PopupMenuManager = new Lang.Class({
             return false;
 
         let isChildMenu = this._grabHelper.grabStack.some(function(grab) {
+            if (!grab || !grab.actor || !grab.actor._delegate)
+                return false;
             let existingMenu = grab.actor._delegate;
             return existingMenu.isChildMenu(menu);
         });


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