popupMenu: Don't close submenus when the toplevel container is closed

It seems this behavior at one time was intentional, but I (along with
the designers) think it looks ugly having the menu having its insides
shrinking and shifting around while fading out of existence.

There's two cases where we currently explicitly try to animate the
submenu closed -- when an item is clicked inside the submenu, and
when the toplevel closes. This removes both of those.

The user expectation is that submenus will be closed the next time the
toplevel is open even if they were open before, so force submenus closed
when the toplevel finishes fading out, without any animation.

https://bugzilla.gnome.org/show_bug.cgi?id=702539
This commit is contained in:
Jasper St. Pierre 2013-06-12 17:38:02 -04:00
parent 7db0900cc8
commit 2aae272d86

View File

@ -772,7 +772,6 @@ const PopupMenuBase = new Lang.Class({
_connectSubMenuSignals: function(object, menu) {
object._subMenuActivateId = menu.connect('activate', Lang.bind(this, function() {
this.emit('activate');
this.close(BoxPointer.PopupAnimation.FULL);
}));
object._subMenuActiveChangeId = menu.connect('active-changed', Lang.bind(this, function(submenu, submenuItem) {
if (this._activeMenuItem && this._activeMenuItem != submenuItem)
@ -887,10 +886,14 @@ const PopupMenuBase = new Lang.Class({
else
menuItem.close();
});
menuItem._parentClosingId = this.connect('menu-closed', function() {
menuItem.emit('menu-closed');
});
menuItem.connect('destroy', Lang.bind(this, function() {
menuItem.disconnect(menuItem._subMenuActivateId);
menuItem.disconnect(menuItem._subMenuActiveChangeId);
this.disconnect(menuItem._parentOpenStateChangedId);
this.disconnect(menuItem._parentClosingId);
this.length--;
}));
@ -901,9 +904,8 @@ const PopupMenuBase = new Lang.Class({
this.box.insert_child_below(menuItem.menu.actor, before_item);
this._connectSubMenuSignals(menuItem, menuItem.menu);
this._connectItemSignals(menuItem);
menuItem._closingId = this.connect('open-state-changed', function(self, open) {
if (!open)
menuItem.menu.close(BoxPointer.PopupAnimation.FADE);
menuItem._closingId = this.connect('menu-closed', function() {
menuItem.menu.close(BoxPointer.PopupAnimation.NONE);
});
} else if (menuItem instanceof PopupSeparatorMenuItem) {
this._connectItemSignals(menuItem);
@ -1114,8 +1116,11 @@ const PopupMenu = new Lang.Class({
childMenu.close();
});
if (this._boxPointer.actor.visible)
this._boxPointer.hide(animate);
if (this._boxPointer.actor.visible) {
this._boxPointer.hide(animate, Lang.bind(this, function() {
this.emit('menu-closed');
}));
}
if (!this.isOpen)
return;