Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always show panel if a menu is open on it #11779

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/ui/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ function start() {

global.reparentActor(global.top_window_group, global.stage);

global.menuStackLength = 0;
global.menuStack = [];

layoutManager = new Layout.LayoutManager();

Expand Down
24 changes: 22 additions & 2 deletions js/ui/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
*
Expand All @@ -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) {
Expand Down Expand Up @@ -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.
Expand Down
51 changes: 32 additions & 19 deletions js/ui/popupMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion js/ui/tooltips.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down