[gnome-shell] Replace ShellXFixesCursor with MetaCursorTracker



commit 2b8414a45325c44c3b9d7eb24b636d82e1b883f0
Author: Giovanni Campagna <gcampagn redhat com>
Date:   Tue Aug 13 14:22:22 2013 +0200

    Replace ShellXFixesCursor with MetaCursorTracker
    
    Mutter now includes an object with the same purpose and functionality
    as ShellXFixesCursor, so we can replace our XFixes code with it
    and work under wayland too.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=705911

 js/ui/magnifier.js        |   20 +-
 src/Makefile.am           |    4 +-
 src/shell-util.c          |   10 +
 src/shell-util.h          |    4 +
 src/shell-xfixes-cursor.c |  426 ---------------------------------------------
 src/shell-xfixes-cursor.h |   33 ----
 6 files changed, 25 insertions(+), 472 deletions(-)
---
diff --git a/js/ui/magnifier.js b/js/ui/magnifier.js
index f4c46e7..7c68ea8 100644
--- a/js/ui/magnifier.js
+++ b/js/ui/magnifier.js
@@ -7,6 +7,7 @@ const Shell = imports.gi.Shell;
 const St = imports.gi.St;
 const Lang = imports.lang;
 const Mainloop = imports.mainloop;
+const Meta = imports.gi.Meta;
 const Signals = imports.signals;
 
 const Main = imports.ui.main;
@@ -53,9 +54,9 @@ const Magnifier = new Lang.Class({
         this._zoomRegions = [];
 
         // Create small clutter tree for the magnified mouse.
-        let xfixesCursor = Shell.XFixesCursor.get_for_stage(global.stage);
+        let cursorTracker = Meta.CursorTracker.get_for_screen(global.screen);
         this._mouseSprite = new Clutter.Texture();
-        xfixesCursor.update_texture_image(this._mouseSprite);
+        Shell.util_cursor_tracker_to_clutter(cursorTracker, this._mouseSprite);
         this._cursorRoot = new Clutter.Actor();
         this._cursorRoot.add_actor(this._mouseSprite);
 
@@ -70,8 +71,8 @@ const Magnifier = new Lang.Class({
         let showAtLaunch = this._settingsInit(aZoomRegion);
         aZoomRegion.scrollContentsTo(this.xMouse, this.yMouse);
 
-        xfixesCursor.connect('cursor-change', Lang.bind(this, this._updateMouseSprite));
-        this._xfixesCursor = xfixesCursor;
+        cursorTracker.connect('cursor-changed', Lang.bind(this, this._updateMouseSprite));
+        this._cursorTracker = cursorTracker;
 
         // Export to dbus.
         magDBusService = new MagnifierDBus.ShellMagnifier();
@@ -83,7 +84,7 @@ const Magnifier = new Lang.Class({
      * Show the system mouse pointer.
      */
     showSystemCursor: function() {
-        this._xfixesCursor.show();
+        global.stage.show_cursor();
     },
 
     /**
@@ -91,7 +92,7 @@ const Magnifier = new Lang.Class({
      * Hide the system mouse pointer.
      */
     hideSystemCursor: function() {
-        this._xfixesCursor.hide();
+        global.stage.hide_cursor();
     },
 
     /**
@@ -112,7 +113,7 @@ const Magnifier = new Lang.Class({
         // Make sure system mouse pointer is shown when all zoom regions are
         // invisible.
         if (!activate)
-            this._xfixesCursor.show();
+            global.stage.show_cursor();
 
         // Notify interested parties of this change
         this.emit('active-changed', activate);
@@ -422,9 +423,8 @@ const Magnifier = new Lang.Class({
     //// Private methods ////
 
     _updateMouseSprite: function() {
-        this._xfixesCursor.update_texture_image(this._mouseSprite);
-        let xHot = this._xfixesCursor.get_hot_x();
-        let yHot = this._xfixesCursor.get_hot_y();
+        Shell.util_cursor_tracker_to_clutter(this._cursorTracker, this._mouseSprite);
+        let [xHot, yHot] = this._cursorTracker.get_hot();
         this._mouseSprite.set_anchor_point(xHot, yHot);
     },
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 13e0cbb..74c6c29 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -126,8 +126,7 @@ shell_public_headers_h =            \
        shell-tray-manager.h            \
        shell-util.h                    \
        shell-window-tracker.h          \
-       shell-wm.h                      \
-       shell-xfixes-cursor.h
+       shell-wm.h
 
 shell_private_sources =                \
        gtkactionmuxer.h                \
@@ -181,7 +180,6 @@ libgnome_shell_la_SOURCES =         \
        shell-util.c                    \
        shell-window-tracker.c          \
        shell-wm.c                      \
-       shell-xfixes-cursor.c           \
        $(NULL)
 
 libgnome_shell_la_gir_sources = \
diff --git a/src/shell-util.c b/src/shell-util.c
index 84adad9..92fc3da 100644
--- a/src/shell-util.c
+++ b/src/shell-util.c
@@ -431,3 +431,13 @@ shell_util_wake_up_screen (void)
   first_keycode = !first_keycode;
   gdk_error_trap_pop_ignored ();
 }
+
+void
+shell_util_cursor_tracker_to_clutter (MetaCursorTracker *tracker,
+                                      ClutterTexture    *texture)
+{
+  CoglTexture *sprite;
+
+  sprite = meta_cursor_tracker_get_sprite (tracker);
+  clutter_texture_set_cogl_texture (texture, sprite);
+}
diff --git a/src/shell-util.h b/src/shell-util.h
index 2d462c1..95271d0 100644
--- a/src/shell-util.h
+++ b/src/shell-util.h
@@ -7,6 +7,7 @@
 #include <clutter/clutter.h>
 #include <libsoup/soup.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
+#include <meta/meta-cursor-tracker.h>
 
 G_BEGIN_DECLS
 
@@ -46,6 +47,9 @@ GdkPixbuf *shell_util_create_pixbuf_from_data (const guchar      *data,
 
 void    shell_util_wake_up_screen             (void);
 
+void    shell_util_cursor_tracker_to_clutter (MetaCursorTracker *tracker,
+                                              ClutterTexture    *texture);
+
 G_END_DECLS
 
 #endif /* __SHELL_UTIL_H__ */


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