messageTray: Skip banner mode when queue exceeds a threshold

We want to shield users from being overloaded by an overwhelming stream
of notification banners, either due to coming back from idle/lock or
because an application is misbehaving. Previously we replaced all queued
notifications with a summary notification in that case, but now that
notifications appear in the summary immediately, we can simply stop
adding them to the queue and rely on the date menu to convey that
information to the user.

https://bugzilla.gnome.org/show_bug.cgi?id=744850
This commit is contained in:
Florian Müllner 2015-02-14 03:18:52 +01:00
parent d6eea0e380
commit 8c72c93aae

View File

@ -27,6 +27,8 @@ const NOTIFICATION_TIMEOUT = 4;
const HIDE_TIMEOUT = 0.2; const HIDE_TIMEOUT = 0.2;
const LONGER_HIDE_TIMEOUT = 0.6; const LONGER_HIDE_TIMEOUT = 0.6;
const MAX_NOTIFICATIONS_IN_QUEUE = 3;
// We delay hiding of the tray if the mouse is within MOUSE_LEFT_ACTOR_THRESHOLD // We delay hiding of the tray if the mouse is within MOUSE_LEFT_ACTOR_THRESHOLD
// range from the point where it left the tray. // range from the point where it left the tray.
const MOUSE_LEFT_ACTOR_THRESHOLD = 20; const MOUSE_LEFT_ACTOR_THRESHOLD = 20;
@ -1550,6 +1552,12 @@ const MessageTray = new Lang.Class({
// we stop hiding it and show it again. // we stop hiding it and show it again.
this._updateShowingNotification(); this._updateShowingNotification();
} else if (this._notificationQueue.indexOf(notification) < 0) { } else if (this._notificationQueue.indexOf(notification) < 0) {
// If the queue is "full", we skip banner mode and just show a small
// indicator in the panel; however do make an exception for CRITICAL
// notifications, as only banner mode allows expansion.
let bannerCount = this._notification ? 1 : 0;
let full = (this.queueCount + bannerCount >= MAX_NOTIFICATIONS_IN_QUEUE);
if (!full || notification.urgency == Urgency.CRITICAL) {
notification.connect('destroy', notification.connect('destroy',
Lang.bind(this, this._onNotificationDestroy)); Lang.bind(this, this._onNotificationDestroy));
this._notificationQueue.push(notification); this._notificationQueue.push(notification);
@ -1557,6 +1565,7 @@ const MessageTray = new Lang.Class({
return (notification2.urgency - notification1.urgency); return (notification2.urgency - notification1.urgency);
}); });
} }
}
this._updateState(); this._updateState();
}, },