[gnome-shell/gnome-40] messageTray: Close SHOWING banner when its notification is destroyed



commit 65102404d499900d70dca3a4de51f6c3b39a2c7c
Author: Sebastian Keller <skeller gnome org>
Date:   Sun Dec 26 00:19:25 2021 +0100

    messageTray: Close SHOWING banner when its notification is destroyed
    
    Currently only banners in the SHOWN state are hidden when the underlying
    notification is destroyed, but if they are in the SHOWING state, they
    remain visible. Because the 'notification' member has already been set
    to null when the notification got destroyed, closing the banner by
    clicking on the close button, will not do anything and clicking on the
    notification itself will result in an error message. For notifications
    without a timeout, i.e. critical ones, this will result in an
    uncloseable notification.
    
    This can happen if the program creating a critical notification
    immediately closes it again, as might happen with power notifications
    from gnome-settings-daemon in some situations.
    
    Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4855
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2079>
    (cherry picked from commit 2801d0bfe3ebd66fec76766d05133b327e498535)

 js/ui/messageTray.js | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 1dab00a700..a15abdc321 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -1198,7 +1198,8 @@ var MessageTray = GObject.registerClass({
                 if (showNextNotification)
                     this._showNotification();
             }
-        } else if (this._notificationState == State.SHOWN) {
+        } else if (this._notificationState === State.SHOWING ||
+                   this._notificationState === State.SHOWN) {
             let expired = (this._userActiveWhileNotificationShown &&
                            this._notificationTimeoutId == 0 &&
                            this._notification.urgency != Urgency.CRITICAL &&
@@ -1209,10 +1210,12 @@ var MessageTray = GObject.registerClass({
             if (mustClose) {
                 let animate = hasNotifications && !this._notificationRemoved;
                 this._hideNotification(animate);
-            } else if (this._pointerInNotification && !this._banner.expanded) {
-                this._expandBanner(false);
-            } else if (this._pointerInNotification) {
-                this._ensureBannerFocused();
+            } else if (this._notificationState === State.SHOWN &&
+                       this._pointerInNotification) {
+                if (!this._banner.expanded)
+                    this._expandBanner(false);
+                else
+                    this._ensureBannerFocused();
             }
         }
 


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