[gnome-shell] magnifier: Use PointerWatcher to poll the mouse pointer



commit 8aed51180fe416a418e4c6d01a4af92639fb60cb
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Aug 30 16:19:32 2012 -0300

    magnifier: Use PointerWatcher to poll the mouse pointer
    
    This gives us a more efficient method to watch the mouse pointer.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=683073

 js/ui/magnifier.js |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)
---
diff --git a/js/ui/magnifier.js b/js/ui/magnifier.js
index 514dc07..4a144b2 100644
--- a/js/ui/magnifier.js
+++ b/js/ui/magnifier.js
@@ -12,7 +12,7 @@ const Signals = imports.signals;
 const Main = imports.ui.main;
 const MagnifierDBus = imports.ui.magnifierDBus;
 const Params = imports.misc.params;
-
+const PointerWatcher = imports.ui.pointerWatcher;
 
 const MOUSE_POLL_FREQUENCY = 50;
 const CROSSHAIRS_CLIP_SIZE = [100, 100];
@@ -136,11 +136,8 @@ const Magnifier = new Lang.Class({
      * Turn on mouse tracking, if not already doing so.
      */
     startTrackingMouse: function() {
-        if (!this._mouseTrackingId)
-            this._mouseTrackingId = Mainloop.timeout_add(
-                MOUSE_POLL_FREQUENCY,
-                Lang.bind(this, this.scrollToMousePos)
-            );
+        if (!this._pointerWatch)
+            this._pointerWatch = PointerWatcher.getPointerWatcher().addWatch(MOUSE_POLL_FREQUENCY, Lang.bind(this, this.scrollToMousePos));
     },
 
     /**
@@ -148,10 +145,10 @@ const Magnifier = new Lang.Class({
      * Turn off mouse tracking, if not already doing so.
      */
     stopTrackingMouse: function() {
-        if (this._mouseTrackingId)
-            Mainloop.source_remove(this._mouseTrackingId);
+        if (this._pointerWatch)
+            this._pointerWatch.remove();
 
-        this._mouseTrackingId = null;
+        this._pointerWatch = null;
     },
 
     /**



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]