From 660f0fec1633d27cfcef5709e66320bf2c854fb8 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Wed, 28 Aug 2013 10:50:07 -0400 Subject: [PATCH] popupMenu: Fix algorithm for separator visibility to work with sections Before, separators naively checked whether their siblings were visible using actor visibility. However, if section actors are visible but have no visible children, this will fail. Special-case separators when doing visiblity checks. https://bugzilla.gnome.org/show_bug.cgi?id=707801 --- js/ui/popupMenu.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index e720c6720..adff1c6a1 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -35,6 +35,13 @@ function _ensureStyle(actor) { actor.ensure_style(); } +function isPopupMenuItemVisible(child) { + if (child._delegate instanceof PopupMenuSection) + if (child._delegate.isEmpty()) + return false; + return child.visible; +} + const PopupBaseMenuItem = new Lang.Class({ Name: 'PopupBaseMenuItem', @@ -437,7 +444,7 @@ const PopupMenuBase = new Lang.Class({ let hasVisibleChildren = this.box.get_children().some(function(child) { if (child._delegate instanceof PopupSeparatorMenuItem) return false; - return child.visible; + return isPopupMenuItemVisible(child); }); return !hasVisibleChildren; @@ -518,7 +525,7 @@ const PopupMenuBase = new Lang.Class({ let childBeforeIndex = index - 1; - while (childBeforeIndex >= 0 && !children[childBeforeIndex].visible) + while (childBeforeIndex >= 0 && !isPopupMenuItemVisible(children[childBeforeIndex])) childBeforeIndex--; if (childBeforeIndex < 0 @@ -529,7 +536,7 @@ const PopupMenuBase = new Lang.Class({ let childAfterIndex = index + 1; - while (childAfterIndex < children.length && !children[childAfterIndex].visible) + while (childAfterIndex < children.length && !isPopupMenuItemVisible(children[childAfterIndex])) childAfterIndex++; if (childAfterIndex >= children.length