Port to GnomeIdleMonitor

https://bugzilla.gnome.org/show_bug.cgi?id=682224
This commit is contained in:
Jasper St. Pierre
2012-08-20 00:06:50 -04:00
parent 418cf6281e
commit d106191e6a
7 changed files with 36 additions and 526 deletions

View File

@ -2,6 +2,7 @@
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const GnomeDesktop = imports.gi.GnomeDesktop;
const Shell = imports.gi.Shell;
// We stop polling if the user is idle for more than this amount of time
@ -40,9 +41,9 @@ const PointerWatcher = new Lang.Class({
Name: 'PointerWatcher',
_init: function() {
let idleMonitor = Shell.IdleMonitor.get();
idleMonitor.add_watch(IDLE_TIME,
Lang.bind(this, this._onIdleMonitorWatch));
let idleMonitor = new GnomeDesktop.IdleMonitor();
idleMonitor.connect('became-active', Lang.bind(this, this._onIdleMonitorBecameActive));
idleMonitor.add_watch(IDLE_TIME, Lang.bind(this, this._onIdleMonitorBecameIdle));
this._idle = idleMonitor.get_idletime() > IDLE_TIME;
this._watches = [];
this.pointerX = null;
@ -78,11 +79,14 @@ const PointerWatcher = new Lang.Class({
}
},
_onIdleMonitorWatch: function(monitor, id, userBecameIdle) {
this._idle = userBecameIdle;
if (!userBecameIdle)
this._updatePointer();
_onIdleMonitorBecameActive: function(monitor) {
this._idle = false;
this._updatePointer();
this._updateTimeout();
},
_onIdleMonitorBecameIdle: function(monitor) {
this._idle = true;
this._updateTimeout();
},