[gnome-shell] PopupMenuManager: only navigate visible menus



commit 4de15b2b57b9e805c038a9d4fb1ebf99317f3279
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Thu Dec 30 15:22:54 2010 +0100

    PopupMenuManager: only navigate visible menus
    
    When doing keyboard navigation, ignore menus whose sourceActor is
    hidden.
    This is needed to hide status icons, as otherwise the menu would
    appear despite having no icon.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=638306

 js/ui/popupMenu.js |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index 91b412c..30f353e 100644
--- a/js/ui/popupMenu.js
+++ b/js/ui/popupMenu.js
@@ -1194,6 +1194,18 @@ PopupMenuManager.prototype = {
         return -1;
     },
 
+    _nextMenu: function(pos, direction) {
+        for (let i = 1; i < this._menus.length; i++) {
+            let candidate = mod(pos + i * direction, this._menus.length);
+            let menu = this._menus[candidate].menu;
+            if (!menu.sourceActor || menu.sourceActor.visible)
+                return menu;
+        }
+        // no menu is found? this should not happen
+        // anyway stay on current menu
+        return this._menus[pos];
+    },
+
     _onEventCapture: function(actor, event) {
         if (!this.grabbed)
             return false;
@@ -1232,7 +1244,7 @@ PopupMenuManager.prototype = {
         if (symbol == Clutter.Left || symbol == Clutter.Right) {
             let direction = symbol == Clutter.Right ? 1 : -1;
             let pos = this._findMenu(this._activeMenu);
-            let next = this._menus[mod(pos + direction, this._menus.length)].menu;
+            let next = this._nextMenu(pos, direction);
             if (next != this._activeMenu) {
                 this._changeMenu(next);
                 next.activateFirst();



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