[gnome-shell/wip/message-tray: 5/33] messageTray: don't time out banners when the user is inactive



commit 97d3ed442d43d758fc04a87508914e0c058e0f36
Author: Marina Zhurakhinskaya <marinaz redhat com>
Date:   Tue Jul 31 01:14:49 2012 +0200

    messageTray: don't time out banners when the user is inactive
    
    This will ensure that the user doesn't miss notifications.

 js/ui/messageTray.js |   50 ++++++++++++--------------------------------------
 1 files changed, 12 insertions(+), 38 deletions(-)
---
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index e941131..ac096ad 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -1463,9 +1463,8 @@ const MessageTray = new Lang.Class({
         this._clickedSummaryItemAllocationChangedId = 0;
         this._pointerBarrier = 0;
 
-        this._unseenNotifications = [];
         this._idleMonitorWatchId = 0;
-        this._backFromAway = false;
+        this._userActiveWhileNotificationShown = false;
 
         this.idleMonitor = new Shell.IdleMonitor();
 
@@ -1689,10 +1688,6 @@ const MessageTray = new Lang.Class({
     },
 
     _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)) {
             this._updateNotificationTimeout(0);
             this._notificationRemoved = true;
@@ -1953,7 +1948,8 @@ const MessageTray = new Lang.Class({
                                   !this._locked &&
                                   !(this._pointerInKeyboard && notificationExpanded);
         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;
 
         if (this._notificationState == State.HIDDEN) {
@@ -1987,9 +1983,7 @@ const MessageTray = new Lang.Class({
             if (summarySummoned) {
                 this._showSummary(0);
             } else if (notificationsDone && !this._busy && !this._inFullscreen) {
-                if (this._backFromAway && this._unseenNotifications.length > 0)
-                    this._showSummary(LONGER_SUMMARY_TIMEOUT);
-                else if (this._newSummaryItems.length > 0)
+                if (this._newSummaryItems.length > 0)
                     this._showSummary(SUMMARY_TIMEOUT);
             }
         } else if (this._summaryState == State.SHOWN && (!summaryPinned || mustHideSummary))
@@ -2123,28 +2117,16 @@ const MessageTray = new Lang.Class({
     _onIdleMonitorWatch: function(monitor, id, userBecameIdle) {
         this.idleMonitor.remove_watch(this._idleMonitorWatchId);
         this._idleMonitorWatchId = 0;
-
-        if (userBecameIdle) {
-            // The user became idle, which means the user was active while the notifications were
-            // 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();
-       }
+        if (!userBecameIdle)
+            this._updateNotificationTimeout(2000);
+        this._userActiveWhileNotificationShown = true;
+        this._updateState();
     },
 
     _showNotification: function(notification) {
         this._notification = notification;
-        this._unseenNotifications.push(this._notification);
-        if (this._idleMonitorWatchId == 0)
-            this._idleMonitorWatchId = this.idleMonitor.add_watch(1000,
+        this._userActiveWhileNotificationShown = false;
+        this._idleMonitorWatchId = this.idleMonitor.add_watch(1000,
                                                                   Lang.bind(this, this._onIdleMonitorWatch));
         this._notificationClickedId = this._notification.connect('done-displaying',
                                                                  Lang.bind(this, this._escapeTray));
@@ -2317,7 +2299,7 @@ const MessageTray = new Lang.Class({
     },
 
     _showSummary: function(timeout) {
-        this._updateSeenSummaryItems();
+        this._newSummaryItems = [];
         this._summaryBin.opacity = 0;
         this._summaryBin.y = this.actor.height;
         this._tween(this._summaryBin, '_summaryState', State.SHOWN,
@@ -2332,6 +2314,7 @@ const MessageTray = new Lang.Class({
     },
 
     _showSummaryCompleted: function(timeout) {
+        this._newSummaryItems = [];
         if (timeout != 0) {
             this._summaryTimeoutId =
                 Mainloop.timeout_add(timeout * 1000,
@@ -2346,7 +2329,6 @@ const MessageTray = new Lang.Class({
     },
 
     _hideSummary: function() {
-        this._updateSeenSummaryItems();
         this._tween(this._summaryBin, '_summaryState', State.HIDDEN,
                     { opacity: 0,
                       time: ANIMATION_TIME,
@@ -2354,14 +2336,6 @@ const MessageTray = new Lang.Class({
                     });
     },
 
-    _updateSeenSummaryItems: function() {
-        if (this._backFromAway) {
-            this._backFromAway = false;
-            this._unseenNotifications = [];
-        }
-        this._newSummaryItems = [];
-    },
-
     _showSummaryBoxPointer: function() {
         this._summaryBoxPointerItem = this._clickedSummaryItem;
         this._summaryBoxPointerContentUpdatedId = this._summaryBoxPointerItem.connect('content-updated',



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