MessageTray: never show summary and a new notification at the same time

We want to minimize focus stealing from the user. If a non-urgent notification
comes in while the user is interacting with the tray, we add it to the tray
and only show it after the user is done interacting with the tray. If an
urgent notification comes in while the user is interacting with the tray,
we hide the tray and show the urgent notification.

https://bugzilla.gnome.org/show_bug.cgi?id=636838
This commit is contained in:
Hellyna Ng 2011-02-28 18:09:40 +08:00 committed by Marina Zhurakhinskaya
parent 604722b775
commit 5a86b0f9e3

View File

@ -1691,14 +1691,15 @@ MessageTray.prototype = {
// at the present time. // at the present time.
_updateState: function() { _updateState: function() {
// Notifications // Notifications
let notificationsPending = this._notificationQueue.length > 0 && let notificationUrgent = this._notificationQueue.length > 0 && this._notificationQueue[0].urgency == Urgency.CRITICAL;
(!this._busy || this._notificationQueue[0].urgency == Urgency.CRITICAL); let notificationsPending = this._notificationQueue.length > 0 && (!this._busy || notificationUrgent);
let notificationPinned = this._pointerInTray && !this._pointerInSummary && !this._notificationRemoved; let notificationPinned = this._pointerInTray && !this._pointerInSummary && !this._notificationRemoved;
let notificationExpanded = this._notificationBin.y < 0; let notificationExpanded = this._notificationBin.y < 0;
let notificationExpired = (this._notificationTimeoutId == 0 && !(this._notification && this._notification.urgency == Urgency.CRITICAL) && !this._pointerInTray && !this._locked) || this._notificationRemoved; let notificationExpired = (this._notificationTimeoutId == 0 && !(this._notification && this._notification.urgency == Urgency.CRITICAL) && !this._pointerInTray && !this._locked) || this._notificationRemoved;
let canShowNotification = notificationsPending && this._summaryState == State.HIDDEN;
if (this._notificationState == State.HIDDEN) { if (this._notificationState == State.HIDDEN) {
if (notificationsPending) if (canShowNotification)
this._showNotification(); this._showNotification();
} else if (this._notificationState == State.SHOWN) { } else if (this._notificationState == State.SHOWN) {
if (notificationExpired) if (notificationExpired)
@ -1720,7 +1721,11 @@ MessageTray.prototype = {
this._notificationState == State.SHOWN); this._notificationState == State.SHOWN);
let notificationsDone = !notificationsVisible && !notificationsPending; let notificationsDone = !notificationsVisible && !notificationsPending;
if (this._summaryState == State.HIDDEN) { let summaryOptionalInOverview = this._overviewVisible && !this._locked && !summaryHovered;
let mustHideSummary = (notificationsPending && (notificationUrgent || summaryOptionalInOverview))
|| notificationsVisible;
if (this._summaryState == State.HIDDEN && !mustHideSummary) {
if (this._backFromAway) { if (this._backFromAway) {
// Immediately set this to false, so that we don't schedule a timeout later // Immediately set this to false, so that we don't schedule a timeout later
this._backFromAway = false; this._backFromAway = false;
@ -1732,7 +1737,7 @@ MessageTray.prototype = {
this._showSummary(0); this._showSummary(0);
} }
} else if (this._summaryState == State.SHOWN) { } else if (this._summaryState == State.SHOWN) {
if (!summaryPinned) if (!summaryPinned || mustHideSummary)
this._hideSummary(); this._hideSummary();
else if (summaryVisibleWithNoHover && !summaryNotificationIsForExpandedSummaryItem) else if (summaryVisibleWithNoHover && !summaryNotificationIsForExpandedSummaryItem)
// If we are hiding the summary, we'll collapse the expanded summary item when we are done // If we are hiding the summary, we'll collapse the expanded summary item when we are done
@ -1761,7 +1766,7 @@ MessageTray.prototype = {
if (haveClickedSummaryItem && !summarySourceIsMainNotificationSource && canShowSummaryBoxPointer && !requestedNotificationStackIsEmpty) if (haveClickedSummaryItem && !summarySourceIsMainNotificationSource && canShowSummaryBoxPointer && !requestedNotificationStackIsEmpty)
this._showSummaryBoxPointer(); this._showSummaryBoxPointer();
} else if (this._summaryBoxPointerState == State.SHOWN) { } else if (this._summaryBoxPointerState == State.SHOWN) {
if (!haveClickedSummaryItem || !canShowSummaryBoxPointer || wrongSummaryBoxPointer) if (!haveClickedSummaryItem || !canShowSummaryBoxPointer || wrongSummaryBoxPointer || mustHideSummary)
this._hideSummaryBoxPointer(); this._hideSummaryBoxPointer();
} }
@ -2016,8 +2021,7 @@ MessageTray.prototype = {
}, },
_hideSummaryCompleted: function() { _hideSummaryCompleted: function() {
this._expandedSummaryItem = null; this._setExpandedSummaryItem(null);
this._expandedSummaryItemTitleWidth = this._summaryItemTitleWidth;
}, },
_showSummaryBoxPointer: function() { _showSummaryBoxPointer: function() {