messageTray: don't time out banners when the user is inactive

This will ensure that the user doesn't miss notifications.
This commit is contained in:
Marina Zhurakhinskaya 2012-07-31 01:14:49 +02:00 committed by Jasper St. Pierre
parent 1a2dcf213e
commit ab5c0bcfcf

View File

@ -1487,9 +1487,8 @@ const MessageTray = new Lang.Class({
this._clickedSummaryItemAllocationChangedId = 0; this._clickedSummaryItemAllocationChangedId = 0;
this._pointerBarrier = 0; this._pointerBarrier = 0;
this._unseenNotifications = [];
this._idleMonitorWatchId = 0; this._idleMonitorWatchId = 0;
this._backFromAway = false; this._userActiveWhileNotificationShown = false;
this.idleMonitor = Shell.IdleMonitor.get(); this.idleMonitor = Shell.IdleMonitor.get();
@ -1713,10 +1712,6 @@ const MessageTray = new Lang.Class({
}, },
_onNotificationDestroy: function(notification) { _onNotificationDestroy: function(notification) {
let unseenNotificationsIndex = this._unseenNotifications.indexOf(notification);
if (unseenNotificationsIndex != -1)
this._unseenNotifications.splice(unseenNotificationsIndex, 1);
if (this._notification == notification && (this._notificationState == State.SHOWN || this._notificationState == State.SHOWING)) { if (this._notification == notification && (this._notificationState == State.SHOWN || this._notificationState == State.SHOWING)) {
this._updateNotificationTimeout(0); this._updateNotificationTimeout(0);
this._notificationRemoved = true; this._notificationRemoved = true;
@ -1977,7 +1972,8 @@ const MessageTray = new Lang.Class({
!this._locked && !this._locked &&
!(this._pointerInKeyboard && notificationExpanded); !(this._pointerInKeyboard && notificationExpanded);
let notificationLockedOut = this._isScreenLocked && (this._notification && !this._notification.showWhenLocked); let notificationLockedOut = this._isScreenLocked && (this._notification && !this._notification.showWhenLocked);
let notificationMustClose = this._notificationRemoved || notificationLockedOut || notificationExpired; // TODO: how to deal with locked out notiifcations if want to keep showing notifications?!
let notificationMustClose = this._notificationRemoved || notificationLockedOut || (notificationExpired && this._userActiveWhileNotificationShown);
let canShowNotification = notificationsPending && this._summaryState == State.HIDDEN; let canShowNotification = notificationsPending && this._summaryState == State.HIDDEN;
if (this._notificationState == State.HIDDEN) { if (this._notificationState == State.HIDDEN) {
@ -2011,9 +2007,7 @@ const MessageTray = new Lang.Class({
if (summarySummoned) { if (summarySummoned) {
this._showSummary(0); this._showSummary(0);
} else if (notificationsDone && !this._busy && !this._inFullscreen) { } else if (notificationsDone && !this._busy && !this._inFullscreen) {
if (this._backFromAway && this._unseenNotifications.length > 0) if (this._newSummaryItems.length > 0)
this._showSummary(LONGER_SUMMARY_TIMEOUT);
else if (this._newSummaryItems.length > 0)
this._showSummary(SUMMARY_TIMEOUT); this._showSummary(SUMMARY_TIMEOUT);
} }
} else if (this._summaryState == State.SHOWN && (!summaryPinned || mustHideSummary)) } else if (this._summaryState == State.SHOWN && (!summaryPinned || mustHideSummary))
@ -2147,27 +2141,15 @@ const MessageTray = new Lang.Class({
_onIdleMonitorWatch: function(monitor, id, userBecameIdle) { _onIdleMonitorWatch: function(monitor, id, userBecameIdle) {
this.idleMonitor.remove_watch(this._idleMonitorWatchId); this.idleMonitor.remove_watch(this._idleMonitorWatchId);
this._idleMonitorWatchId = 0; this._idleMonitorWatchId = 0;
if (!userBecameIdle)
if (userBecameIdle) { this._updateNotificationTimeout(2000);
// The user became idle, which means the user was active while the notifications were this._userActiveWhileNotificationShown = true;
// shown and we can unset this._unseenNotifications .
this._unseenNotiications = [];
} else if (this._unseenNotifications.length == 1 && this._unseenNotifications[0] == this._notification) {
// The user became active while the only notification in this._unseenNotifications is being shown
// as this._notification , so we can unset this._unseenNotifications .
this._unseenNotifications = [];
} else {
// The user became active and we have one or more unseen notifications. We should show
// the message tray to the user to inform the user about the missed notifications.
this._backFromAway = true;
this._updateState(); this._updateState();
}
}, },
_showNotification: function(notification) { _showNotification: function(notification) {
this._notification = notification; this._notification = notification;
this._unseenNotifications.push(this._notification); this._userActiveWhileNotificationShown = false;
if (this._idleMonitorWatchId == 0)
this._idleMonitorWatchId = this.idleMonitor.add_watch(1000, this._idleMonitorWatchId = this.idleMonitor.add_watch(1000,
Lang.bind(this, this._onIdleMonitorWatch)); Lang.bind(this, this._onIdleMonitorWatch));
this._notificationClickedId = this._notification.connect('done-displaying', this._notificationClickedId = this._notification.connect('done-displaying',
@ -2341,7 +2323,7 @@ const MessageTray = new Lang.Class({
}, },
_showSummary: function(timeout) { _showSummary: function(timeout) {
this._updateSeenSummaryItems(); this._newSummaryItems = [];
this._summaryBin.opacity = 0; this._summaryBin.opacity = 0;
this._summaryBin.y = this.actor.height; this._summaryBin.y = this.actor.height;
this._tween(this._summaryBin, '_summaryState', State.SHOWN, this._tween(this._summaryBin, '_summaryState', State.SHOWN,
@ -2356,6 +2338,7 @@ const MessageTray = new Lang.Class({
}, },
_showSummaryCompleted: function(timeout) { _showSummaryCompleted: function(timeout) {
this._newSummaryItems = [];
if (timeout != 0) { if (timeout != 0) {
this._summaryTimeoutId = this._summaryTimeoutId =
Mainloop.timeout_add(timeout * 1000, Mainloop.timeout_add(timeout * 1000,
@ -2370,7 +2353,6 @@ const MessageTray = new Lang.Class({
}, },
_hideSummary: function() { _hideSummary: function() {
this._updateSeenSummaryItems();
this._tween(this._summaryBin, '_summaryState', State.HIDDEN, this._tween(this._summaryBin, '_summaryState', State.HIDDEN,
{ opacity: 0, { opacity: 0,
time: ANIMATION_TIME, time: ANIMATION_TIME,
@ -2378,14 +2360,6 @@ const MessageTray = new Lang.Class({
}); });
}, },
_updateSeenSummaryItems: function() {
if (this._backFromAway) {
this._backFromAway = false;
this._unseenNotifications = [];
}
this._newSummaryItems = [];
},
_showSummaryBoxPointer: function() { _showSummaryBoxPointer: function() {
this._summaryBoxPointerItem = this._clickedSummaryItem; this._summaryBoxPointerItem = this._clickedSummaryItem;
this._summaryBoxPointerContentUpdatedId = this._summaryBoxPointerItem.connect('content-updated', this._summaryBoxPointerContentUpdatedId = this._summaryBoxPointerItem.connect('content-updated',