[gnome-shell] popupMenu: Close when source actor gets hidden



commit 35494f5d081a4f726631df3beee3bdc7d9a8b41e
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Dec 17 01:01:13 2019 +0100

    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

 js/ui/popupMenu.js | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index c3e763b369..56638050f9 100644
--- a/js/ui/popupMenu.js
+++ b/js/ui/popupMenu.js
@@ -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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]