messageTray: Correct idleness

If the user is already active when the notification pops up, we
won't get an idle watcher because there's no transition from
active to idle or vice versa. Correct this by initializing the
state correctly from XSync.
This commit is contained in:
Jasper St. Pierre
2012-08-10 18:54:33 -03:00
parent 3da0e9e86a
commit 8f71920622
3 changed files with 18 additions and 3 deletions

View File

@ -39,6 +39,8 @@ const NOTIFICATION_ICON_SIZE = 24;
// range from the point where it left the tray.
const MOUSE_LEFT_ACTOR_THRESHOLD = 20;
const IDLE_TIME = 1000;
const State = {
HIDDEN: 0,
SHOWING: 1,
@ -1979,9 +1981,9 @@ const MessageTray = new Lang.Class({
_showNotification: function(notification) {
this._notification = notification;
this._userActiveWhileNotificationShown = false;
this._idleMonitorWatchId = this.idleMonitor.add_watch(1000,
Lang.bind(this, this._onIdleMonitorWatch));
this._userActiveWhileNotificationShown = this.idleMonitor.get_idletime() <= IDLE_TIME;
this._idleMonitorWatchId = this.idleMonitor.add_watch(IDLE_TIME,
Lang.bind(this, this._onIdleMonitorWatch));
this._notificationClickedId = this._notification.connect('done-displaying',
Lang.bind(this, this._escapeTray));
this._notificationBin.child = this._notification.actor;