From 024ab39c6d1d23887411da7117a721f2ec0733e4 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Thu, 29 Apr 2010 15:06:51 -0400 Subject: [PATCH] [MessageTray] don't time out the tray if the user is mousing towards it If a notification is about to hide, but the user has moved the mouse towards it, let it stick around for another second (and so on, until the mouse either reaches the tray and causes it to be pinned, or stops moving the mouse toward it). https://bugzilla.gnome.org/show_bug.cgi?id=610071 --- js/ui/messageTray.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js index df695e882..a9c58c08a 100644 --- a/js/ui/messageTray.js +++ b/js/ui/messageTray.js @@ -820,6 +820,9 @@ MessageTray.prototype = { // tween, and so the onComplete will remain as well. this._expandNotification(); } + + let [x, y, mods] = global.get_pointer(); + this._lastSeenMouseY = y; }, _showNotificationCompleted: function() { @@ -829,8 +832,21 @@ MessageTray.prototype = { }, _notificationTimeout: function() { - this._notificationTimeoutId = 0; - this._updateState(); + let [x, y, mods] = global.get_pointer(); + if (y > this._lastSeenMouseY + 10 && y < this.actor.y) { + // The mouse is moving towards the notification, so don't + // hide it yet. (We just create a new timeout (and destroy + // the old one) each time because the bookkeeping is + // simpler.) + this._lastSeenMouseY = y; + this._notificationTimeoutId = + Mainloop.timeout_add(1000, + Lang.bind(this, this._notificationTimeout)); + } else { + this._notificationTimeoutId = 0; + this._updateState(); + } + return false; },