[panel] fix nested-queue_relayout warning in menus

We don't need to reposition the menu every time its button is
allocated; we can just stick it in the right place when we pop it up
(which is guaranteed to not be during a layout cycle).

(This means that now we won't reposition the menu if the button
moves/resizes while the menu is already popped up, but it's not clear
that we'd want it to anyway, since that could easily result in the
user selecting the wrong item, etc.)

Also, we don't need to override the menu's width any more, so remove
that.

https://bugzilla.gnome.org/show_bug.cgi?id=619113
This commit is contained in:
Dan Winship 2010-05-19 13:50:39 -04:00
parent b6a47cdf76
commit c8f4adde7f

View File

@ -419,14 +419,9 @@ PanelMenuButton.prototype = {
track_hover: true });
this.actor._delegate = this;
this.actor.connect('button-press-event', Lang.bind(this, this._onButtonPress));
// FIXME - this will trigger a warning about a queued allocation from inside
// allocate; hard to solve without a way to express a high level positioning
// constraint between actors
this.actor.connect('notify::allocation', Lang.bind(this, this._repositionMenu));
this._state = this.State.CLOSED;
this.menu = new PanelMenu(this.actor);
this.menu.connect('activate', Lang.bind(this, this._onActivated));
this.menu.actor.connect('notify::allocation', Lang.bind(this, this._repositionMenuArrow));
Main.chrome.addActor(this.menu.actor, { visibleInOverview: true,
affectsStruts: false });
this.menu.actor.hide();
@ -460,9 +455,6 @@ PanelMenuButton.prototype = {
let [buttonX, buttonY] = this.actor.get_transformed_position();
let [buttonWidth, buttonHeight] = this.actor.get_transformed_size();
// We need to reset the size here; otherwise get_preferred_size will
// just return what we set below
this.menu.actor.set_size(-1, -1);
let [minWidth, minHeight, natWidth, natHeight] = this.menu.actor.get_preferred_size();
// Adjust X position for alignment
@ -483,17 +475,10 @@ PanelMenuButton.prototype = {
// Actually set the position
let panelActor = Main.panel.actor;
this.menu.actor.x = stageX;
this.menu.actor.width = natWidth;
this.menu.actor.y = Math.floor(panelActor.y + panelActor.height);
// TODO - we could scroll here
this.menu.actor.height = natHeight;
},
_repositionMenuArrow: function() {
let [buttonX, buttonY] = this.actor.get_transformed_position();
let [buttonWidth, buttonHeight] = this.actor.get_transformed_size();
let [menuX, menuY] = this.menu.actor.get_transformed_position();
this.menu.setArrowOrigin((buttonX - menuX) + Math.floor(buttonWidth / 2));
// And adjust the arrow
this.menu.setArrowOrigin((buttonX - stageX) + Math.floor(buttonWidth / 2));
},
close: function() {