popupMenu: Close when source actor gets hidden

If a menu is anchored to a source actor, it is odd to leave it floating
around when the source actor gets hidden.

Close the menu instead in that case.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/2002
This commit is contained in:
Florian Müllner 2019-12-17 01:01:13 +01:00 committed by Florian Müllner
parent 4f66b301e7
commit 35494f5d08

View File

@ -814,7 +814,12 @@ var PopupMenu = class extends PopupMenuBase {
if (this.sourceActor) {
this._keyPressId = this.sourceActor.connect('key-press-event',
this._onKeyPress.bind(this));
this._onKeyPress.bind(this));
this._notifyMappedId = this.sourceActor.connect('notify::mapped',
() => {
if (!this.sourceActor.mapped)
this.close();
});
}
this._systemModalOpenedId = 0;
@ -928,6 +933,9 @@ var PopupMenu = class extends PopupMenuBase {
if (this._keyPressId)
this.sourceActor.disconnect(this._keyPressId);
if (this._notifyMappedId)
this.sourceActor.disconnect(this._notifyMappedId);
if (this._systemModalOpenedId)
Main.layoutManager.disconnect(this._systemModalOpenedId);
this._systemModalOpenedId = 0;