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>
This commit is contained in:
Sebastian Keller 2021-12-26 00:19:25 +01:00 committed by Marge Bot
parent f04914ac15
commit 2801d0bfe3

View File

@ -1204,7 +1204,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 &&
@ -1215,10 +1216,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();
}
}