[gnome-shell/wip/message-tray: 17/32] messageTray: Correct idleness
- From: Marina Zhurakhinskaya <marinaz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/message-tray: 17/32] messageTray: Correct idleness
- Date: Fri, 17 Aug 2012 01:38:22 +0000 (UTC)
commit ca68dee21e3b0b20fb0b183e8d6bf7593cddc4f5
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Fri Aug 10 18:54:33 2012 -0300
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.
js/ui/messageTray.js | 10 ++++++----
src/shell-idle-monitor.c | 14 ++++++++++++++
src/shell-idle-monitor.h | 2 ++
3 files changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index b6d67d5..07f5ee9 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -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,
@@ -1949,15 +1951,15 @@ const MessageTray = new Lang.Class({
this._idleMonitorWatchId = 0;
if (!userBecameIdle)
this._updateNotificationTimeout(2000);
- this._userActiveWhileNotificationShown = true;
+ this._userActiveWhileNotificationShown = !userBecameIdle;
this._updateState();
},
_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;
diff --git a/src/shell-idle-monitor.c b/src/shell-idle-monitor.c
index 592f477..0b07b4e 100644
--- a/src/shell-idle-monitor.c
+++ b/src/shell-idle-monitor.c
@@ -416,3 +416,17 @@ shell_idle_monitor_remove_watch (ShellIdleMonitor *monitor,
g_hash_table_remove (monitor->priv->watches,
GUINT_TO_POINTER (id));
}
+
+gboolean
+shell_idle_monitor_get_idletime (ShellIdleMonitor *monitor)
+{
+ XSyncValue value;
+ gint64 idletime;
+
+ if (!XSyncQueryCounter (monitor->priv->display, monitor->priv->counter, &value))
+ return FALSE;
+
+ idletime = _xsyncvalue_to_int64 (value);
+
+ return idletime;
+}
diff --git a/src/shell-idle-monitor.h b/src/shell-idle-monitor.h
index 2fcd082..09eb72f 100644
--- a/src/shell-idle-monitor.h
+++ b/src/shell-idle-monitor.h
@@ -67,6 +67,8 @@ guint shell_idle_monitor_add_watch (ShellIdleMonitor *mo
void shell_idle_monitor_remove_watch (ShellIdleMonitor *monitor,
guint id);
+gboolean shell_idle_monitor_get_idletime (ShellIdleMonitor *monitor);
+
G_END_DECLS
#endif /* __SHELL_IDLE_MONITOR_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]