diff --git a/js/ui/main.js b/js/ui/main.js index 79915ee89e..d664b9f376 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -368,7 +368,7 @@ function start() { global.reparentActor(global.top_window_group, global.stage); - global.menuStackLength = 0; + global.menuStack = []; layoutManager = new Layout.LayoutManager(); diff --git a/js/ui/panel.js b/js/ui/panel.js index 11c736bec2..cc850ced54 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -3547,6 +3547,26 @@ Panel.prototype = { } }, + /** + * _panelHasOpenMenus: + * + * Checks if panel has open menus in the global.menuStack + * @returns + */ + _panelHasOpenMenus: function() { + if (global.menuStack == null || global.menuStack.length == 0) + return false; + + for (let i = 0; i < global.menuStack.length; i++) { + let menu = global.menuStack[i]; + if (menu.getPanel() === this.actor) { + return true; + } + } + + return false; + }, + /** * _updatePanelVisibility: * @@ -3557,7 +3577,7 @@ Panel.prototype = { * true = autohide, false = always show, intel = Intelligent */ _updatePanelVisibility: function() { - if (this._panelEditMode || this._peeking) + if (this._panelEditMode || this._peeking || this._panelHasOpenMenus()) this._shouldShow = true; else { switch (this._autohideSettings) { @@ -3787,7 +3807,7 @@ Panel.prototype = { if (this._destroyed) return; this._showHideTimer = 0; - if ((this._shouldShow && !force) || global.menuStackLength > 0) return; + if ((this._shouldShow && !force) || this._panelHasOpenMenus()) return; // setup panel tween - slide out the monitor edge leaving one pixel // if horizontal panel, animation on y. if vertical, animation on x. diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index da99cb4f0a..a47b967d82 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -2280,6 +2280,29 @@ var PopupMenu = class PopupMenu extends PopupMenuBase { */ setSourceAlignment(alignment) {} + /** + * getPanel: + * + * @returns panel (Clutter.Actor | null) actor of the panel this menu is on, or null if it is not on a panel + */ + getPanel() { + let parentPanel = null; + if (this.sourceActor.get_name() == "panel") { + parentPanel = this.sourceActor; + } else { + let parent = this.sourceActor.get_parent(); + while (parent) { + if (parent.get_name() == "panel") { + parentPanel = parent; + break; + } + parent = parent.get_parent(); + } + } + + return parentPanel; + } + /** * open: * @animate (boolean): whether to animate the open effect or not @@ -2300,28 +2323,18 @@ var PopupMenu = class PopupMenu extends PopupMenuBase { this._breadth = 0; this.isOpen = true; - if (global.menuStackLength == undefined) - global.menuStackLength = 0; - global.menuStackLength += 1; + if (global.menuStack == undefined) + global.menuStack = []; + global.menuStack.push(this); + + Main.panelManager.updatePanelsVisibility(); this._signals.connect(this.actor, "paint", Lang.bind(this, this.on_paint)); /* If the sourceActor of our menu is located on a panel or from the panel itself, we want to position it just below the panel actors. This prevents some cases where the menu will otherwise partially overlap the panel and look strange visually */ - let parentPanel = null; - if (this.sourceActor.get_name() == "panel") { - parentPanel = this.sourceActor; - } else { - let parent = this.sourceActor.get_parent(); - while (parent) { - if (parent.get_name() == "panel") { - parentPanel = parent; - break; - } - parent = parent.get_parent(); - } - } + let parentPanel = this.getPanel(); if (parentPanel) { let monitor = Main.layoutManager.findMonitorForActor(this.sourceActor) @@ -2442,9 +2455,7 @@ var PopupMenu = class PopupMenu extends PopupMenuBase { return; this.isOpen = false; - global.menuStackLength -= 1; - - Main.panelManager.updatePanelsVisibility(); + global.menuStack.splice(global.menuStack.indexOf(this), 1); if (this._activeMenuItem) this._activeMenuItem.setActive(false); @@ -2513,6 +2524,8 @@ var PopupMenu = class PopupMenu extends PopupMenuBase { this.animating = false; this.actor.hide(); } + + Main.panelManager.updatePanelsVisibility(); this.emit('open-state-changed', false); // keep the order of open-state-changed -> menu-animated-closed in case it matters. diff --git a/js/ui/tooltips.js b/js/ui/tooltips.js index c056efacc0..5121178077 100644 --- a/js/ui/tooltips.js +++ b/js/ui/tooltips.js @@ -340,7 +340,7 @@ PanelItemTooltip.prototype = { }, show: function() { - if (this._tooltip.get_text() == "" || global.menuStackLength > 0 || !this.mousePosition) + if (this._tooltip.get_text() == "" || global.menuStack.length > 0 || !this.mousePosition) return; let op = this._tooltip.get_opacity();