From 3cb809b44417d2a46a281ae92e1b1212d7144215 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Thu, 1 Aug 2013 22:53:21 -0400 Subject: [PATCH] messageTray: Clean up the code that animates the notification Right now the code chooses to animate based on whether or not the notification was "removed", which is quite a sketchy subject. For now, add an additional case so that we don't animate when we transition to the lock screen. --- js/ui/messageTray.js | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js index 250c11295..12597ab0b 100644 --- a/js/ui/messageTray.js +++ b/js/ui/messageTray.js @@ -2250,26 +2250,27 @@ const MessageTray = new Lang.Class({ let nextNotification = notificationQueue.length > 0 ? notificationQueue[0] : null; let notificationPinned = this._pointerInNotification && !this._notificationRemoved; let notificationExpanded = this._notification && this._notification.expanded; - let notificationExpired = this._notificationTimeoutId == 0 && - !(this._notification && this._notification.urgency == Urgency.CRITICAL) && - !(this._notification && this._notification.focused) && - !this._pointerInNotification; + let notificationExpired = (this._userActiveWhileNotificationShown && + this._notificationTimeoutId == 0 && + !(this._notification && this._notification.urgency == Urgency.CRITICAL) && + !(this._notification && this._notification.focused) && + !this._pointerInNotification); let notificationLockedOut = !hasNotifications && this._notification; - let notificationMustClose = (this._notificationRemoved || notificationLockedOut || - (notificationExpired && this._userActiveWhileNotificationShown) || - this._traySummoned); + let notificationMustClose = (this._notificationRemoved || notificationLockedOut || notificationExpired || this._traySummoned); let canShowNotification = notificationsPending && this._trayState == State.HIDDEN && !this._traySummoned; if (this._notificationState == State.HIDDEN) { if (canShowNotification) this._showNotification(); } else if (this._notificationState == State.SHOWN) { - if (notificationMustClose) - this._hideNotification(); - else if (notificationPinned && !notificationExpanded) + if (notificationMustClose) { + let animate = !(this._notificationRemoved || notificationLockedOut); + this._hideNotification(animate); + } else if (notificationPinned && !notificationExpanded) { this._expandNotification(false); - else if (notificationPinned) + } else if (notificationPinned) { this._ensureNotificationFocused(); + } } // Summary notification @@ -2549,7 +2550,7 @@ const MessageTray = new Lang.Class({ return false; }, - _hideNotification: function() { + _hideNotification: function(animate) { this._notificationFocusGrabber.ungrabFocus(); if (this._notificationExpandedId) { @@ -2573,13 +2574,7 @@ const MessageTray = new Lang.Class({ this._notificationLeftMouseY = -1; } - if (this._notificationRemoved) { - Tweener.removeTweens(this._notificationWidget); - this._notificationWidget.y = this.actor.height; - this._notificationWidget.opacity = 0; - this._notificationState = State.HIDDEN; - this._hideNotificationCompleted(); - } else { + if (animate) { this._tween(this._notificationWidget, '_notificationState', State.HIDDEN, { y: this.actor.height, opacity: 0, @@ -2588,7 +2583,12 @@ const MessageTray = new Lang.Class({ onComplete: this._hideNotificationCompleted, onCompleteScope: this }); - + } else { + Tweener.removeTweens(this._notificationWidget); + this._notificationWidget.y = this.actor.height; + this._notificationWidget.opacity = 0; + this._notificationState = State.HIDDEN; + this._hideNotificationCompleted(); } },