kathenas / rpms / mutter

Forked from rpms/mutter 5 years ago
Clone

Blame SOURCES/hw-cursor-on-demand-gnome-3-28.patch

776610
diff --git a/src/Makefile.am b/src/Makefile.am
776610
index bcb3505c7..5bbac70e8 100644
776610
--- a/src/Makefile.am
776610
+++ b/src/Makefile.am
776610
@@ -114,6 +114,8 @@ libmutter_@LIBMUTTER_API_VERSION@_la_SOURCES =	\
776610
 	backends/meta-cursor-tracker-private.h	\
776610
 	backends/meta-cursor-renderer.c		\
776610
 	backends/meta-cursor-renderer.h		\
776610
+	backends/meta-cursor-sprite-xcursor.c	\
776610
+	backends/meta-cursor-sprite-xcursor.h	\
776610
 	backends/meta-dnd-private.h		\
776610
 	backends/meta-egl.c			\
776610
 	backends/meta-egl.h			\
776610
@@ -176,6 +178,8 @@ libmutter_@LIBMUTTER_API_VERSION@_la_SOURCES =	\
776610
 	backends/x11/meta-gpu-xrandr.h			\
776610
 	backends/x11/cm/meta-backend-x11-cm.c		\
776610
 	backends/x11/cm/meta-backend-x11-cm.h		\
776610
+	backends/x11/cm/meta-cursor-sprite-xfixes.c	\
776610
+	backends/x11/cm/meta-cursor-sprite-xfixes.h	\
776610
 	backends/x11/cm/meta-renderer-x11-cm.c		\
776610
 	backends/x11/cm/meta-renderer-x11-cm.h		\
776610
 	backends/x11/nested/meta-backend-x11-nested.c	\
776610
@@ -370,6 +374,8 @@ if HAVE_WAYLAND
776610
 libmutter_@LIBMUTTER_API_VERSION@_la_SOURCES +=	\
776610
 	compositor/meta-surface-actor-wayland.c	\
776610
 	compositor/meta-surface-actor-wayland.h	\
776610
+	wayland/meta-cursor-sprite-wayland.c	\
776610
+	wayland/meta-cursor-sprite-wayland.h	\
776610
 	wayland/meta-wayland.c			\
776610
 	wayland/meta-wayland.h			\
776610
 	wayland/meta-wayland-private.h		\
776610
@@ -431,10 +437,10 @@ libmutter_@LIBMUTTER_API_VERSION@_la_SOURCES +=	\
776610
 	wayland/meta-wayland-touch.h		\
776610
 	wayland/meta-wayland-surface.c		\
776610
 	wayland/meta-wayland-surface.h		\
776610
-	wayland/meta-wayland-surface-role-cursor.c	\
776610
-	wayland/meta-wayland-surface-role-cursor.h	\
776610
-	wayland/meta-wayland-surface-role-tablet-cursor.c	\
776610
-	wayland/meta-wayland-surface-role-tablet-cursor.h	\
776610
+	wayland/meta-wayland-cursor-surface.c	\
776610
+	wayland/meta-wayland-cursor-surface.h	\
776610
+	wayland/meta-wayland-tablet-cursor-surface.c	\
776610
+	wayland/meta-wayland-tablet-cursor-surface.h	\
776610
 	wayland/meta-wayland-actor-surface.c	\
776610
 	wayland/meta-wayland-actor-surface.h	\
776610
 	wayland/meta-wayland-subsurface.c	\
776610
diff --git a/src/backends/meta-cursor-renderer.c b/src/backends/meta-cursor-renderer.c
776610
index f6470e66a..eb79737f1 100644
776610
--- a/src/backends/meta-cursor-renderer.c
776610
+++ b/src/backends/meta-cursor-renderer.c
776610
@@ -193,8 +193,8 @@ meta_cursor_renderer_calculate_rect (MetaCursorRenderer *renderer,
776610
 }
776610
 
776610
 static void
776610
-update_cursor (MetaCursorRenderer *renderer,
776610
-               MetaCursorSprite   *cursor_sprite)
776610
+meta_cursor_renderer_update_cursor (MetaCursorRenderer *renderer,
776610
+                                    MetaCursorSprite   *cursor_sprite)
776610
 {
776610
   MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);
776610
   gboolean handled_by_backend;
776610
@@ -237,7 +237,7 @@ meta_cursor_renderer_set_cursor (MetaCursorRenderer *renderer,
776610
     return;
776610
   priv->displayed_cursor = cursor_sprite;
776610
 
776610
-  update_cursor (renderer, cursor_sprite);
776610
+  meta_cursor_renderer_update_cursor (renderer, cursor_sprite);
776610
 }
776610
 
776610
 void
776610
@@ -246,7 +246,7 @@ meta_cursor_renderer_force_update (MetaCursorRenderer *renderer)
776610
   MetaCursorRendererPrivate *priv =
776610
     meta_cursor_renderer_get_instance_private (renderer);
776610
 
776610
-  update_cursor (renderer, priv->displayed_cursor);
776610
+  meta_cursor_renderer_update_cursor (renderer, priv->displayed_cursor);
776610
 }
776610
 
776610
 void
776610
@@ -261,7 +261,7 @@ meta_cursor_renderer_set_position (MetaCursorRenderer *renderer,
776610
   priv->current_x = x;
776610
   priv->current_y = y;
776610
 
776610
-  update_cursor (renderer, priv->displayed_cursor);
776610
+  meta_cursor_renderer_update_cursor (renderer, priv->displayed_cursor);
776610
 }
776610
 
776610
 ClutterPoint
776610
@@ -283,28 +283,3 @@ meta_cursor_renderer_get_cursor (MetaCursorRenderer *renderer)
776610
 
776610
   return priv->displayed_cursor;
776610
 }
776610
-
776610
-#ifdef HAVE_WAYLAND
776610
-void
776610
-meta_cursor_renderer_realize_cursor_from_wl_buffer (MetaCursorRenderer *renderer,
776610
-                                                    MetaCursorSprite   *cursor_sprite,
776610
-                                                    struct wl_resource *buffer)
776610
-{
776610
-
776610
-  MetaCursorRendererClass *renderer_class = META_CURSOR_RENDERER_GET_CLASS (renderer);
776610
-
776610
-  if (renderer_class->realize_cursor_from_wl_buffer)
776610
-    renderer_class->realize_cursor_from_wl_buffer (renderer, cursor_sprite, buffer);
776610
-}
776610
-#endif
776610
-
776610
-void
776610
-meta_cursor_renderer_realize_cursor_from_xcursor (MetaCursorRenderer *renderer,
776610
-                                                  MetaCursorSprite   *cursor_sprite,
776610
-                                                  XcursorImage       *xc_image)
776610
-{
776610
-  MetaCursorRendererClass *renderer_class = META_CURSOR_RENDERER_GET_CLASS (renderer);
776610
-
776610
-  if (renderer_class->realize_cursor_from_xcursor)
776610
-    renderer_class->realize_cursor_from_xcursor (renderer, cursor_sprite, xc_image);
776610
-}
776610
diff --git a/src/backends/meta-cursor-renderer.h b/src/backends/meta-cursor-renderer.h
776610
index 1691f4471..830d16ef6 100644
776610
--- a/src/backends/meta-cursor-renderer.h
776610
+++ b/src/backends/meta-cursor-renderer.h
776610
@@ -26,10 +26,6 @@
776610
 #define META_CURSOR_RENDERER_H
776610
 
776610
 #include <glib-object.h>
776610
-#include <X11/Xcursor/Xcursor.h>
776610
-#ifdef HAVE_WAYLAND
776610
-#include <wayland-server.h>
776610
-#endif
776610
 
776610
 #include <meta/screen.h>
776610
 #include "meta-cursor.h"
776610
@@ -44,14 +40,6 @@ struct _MetaCursorRendererClass
776610
 
776610
   gboolean (* update_cursor) (MetaCursorRenderer *renderer,
776610
                               MetaCursorSprite   *cursor_sprite);
776610
-#ifdef HAVE_WAYLAND
776610
-  void (* realize_cursor_from_wl_buffer) (MetaCursorRenderer *renderer,
776610
-                                          MetaCursorSprite *cursor_sprite,
776610
-                                          struct wl_resource *buffer);
776610
-#endif
776610
-  void (* realize_cursor_from_xcursor) (MetaCursorRenderer *renderer,
776610
-                                        MetaCursorSprite *cursor_sprite,
776610
-                                        XcursorImage *xc_image);
776610
 };
776610
 
776610
 MetaCursorRenderer * meta_cursor_renderer_new (void);
776610
@@ -70,16 +58,6 @@ MetaCursorSprite * meta_cursor_renderer_get_cursor (MetaCursorRenderer *renderer
776610
 ClutterRect meta_cursor_renderer_calculate_rect (MetaCursorRenderer *renderer,
776610
                                                  MetaCursorSprite   *cursor_sprite);
776610
 
776610
-#ifdef HAVE_WAYLAND
776610
-void meta_cursor_renderer_realize_cursor_from_wl_buffer (MetaCursorRenderer *renderer,
776610
-                                                         MetaCursorSprite   *cursor_sprite,
776610
-                                                         struct wl_resource *buffer);
776610
-#endif
776610
-
776610
-void meta_cursor_renderer_realize_cursor_from_xcursor (MetaCursorRenderer *renderer,
776610
-                                                       MetaCursorSprite   *cursor_sprite,
776610
-                                                       XcursorImage       *xc_image);
776610
-
776610
 void meta_cursor_renderer_emit_painted (MetaCursorRenderer *renderer,
776610
                                         MetaCursorSprite   *cursor_sprite);
776610
 
776610
diff --git a/src/backends/meta-cursor-sprite-xcursor.c b/src/backends/meta-cursor-sprite-xcursor.c
776610
new file mode 100644
776610
index 000000000..657c1dae8
776610
--- /dev/null
776610
+++ b/src/backends/meta-cursor-sprite-xcursor.c
776610
@@ -0,0 +1,292 @@
776610
+/*
776610
+ * Copyright 2013, 2018 Red Hat, Inc.
776610
+ *
776610
+ * This program is free software; you can redistribute it and/or
776610
+ * modify it under the terms of the GNU General Public License as
776610
+ * published by the Free Software Foundation; either version 2 of the
776610
+ * License, or (at your option) any later version.
776610
+ *
776610
+ * This program is distributed in the hope that it will be useful, but
776610
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
776610
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
776610
+ * General Public License for more details.
776610
+ *
776610
+ * You should have received a copy of the GNU General Public License
776610
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
776610
+ *
776610
+ */
776610
+
776610
+#include "config.h"
776610
+
776610
+#include "backends/meta-cursor-sprite-xcursor.h"
776610
+
776610
+#include "backends/meta-cursor.h"
776610
+#include "backends/meta-cursor-renderer.h"
776610
+#include "clutter/clutter.h"
776610
+#include "cogl/cogl.h"
776610
+#include "meta/prefs.h"
776610
+
776610
+struct _MetaCursorSpriteXcursor
776610
+{
776610
+  MetaCursorSprite parent;
776610
+
776610
+  MetaCursor cursor;
776610
+
776610
+  int current_frame;
776610
+  XcursorImages *xcursor_images;
776610
+
776610
+  int theme_scale;
776610
+  gboolean theme_dirty;
776610
+};
776610
+
776610
+G_DEFINE_TYPE (MetaCursorSpriteXcursor, meta_cursor_sprite_xcursor,
776610
+               META_TYPE_CURSOR_SPRITE)
776610
+
776610
+static const char *
776610
+translate_meta_cursor (MetaCursor cursor)
776610
+{
776610
+  switch (cursor)
776610
+    {
776610
+    case META_CURSOR_DEFAULT:
776610
+      return "left_ptr";
776610
+    case META_CURSOR_NORTH_RESIZE:
776610
+      return "top_side";
776610
+    case META_CURSOR_SOUTH_RESIZE:
776610
+      return "bottom_side";
776610
+    case META_CURSOR_WEST_RESIZE:
776610
+      return "left_side";
776610
+    case META_CURSOR_EAST_RESIZE:
776610
+      return "right_side";
776610
+    case META_CURSOR_SE_RESIZE:
776610
+      return "bottom_right_corner";
776610
+    case META_CURSOR_SW_RESIZE:
776610
+      return "bottom_left_corner";
776610
+    case META_CURSOR_NE_RESIZE:
776610
+      return "top_right_corner";
776610
+    case META_CURSOR_NW_RESIZE:
776610
+      return "top_left_corner";
776610
+    case META_CURSOR_MOVE_OR_RESIZE_WINDOW:
776610
+      return "fleur";
776610
+    case META_CURSOR_BUSY:
776610
+      return "watch";
776610
+    case META_CURSOR_DND_IN_DRAG:
776610
+      return "dnd-none";
776610
+    case META_CURSOR_DND_MOVE:
776610
+      return "dnd-move";
776610
+    case META_CURSOR_DND_COPY:
776610
+      return "dnd-copy";
776610
+    case META_CURSOR_DND_UNSUPPORTED_TARGET:
776610
+      return "dnd-none";
776610
+    case META_CURSOR_POINTING_HAND:
776610
+      return "hand2";
776610
+    case META_CURSOR_CROSSHAIR:
776610
+      return "crosshair";
776610
+    case META_CURSOR_IBEAM:
776610
+      return "xterm";
776610
+    default:
776610
+      break;
776610
+    }
776610
+
776610
+  g_assert_not_reached ();
776610
+}
776610
+
776610
+MetaCursor
776610
+meta_cursor_sprite_xcursor_get_cursor (MetaCursorSpriteXcursor *sprite_xcursor)
776610
+{
776610
+  return sprite_xcursor->cursor;
776610
+}
776610
+
776610
+Cursor
776610
+meta_create_x_cursor (Display    *xdisplay,
776610
+                      MetaCursor  cursor)
776610
+{
776610
+  return XcursorLibraryLoadCursor (xdisplay, translate_meta_cursor (cursor));
776610
+}
776610
+
776610
+static XcursorImages *
776610
+load_cursor_on_client (MetaCursor cursor, int scale)
776610
+{
776610
+  return XcursorLibraryLoadImages (translate_meta_cursor (cursor),
776610
+                                   meta_prefs_get_cursor_theme (),
776610
+                                   meta_prefs_get_cursor_size () * scale);
776610
+}
776610
+
776610
+static void
776610
+load_from_current_xcursor_image (MetaCursorSpriteXcursor *sprite_xcursor)
776610
+{
776610
+  MetaCursorSprite *sprite = META_CURSOR_SPRITE (sprite_xcursor);
776610
+  XcursorImage *xc_image;
776610
+  int width, height, rowstride;
776610
+  CoglPixelFormat cogl_format;
776610
+  ClutterBackend *clutter_backend;
776610
+  CoglContext *cogl_context;
776610
+  CoglTexture2D *texture;
776610
+  CoglError *error = NULL;
776610
+
776610
+  g_assert (!meta_cursor_sprite_get_cogl_texture (sprite));
776610
+
776610
+  xc_image = meta_cursor_sprite_xcursor_get_current_image (sprite_xcursor);
776610
+  width = (int) xc_image->width;
776610
+  height = (int) xc_image->height;
776610
+  rowstride = width * 4;
776610
+
776610
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
776610
+  cogl_format = COGL_PIXEL_FORMAT_BGRA_8888;
776610
+#else
776610
+  cogl_format = COGL_PIXEL_FORMAT_ARGB_8888;
776610
+#endif
776610
+
776610
+  clutter_backend = clutter_get_default_backend ();
776610
+  cogl_context = clutter_backend_get_cogl_context (clutter_backend);
776610
+  texture = cogl_texture_2d_new_from_data (cogl_context,
776610
+                                           width, height,
776610
+                                           cogl_format,
776610
+                                           rowstride,
776610
+                                           (uint8_t *) xc_image->pixels,
776610
+                                           &error);
776610
+  if (!texture)
776610
+    {
776610
+      g_warning ("Failed to allocate cursor texture: %s\n", error->message);
776610
+      cogl_error_free (error);
776610
+    }
776610
+
776610
+  meta_cursor_sprite_set_texture (sprite,
776610
+                                  COGL_TEXTURE (texture),
776610
+                                  xc_image->xhot, xc_image->yhot);
776610
+
776610
+  if (texture)
776610
+    cogl_object_unref (texture);
776610
+}
776610
+
776610
+void
776610
+meta_cursor_sprite_xcursor_set_theme_scale (MetaCursorSpriteXcursor *sprite_xcursor,
776610
+                                            int                      theme_scale)
776610
+{
776610
+  if (sprite_xcursor->theme_scale != theme_scale)
776610
+    sprite_xcursor->theme_dirty = TRUE;
776610
+  sprite_xcursor->theme_scale = theme_scale;
776610
+}
776610
+
776610
+
776610
+static gboolean
776610
+meta_cursor_sprite_xcursor_is_animated (MetaCursorSprite *sprite)
776610
+{
776610
+  MetaCursorSpriteXcursor *sprite_xcursor = META_CURSOR_SPRITE_XCURSOR (sprite);
776610
+
776610
+  return (sprite_xcursor->xcursor_images &&
776610
+          sprite_xcursor->xcursor_images->nimage > 1);
776610
+}
776610
+
776610
+XcursorImage *
776610
+meta_cursor_sprite_xcursor_get_current_image (MetaCursorSpriteXcursor *sprite_xcursor)
776610
+{
776610
+  return sprite_xcursor->xcursor_images->images[sprite_xcursor->current_frame];
776610
+}
776610
+
776610
+static void
776610
+meta_cursor_sprite_xcursor_tick_frame (MetaCursorSprite *sprite)
776610
+{
776610
+  MetaCursorSpriteXcursor *sprite_xcursor = META_CURSOR_SPRITE_XCURSOR (sprite);
776610
+
776610
+  if (!meta_cursor_sprite_is_animated (sprite))
776610
+    return;
776610
+
776610
+  sprite_xcursor->current_frame++;
776610
+
776610
+  if (sprite_xcursor->current_frame >= sprite_xcursor->xcursor_images->nimage)
776610
+    sprite_xcursor->current_frame = 0;
776610
+
776610
+  meta_cursor_sprite_clear_texture (sprite);
776610
+  load_from_current_xcursor_image (sprite_xcursor);
776610
+}
776610
+
776610
+static unsigned int
776610
+meta_cursor_sprite_xcursor_get_current_frame_time (MetaCursorSprite *sprite)
776610
+{
776610
+  MetaCursorSpriteXcursor *sprite_xcursor = META_CURSOR_SPRITE_XCURSOR (sprite);
776610
+  XcursorImages *xcursor_images;
776610
+
776610
+  g_return_val_if_fail (meta_cursor_sprite_is_animated (sprite), 0);
776610
+
776610
+  xcursor_images = sprite_xcursor->xcursor_images;
776610
+  return xcursor_images->images[sprite_xcursor->current_frame]->delay;
776610
+}
776610
+
776610
+static void
776610
+load_cursor_from_theme (MetaCursorSprite *sprite)
776610
+{
776610
+  MetaCursorSpriteXcursor *sprite_xcursor = META_CURSOR_SPRITE_XCURSOR (sprite);
776610
+
776610
+  g_assert (sprite_xcursor->cursor != META_CURSOR_NONE);
776610
+
776610
+  sprite_xcursor->theme_dirty = FALSE;
776610
+
776610
+  /* We might be reloading with a different scale. If so clear the old data. */
776610
+  if (sprite_xcursor->xcursor_images)
776610
+    {
776610
+      meta_cursor_sprite_clear_texture (sprite);
776610
+      XcursorImagesDestroy (sprite_xcursor->xcursor_images);
776610
+    }
776610
+
776610
+  sprite_xcursor->current_frame = 0;
776610
+  sprite_xcursor->xcursor_images =
776610
+    load_cursor_on_client (sprite_xcursor->cursor,
776610
+                           sprite_xcursor->theme_scale);
776610
+  if (!sprite_xcursor->xcursor_images)
776610
+    g_error ("Could not find cursor. Perhaps set XCURSOR_PATH?");
776610
+
776610
+  load_from_current_xcursor_image (sprite_xcursor);
776610
+}
776610
+
776610
+static void
776610
+meta_cursor_sprite_xcursor_realize_texture (MetaCursorSprite *sprite)
776610
+{
776610
+  MetaCursorSpriteXcursor *sprite_xcursor = META_CURSOR_SPRITE_XCURSOR (sprite);
776610
+
776610
+  if (sprite_xcursor->theme_dirty)
776610
+    load_cursor_from_theme (sprite);
776610
+}
776610
+
776610
+MetaCursorSpriteXcursor *
776610
+meta_cursor_sprite_xcursor_new (MetaCursor cursor)
776610
+{
776610
+  MetaCursorSpriteXcursor *sprite_xcursor;
776610
+
776610
+  sprite_xcursor = g_object_new (META_TYPE_CURSOR_SPRITE_XCURSOR, NULL);
776610
+  sprite_xcursor->cursor = cursor;
776610
+
776610
+  return sprite_xcursor;
776610
+}
776610
+
776610
+static void
776610
+meta_cursor_sprite_xcursor_finalize (GObject *object)
776610
+{
776610
+  MetaCursorSpriteXcursor *sprite_xcursor = META_CURSOR_SPRITE_XCURSOR (object);
776610
+
776610
+  g_clear_pointer (&sprite_xcursor->xcursor_images,
776610
+                   XcursorImagesDestroy);
776610
+
776610
+  G_OBJECT_CLASS (meta_cursor_sprite_xcursor_parent_class)->finalize (object);
776610
+}
776610
+
776610
+static void
776610
+meta_cursor_sprite_xcursor_init (MetaCursorSpriteXcursor *sprite_xcursor)
776610
+{
776610
+  sprite_xcursor->theme_dirty = TRUE;
776610
+}
776610
+
776610
+static void
776610
+meta_cursor_sprite_xcursor_class_init (MetaCursorSpriteXcursorClass *klass)
776610
+{
776610
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
776610
+  MetaCursorSpriteClass *cursor_sprite_class = META_CURSOR_SPRITE_CLASS (klass);
776610
+
776610
+  object_class->finalize = meta_cursor_sprite_xcursor_finalize;
776610
+
776610
+  cursor_sprite_class->realize_texture =
776610
+    meta_cursor_sprite_xcursor_realize_texture;
776610
+  cursor_sprite_class->is_animated = meta_cursor_sprite_xcursor_is_animated;
776610
+  cursor_sprite_class->tick_frame = meta_cursor_sprite_xcursor_tick_frame;
776610
+  cursor_sprite_class->get_current_frame_time =
776610
+    meta_cursor_sprite_xcursor_get_current_frame_time;
776610
+}
776610
diff --git a/src/backends/meta-cursor-sprite-xcursor.h b/src/backends/meta-cursor-sprite-xcursor.h
776610
new file mode 100644
776610
index 000000000..dbc927484
776610
--- /dev/null
776610
+++ b/src/backends/meta-cursor-sprite-xcursor.h
776610
@@ -0,0 +1,43 @@
776610
+/*
776610
+ * Copyright 2013, 2018 Red Hat, Inc.
776610
+ *
776610
+ * This program is free software; you can redistribute it and/or
776610
+ * modify it under the terms of the GNU General Public License as
776610
+ * published by the Free Software Foundation; either version 2 of the
776610
+ * License, or (at your option) any later version.
776610
+ *
776610
+ * This program is distributed in the hope that it will be useful, but
776610
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
776610
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
776610
+ * General Public License for more details.
776610
+ *
776610
+ * You should have received a copy of the GNU General Public License
776610
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
776610
+ *
776610
+ */
776610
+
776610
+#ifndef META_CURSOR_SPRITE_XCURSOR_H
776610
+#define META_CURSOR_SPRITE_XCURSOR_H
776610
+
776610
+#include <glib-object.h>
776610
+#include <X11/Xcursor/Xcursor.h>
776610
+
776610
+#include "backends/meta-cursor.h"
776610
+
776610
+#define META_TYPE_CURSOR_SPRITE_XCURSOR meta_cursor_sprite_xcursor_get_type ()
776610
+G_DECLARE_FINAL_TYPE (MetaCursorSpriteXcursor, meta_cursor_sprite_xcursor,
776610
+                      META, CURSOR_SPRITE_XCURSOR, MetaCursorSprite)
776610
+
776610
+MetaCursorSpriteXcursor * meta_cursor_sprite_xcursor_new (MetaCursor cursor);
776610
+
776610
+void meta_cursor_sprite_xcursor_set_theme_scale (MetaCursorSpriteXcursor *sprite_xcursor,
776610
+                                                 int                      scale);
776610
+
776610
+MetaCursor meta_cursor_sprite_xcursor_get_cursor (MetaCursorSpriteXcursor *sprite_xcusror);
776610
+
776610
+XcursorImage * meta_cursor_sprite_xcursor_get_current_image (MetaCursorSpriteXcursor *sprite_xcursor);
776610
+
776610
+Cursor meta_create_x_cursor (Display    *xdisplay,
776610
+                             MetaCursor  cursor);
776610
+
776610
+#endif /* META_CURSOR_SPRITE_XCURSOR_H */
776610
diff --git a/src/backends/meta-cursor-tracker-private.h b/src/backends/meta-cursor-tracker-private.h
776610
index 2ec946847..6f4f84b83 100644
776610
--- a/src/backends/meta-cursor-tracker-private.h
776610
+++ b/src/backends/meta-cursor-tracker-private.h
776610
@@ -26,6 +26,7 @@
776610
 
776610
 #include "meta-cursor.h"
776610
 #include "meta-cursor-renderer.h"
776610
+#include "backends/x11/cm/meta-cursor-sprite-xfixes.h"
776610
 
776610
 struct _MetaCursorTracker {
776610
   GObject parent_instance;
776610
@@ -46,7 +47,7 @@ struct _MetaCursorTracker {
776610
   MetaCursorSprite *root_cursor;
776610
 
776610
   /* The cursor from the X11 server. */
776610
-  MetaCursorSprite *xfixes_cursor;
776610
+  MetaCursorSpriteXfixes *xfixes_cursor;
776610
 };
776610
 
776610
 struct _MetaCursorTrackerClass {
776610
diff --git a/src/backends/meta-cursor-tracker.c b/src/backends/meta-cursor-tracker.c
776610
index 74fa4351d..6244f11ee 100644
776610
--- a/src/backends/meta-cursor-tracker.c
776610
+++ b/src/backends/meta-cursor-tracker.c
776610
@@ -40,9 +40,9 @@
776610
 
776610
 #include <gdk/gdk.h>
776610
 #include <gdk/gdkx.h>
776610
-#include <X11/extensions/Xfixes.h>
776610
 
776610
 #include "meta-backend-private.h"
776610
+#include "backends/x11/cm/meta-cursor-sprite-xfixes.h"
776610
 
776610
 G_DEFINE_TYPE (MetaCursorTracker, meta_cursor_tracker, G_TYPE_OBJECT);
776610
 
776610
@@ -218,75 +218,14 @@ static void
776610
 ensure_xfixes_cursor (MetaCursorTracker *tracker)
776610
 {
776610
   MetaDisplay *display = meta_get_display ();
776610
-  XFixesCursorImage *cursor_image;
776610
-  CoglTexture2D *sprite;
776610
-  guint8 *cursor_data;
776610
-  gboolean free_cursor_data;
776610
-  CoglContext *ctx;
776610
-  CoglError *error = NULL;
776610
+  g_autoptr (GError) error = NULL;
776610
 
776610
   if (tracker->xfixes_cursor)
776610
     return;
776610
 
776610
-  cursor_image = XFixesGetCursorImage (display->xdisplay);
776610
-  if (!cursor_image)
776610
-    return;
776610
-
776610
-  /* Like all X APIs, XFixesGetCursorImage() returns arrays of 32-bit
776610
-   * quantities as arrays of long; we need to convert on 64 bit */
776610
-  if (sizeof(long) == 4)
776610
-    {
776610
-      cursor_data = (guint8 *)cursor_image->pixels;
776610
-      free_cursor_data = FALSE;
776610
-    }
776610
-  else
776610
-    {
776610
-      int i, j;
776610
-      guint32 *cursor_words;
776610
-      gulong *p;
776610
-      guint32 *q;
776610
-
776610
-      cursor_words = g_new (guint32, cursor_image->width * cursor_image->height);
776610
-      cursor_data = (guint8 *)cursor_words;
776610
-
776610
-      p = cursor_image->pixels;
776610
-      q = cursor_words;
776610
-      for (j = 0; j < cursor_image->height; j++)
776610
-        for (i = 0; i < cursor_image->width; i++)
776610
-          *(q++) = *(p++);
776610
-
776610
-      free_cursor_data = TRUE;
776610
-    }
776610
-
776610
-  ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());
776610
-  sprite = cogl_texture_2d_new_from_data (ctx,
776610
-                                          cursor_image->width,
776610
-                                          cursor_image->height,
776610
-                                          CLUTTER_CAIRO_FORMAT_ARGB32,
776610
-                                          cursor_image->width * 4, /* stride */
776610
-                                          cursor_data,
776610
-                                          &error);
776610
-
776610
-  if (free_cursor_data)
776610
-    g_free (cursor_data);
776610
-
776610
-  if (error != NULL)
776610
-    {
776610
-      meta_warning ("Failed to allocate cursor sprite texture: %s\n", error->message);
776610
-      cogl_error_free (error);
776610
-    }
776610
-
776610
-  if (sprite != NULL)
776610
-    {
776610
-      MetaCursorSprite *cursor_sprite = meta_cursor_sprite_new ();
776610
-      meta_cursor_sprite_set_texture (cursor_sprite,
776610
-                                      COGL_TEXTURE (sprite),
776610
-                                      cursor_image->xhot,
776610
-                                      cursor_image->yhot);
776610
-      cogl_object_unref (sprite);
776610
-      tracker->xfixes_cursor = cursor_sprite;
776610
-    }
776610
-  XFree (cursor_image);
776610
+  tracker->xfixes_cursor = meta_cursor_sprite_xfixes_new (display, &error);
776610
+  if (!tracker->xfixes_cursor)
776610
+    g_warning ("Failed to create XFIXES cursor: %s", error->message);
776610
 }
776610
 
776610
 /**
776610
@@ -308,7 +247,7 @@ meta_cursor_tracker_get_sprite (MetaCursorTracker *tracker)
776610
   else
776610
     {
776610
       ensure_xfixes_cursor (tracker);
776610
-      cursor_sprite = tracker->xfixes_cursor;
776610
+      cursor_sprite = META_CURSOR_SPRITE (tracker->xfixes_cursor);
776610
     }
776610
 
776610
   if (cursor_sprite)
776610
@@ -345,7 +284,7 @@ meta_cursor_tracker_get_hot (MetaCursorTracker *tracker,
776610
   else
776610
     {
776610
       ensure_xfixes_cursor (tracker);
776610
-      cursor_sprite = tracker->xfixes_cursor;
776610
+      cursor_sprite = META_CURSOR_SPRITE (tracker->xfixes_cursor);
776610
     }
776610
 
776610
   if (cursor_sprite)
776610
diff --git a/src/backends/meta-cursor.c b/src/backends/meta-cursor.c
776610
index beeee765b..9750dc00b 100644
776610
--- a/src/backends/meta-cursor.c
776610
+++ b/src/backends/meta-cursor.c
776610
@@ -23,19 +23,12 @@
776610
 
776610
 #include "meta-cursor.h"
776610
 
776610
-#include <meta/errors.h>
776610
+#include "backends/meta-backend-private.h"
776610
+#include "cogl/cogl.h"
776610
+#include "meta/common.h"
776610
 
776610
-#include "display-private.h"
776610
-#include "screen-private.h"
776610
-#include "meta-backend-private.h"
776610
-
776610
-#include <string.h>
776610
-
776610
-#include <X11/cursorfont.h>
776610
-#include <X11/extensions/Xfixes.h>
776610
-#include <X11/Xcursor/Xcursor.h>
776610
-
776610
-enum {
776610
+enum
776610
+{
776610
   PREPARE_AT,
776610
   TEXTURE_CHANGED,
776610
 
776610
@@ -44,316 +37,148 @@ enum {
776610
 
776610
 static guint signals[LAST_SIGNAL];
776610
 
776610
-struct _MetaCursorSprite
776610
+typedef struct _MetaCursorSpritePrivate
776610
 {
776610
   GObject parent;
776610
 
776610
-  MetaCursor cursor;
776610
-
776610
   CoglTexture2D *texture;
776610
   float texture_scale;
776610
   int hot_x, hot_y;
776610
+} MetaCursorSpritePrivate;
776610
 
776610
-  int current_frame;
776610
-  XcursorImages *xcursor_images;
776610
-
776610
-  int theme_scale;
776610
-  gboolean theme_dirty;
776610
-};
776610
-
776610
-G_DEFINE_TYPE (MetaCursorSprite, meta_cursor_sprite, G_TYPE_OBJECT)
776610
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MetaCursorSprite,
776610
+                                     meta_cursor_sprite,
776610
+                                     G_TYPE_OBJECT)
776610
 
776610
-static const char *
776610
-translate_meta_cursor (MetaCursor cursor)
776610
-{
776610
-  switch (cursor)
776610
-    {
776610
-    case META_CURSOR_DEFAULT:
776610
-      return "left_ptr";
776610
-    case META_CURSOR_NORTH_RESIZE:
776610
-      return "top_side";
776610
-    case META_CURSOR_SOUTH_RESIZE:
776610
-      return "bottom_side";
776610
-    case META_CURSOR_WEST_RESIZE:
776610
-      return "left_side";
776610
-    case META_CURSOR_EAST_RESIZE:
776610
-      return "right_side";
776610
-    case META_CURSOR_SE_RESIZE:
776610
-      return "bottom_right_corner";
776610
-    case META_CURSOR_SW_RESIZE:
776610
-      return "bottom_left_corner";
776610
-    case META_CURSOR_NE_RESIZE:
776610
-      return "top_right_corner";
776610
-    case META_CURSOR_NW_RESIZE:
776610
-      return "top_left_corner";
776610
-    case META_CURSOR_MOVE_OR_RESIZE_WINDOW:
776610
-      return "fleur";
776610
-    case META_CURSOR_BUSY:
776610
-      return "watch";
776610
-    case META_CURSOR_DND_IN_DRAG:
776610
-      return "dnd-none";
776610
-    case META_CURSOR_DND_MOVE:
776610
-      return "dnd-move";
776610
-    case META_CURSOR_DND_COPY:
776610
-      return "dnd-copy";
776610
-    case META_CURSOR_DND_UNSUPPORTED_TARGET:
776610
-      return "dnd-none";
776610
-    case META_CURSOR_POINTING_HAND:
776610
-      return "hand2";
776610
-    case META_CURSOR_CROSSHAIR:
776610
-      return "crosshair";
776610
-    case META_CURSOR_IBEAM:
776610
-      return "xterm";
776610
-    default:
776610
-      break;
776610
-    }
776610
-
776610
-  g_assert_not_reached ();
776610
-}
776610
-
776610
-Cursor
776610
-meta_cursor_create_x_cursor (Display    *xdisplay,
776610
-                             MetaCursor  cursor)
776610
-{
776610
-  return XcursorLibraryLoadCursor (xdisplay, translate_meta_cursor (cursor));
776610
-}
776610
-
776610
-static XcursorImages *
776610
-load_cursor_on_client (MetaCursor cursor, int scale)
776610
-{
776610
-  return XcursorLibraryLoadImages (translate_meta_cursor (cursor),
776610
-                                   meta_prefs_get_cursor_theme (),
776610
-                                   meta_prefs_get_cursor_size () * scale);
776610
-}
776610
-
776610
-static void
776610
-meta_cursor_sprite_load_from_xcursor_image (MetaCursorSprite *self,
776610
-                                            XcursorImage     *xc_image)
776610
+gboolean
776610
+meta_cursor_sprite_is_animated (MetaCursorSprite *sprite)
776610
 {
776610
-  MetaBackend *meta_backend = meta_get_backend ();
776610
-  MetaCursorRenderer *renderer = meta_backend_get_cursor_renderer (meta_backend);
776610
-  uint width, height, rowstride;
776610
-  CoglPixelFormat cogl_format;
776610
-  ClutterBackend *clutter_backend;
776610
-  CoglContext *cogl_context;
776610
-  CoglTexture2D *texture;
776610
-  CoglError *error = NULL;
776610
-
776610
-  g_assert (self->texture == NULL);
776610
-
776610
-  width           = xc_image->width;
776610
-  height          = xc_image->height;
776610
-  rowstride       = width * 4;
776610
-
776610
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
776610
-  cogl_format = COGL_PIXEL_FORMAT_BGRA_8888;
776610
-#else
776610
-  cogl_format = COGL_PIXEL_FORMAT_ARGB_8888;
776610
-#endif
776610
-
776610
-  clutter_backend = clutter_get_default_backend ();
776610
-  cogl_context = clutter_backend_get_cogl_context (clutter_backend);
776610
-  texture = cogl_texture_2d_new_from_data (cogl_context,
776610
-                                           width, height,
776610
-                                           cogl_format,
776610
-                                           rowstride,
776610
-                                           (uint8_t *) xc_image->pixels,
776610
-                                           &error);
776610
-
776610
-  if (error)
776610
-    {
776610
-      meta_warning ("Failed to allocate cursor texture: %s\n", error->message);
776610
-      cogl_error_free (error);
776610
-    }
776610
-
776610
-  meta_cursor_sprite_set_texture (self, COGL_TEXTURE (texture),
776610
-                                  xc_image->xhot, xc_image->yhot);
776610
+  MetaCursorSpriteClass *klass = META_CURSOR_SPRITE_GET_CLASS (sprite);
776610
 
776610
-  if (texture)
776610
-    cogl_object_unref (texture);
776610
-
776610
-  meta_cursor_renderer_realize_cursor_from_xcursor (renderer, self, xc_image);
776610
-}
776610
-
776610
-static XcursorImage *
776610
-meta_cursor_sprite_get_current_frame_image (MetaCursorSprite *self)
776610
-{
776610
-  return self->xcursor_images->images[self->current_frame];
776610
+  if (klass->is_animated)
776610
+    return klass->is_animated (sprite);
776610
+  else
776610
+    return FALSE;
776610
 }
776610
 
776610
 void
776610
-meta_cursor_sprite_tick_frame (MetaCursorSprite *self)
776610
-{
776610
-  XcursorImage *image;
776610
-
776610
-  if (!meta_cursor_sprite_is_animated (self))
776610
-    return;
776610
-
776610
-  self->current_frame++;
776610
-
776610
-  if (self->current_frame >= self->xcursor_images->nimage)
776610
-    self->current_frame = 0;
776610
-
776610
-  image = meta_cursor_sprite_get_current_frame_image (self);
776610
-
776610
-  g_clear_pointer (&self->texture, cogl_object_unref);
776610
-  meta_cursor_sprite_load_from_xcursor_image (self, image);
776610
-}
776610
-
776610
-guint
776610
-meta_cursor_sprite_get_current_frame_time (MetaCursorSprite *self)
776610
-{
776610
-  if (!meta_cursor_sprite_is_animated (self))
776610
-    return 0;
776610
-
776610
-  return self->xcursor_images->images[self->current_frame]->delay;
776610
-}
776610
-
776610
-gboolean
776610
-meta_cursor_sprite_is_animated (MetaCursorSprite *self)
776610
+meta_cursor_sprite_tick_frame (MetaCursorSprite *sprite)
776610
 {
776610
-  return (self->xcursor_images &&
776610
-          self->xcursor_images->nimage > 1);
776610
+  return META_CURSOR_SPRITE_GET_CLASS (sprite)->tick_frame (sprite);
776610
 }
776610
 
776610
-MetaCursorSprite *
776610
-meta_cursor_sprite_new (void)
776610
+unsigned int
776610
+meta_cursor_sprite_get_current_frame_time (MetaCursorSprite *sprite)
776610
 {
776610
-  return g_object_new (META_TYPE_CURSOR_SPRITE, NULL);
776610
+  return META_CURSOR_SPRITE_GET_CLASS (sprite)->get_current_frame_time (sprite);
776610
 }
776610
 
776610
-static void
776610
-meta_cursor_sprite_load_from_theme (MetaCursorSprite *self)
776610
-{
776610
-  XcursorImage *image;
776610
-
776610
-  g_assert (self->cursor != META_CURSOR_NONE);
776610
-
776610
-  self->theme_dirty = FALSE;
776610
-
776610
-  /* We might be reloading with a different scale. If so clear the old data. */
776610
-  if (self->xcursor_images)
776610
-    {
776610
-      g_clear_pointer (&self->texture, cogl_object_unref);
776610
-      XcursorImagesDestroy (self->xcursor_images);
776610
-    }
776610
-
776610
-  self->current_frame = 0;
776610
-  self->xcursor_images = load_cursor_on_client (self->cursor,
776610
-                                                self->theme_scale);
776610
-  if (!self->xcursor_images)
776610
-    meta_fatal ("Could not find cursor. Perhaps set XCURSOR_PATH?");
776610
-
776610
-  image = meta_cursor_sprite_get_current_frame_image (self);
776610
-  meta_cursor_sprite_load_from_xcursor_image (self, image);
776610
-}
776610
-
776610
-MetaCursorSprite *
776610
-meta_cursor_sprite_from_theme (MetaCursor cursor)
776610
+void
776610
+meta_cursor_sprite_clear_texture (MetaCursorSprite *sprite)
776610
 {
776610
-  MetaCursorSprite *self;
776610
-
776610
-  self = meta_cursor_sprite_new ();
776610
-
776610
-  self->cursor = cursor;
776610
-  self->theme_dirty = TRUE;
776610
+  MetaCursorSpritePrivate *priv =
776610
+    meta_cursor_sprite_get_instance_private (sprite);
776610
 
776610
-  return self;
776610
+  g_clear_pointer (&priv->texture, cogl_object_unref);
776610
 }
776610
 
776610
 void
776610
-meta_cursor_sprite_set_texture (MetaCursorSprite *self,
776610
+meta_cursor_sprite_set_texture (MetaCursorSprite *sprite,
776610
                                 CoglTexture      *texture,
776610
                                 int               hot_x,
776610
                                 int               hot_y)
776610
 {
776610
-  if (self->texture == COGL_TEXTURE_2D (texture) &&
776610
-      self->hot_x == hot_x &&
776610
-      self->hot_y == hot_y)
776610
+  MetaCursorSpritePrivate *priv =
776610
+    meta_cursor_sprite_get_instance_private (sprite);
776610
+
776610
+  if (priv->texture == COGL_TEXTURE_2D (texture) &&
776610
+      priv->hot_x == hot_x &&
776610
+      priv->hot_y == hot_y)
776610
     return;
776610
 
776610
-  g_clear_pointer (&self->texture, cogl_object_unref);
776610
+  g_clear_pointer (&priv->texture, cogl_object_unref);
776610
   if (texture)
776610
-    self->texture = cogl_object_ref (texture);
776610
-  self->hot_x = hot_x;
776610
-  self->hot_y = hot_y;
776610
+    priv->texture = cogl_object_ref (texture);
776610
+  priv->hot_x = hot_x;
776610
+  priv->hot_y = hot_y;
776610
 
776610
-  g_signal_emit (self, signals[TEXTURE_CHANGED], 0);
776610
+  g_signal_emit (sprite, signals[TEXTURE_CHANGED], 0);
776610
 }
776610
 
776610
 void
776610
-meta_cursor_sprite_set_texture_scale (MetaCursorSprite *self,
776610
+meta_cursor_sprite_set_texture_scale (MetaCursorSprite *sprite,
776610
                                       float             scale)
776610
 {
776610
-  self->texture_scale = scale;
776610
-}
776610
+  MetaCursorSpritePrivate *priv =
776610
+    meta_cursor_sprite_get_instance_private (sprite);
776610
 
776610
-void
776610
-meta_cursor_sprite_set_theme_scale (MetaCursorSprite *self,
776610
-                                    int               theme_scale)
776610
-{
776610
-  if (self->theme_scale != theme_scale)
776610
-    self->theme_dirty = TRUE;
776610
-  self->theme_scale = theme_scale;
776610
+  priv->texture_scale = scale;
776610
 }
776610
 
776610
 CoglTexture *
776610
-meta_cursor_sprite_get_cogl_texture (MetaCursorSprite *self)
776610
+meta_cursor_sprite_get_cogl_texture (MetaCursorSprite *sprite)
776610
 {
776610
-  return COGL_TEXTURE (self->texture);
776610
-}
776610
+  MetaCursorSpritePrivate *priv =
776610
+    meta_cursor_sprite_get_instance_private (sprite);
776610
 
776610
-MetaCursor
776610
-meta_cursor_sprite_get_meta_cursor (MetaCursorSprite *self)
776610
-{
776610
-  return self->cursor;
776610
+  return COGL_TEXTURE (priv->texture);
776610
 }
776610
 
776610
 void
776610
-meta_cursor_sprite_get_hotspot (MetaCursorSprite *self,
776610
+meta_cursor_sprite_get_hotspot (MetaCursorSprite *sprite,
776610
                                 int              *hot_x,
776610
                                 int              *hot_y)
776610
 {
776610
-  *hot_x = self->hot_x;
776610
-  *hot_y = self->hot_y;
776610
+  MetaCursorSpritePrivate *priv =
776610
+    meta_cursor_sprite_get_instance_private (sprite);
776610
+
776610
+  *hot_x = priv->hot_x;
776610
+  *hot_y = priv->hot_y;
776610
 }
776610
 
776610
 float
776610
-meta_cursor_sprite_get_texture_scale (MetaCursorSprite *self)
776610
+meta_cursor_sprite_get_texture_scale (MetaCursorSprite *sprite)
776610
 {
776610
-  return self->texture_scale;
776610
+  MetaCursorSpritePrivate *priv =
776610
+    meta_cursor_sprite_get_instance_private (sprite);
776610
+
776610
+  return priv->texture_scale;
776610
 }
776610
 
776610
 void
776610
-meta_cursor_sprite_prepare_at (MetaCursorSprite *self,
776610
+meta_cursor_sprite_prepare_at (MetaCursorSprite *sprite,
776610
                                int               x,
776610
                                int               y)
776610
 {
776610
-  g_signal_emit (self, signals[PREPARE_AT], 0, x, y);
776610
+  g_signal_emit (sprite, signals[PREPARE_AT], 0, x, y);
776610
 }
776610
 
776610
 void
776610
-meta_cursor_sprite_realize_texture (MetaCursorSprite *self)
776610
+meta_cursor_sprite_realize_texture (MetaCursorSprite *sprite)
776610
 {
776610
-  if (self->theme_dirty)
776610
-    meta_cursor_sprite_load_from_theme (self);
776610
+  MetaCursorSpriteClass *klass = META_CURSOR_SPRITE_GET_CLASS (sprite);
776610
+
776610
+  if (klass->realize_texture)
776610
+    klass->realize_texture (sprite);
776610
 }
776610
 
776610
 static void
776610
-meta_cursor_sprite_init (MetaCursorSprite *self)
776610
+meta_cursor_sprite_init (MetaCursorSprite *sprite)
776610
 {
776610
-  self->texture_scale = 1.0f;
776610
+  MetaCursorSpritePrivate *priv =
776610
+    meta_cursor_sprite_get_instance_private (sprite);
776610
+
776610
+  priv->texture_scale = 1.0f;
776610
 }
776610
 
776610
 static void
776610
 meta_cursor_sprite_finalize (GObject *object)
776610
 {
776610
-  MetaCursorSprite *self = META_CURSOR_SPRITE (object);
776610
-
776610
-  if (self->xcursor_images)
776610
-    XcursorImagesDestroy (self->xcursor_images);
776610
+  MetaCursorSprite *sprite = META_CURSOR_SPRITE (object);
776610
+  MetaCursorSpritePrivate *priv =
776610
+    meta_cursor_sprite_get_instance_private (sprite);
776610
 
776610
-  g_clear_pointer (&self->texture, cogl_object_unref);
776610
+  g_clear_pointer (&priv->texture, cogl_object_unref);
776610
 
776610
   G_OBJECT_CLASS (meta_cursor_sprite_parent_class)->finalize (object);
776610
 }
776610
diff --git a/src/backends/meta-cursor.h b/src/backends/meta-cursor.h
776610
index 6087df69c..3051fdee6 100644
776610
--- a/src/backends/meta-cursor.h
776610
+++ b/src/backends/meta-cursor.h
776610
@@ -25,51 +25,50 @@
776610
 #include <meta/common.h>
776610
 #include <meta/boxes.h>
776610
 
776610
-typedef struct _MetaCursorSprite MetaCursorSprite;
776610
-
776610
 #define META_TYPE_CURSOR_SPRITE (meta_cursor_sprite_get_type ())
776610
-G_DECLARE_FINAL_TYPE (MetaCursorSprite,
776610
-                      meta_cursor_sprite,
776610
-                      META, CURSOR_SPRITE,
776610
-                      GObject);
776610
-
776610
-MetaCursorSprite * meta_cursor_sprite_new (void);
776610
-
776610
-MetaCursorSprite * meta_cursor_sprite_from_theme  (MetaCursor cursor);
776610
-
776610
-
776610
-void meta_cursor_sprite_set_theme_scale (MetaCursorSprite *self,
776610
-                                         int               scale);
776610
-
776610
-MetaCursor meta_cursor_sprite_get_meta_cursor (MetaCursorSprite *self);
776610
-
776610
-Cursor meta_cursor_create_x_cursor (Display    *xdisplay,
776610
-                                    MetaCursor  cursor);
776610
-
776610
-void meta_cursor_sprite_prepare_at (MetaCursorSprite *self,
776610
+G_DECLARE_DERIVABLE_TYPE (MetaCursorSprite,
776610
+                          meta_cursor_sprite,
776610
+                          META, CURSOR_SPRITE,
776610
+                          GObject)
776610
+
776610
+struct _MetaCursorSpriteClass
776610
+{
776610
+  GObjectClass parent_class;
776610
+
776610
+  void (* realize_texture) (MetaCursorSprite *sprite);
776610
+  gboolean (* is_animated) (MetaCursorSprite *sprite);
776610
+  void (* tick_frame) (MetaCursorSprite *sprite);
776610
+  unsigned int (* get_current_frame_time) (MetaCursorSprite *sprite);
776610
+};
776610
+
776610
+void meta_cursor_sprite_prepare_at (MetaCursorSprite *sprite,
776610
                                     int               x,
776610
                                     int               y);
776610
 
776610
-void meta_cursor_sprite_realize_texture (MetaCursorSprite *self);
776610
+void meta_cursor_sprite_realize_texture (MetaCursorSprite *sprite);
776610
+
776610
+void meta_cursor_sprite_clear_texture (MetaCursorSprite *sprite);
776610
 
776610
-void meta_cursor_sprite_set_texture (MetaCursorSprite *self,
776610
+void meta_cursor_sprite_set_texture (MetaCursorSprite *sprite,
776610
                                      CoglTexture      *texture,
776610
                                      int               hot_x,
776610
                                      int               hot_y);
776610
 
776610
-void meta_cursor_sprite_set_texture_scale (MetaCursorSprite *self,
776610
+void meta_cursor_sprite_set_texture_scale (MetaCursorSprite *sprite,
776610
                                            float             scale);
776610
 
776610
-CoglTexture *meta_cursor_sprite_get_cogl_texture (MetaCursorSprite *self);
776610
+CoglTexture *meta_cursor_sprite_get_cogl_texture (MetaCursorSprite *sprite);
776610
 
776610
-void meta_cursor_sprite_get_hotspot (MetaCursorSprite *self,
776610
+void meta_cursor_sprite_get_hotspot (MetaCursorSprite *sprite,
776610
                                      int              *hot_x,
776610
                                      int              *hot_y);
776610
 
776610
-float meta_cursor_sprite_get_texture_scale (MetaCursorSprite *self);
776610
+float meta_cursor_sprite_get_texture_scale (MetaCursorSprite *sprite);
776610
+
776610
+gboolean meta_cursor_sprite_is_animated (MetaCursorSprite *sprite);
776610
+
776610
+void meta_cursor_sprite_tick_frame (MetaCursorSprite *sprite);
776610
 
776610
-gboolean meta_cursor_sprite_is_animated            (MetaCursorSprite *self);
776610
-void     meta_cursor_sprite_tick_frame             (MetaCursorSprite *self);
776610
-guint    meta_cursor_sprite_get_current_frame_time (MetaCursorSprite *self);
776610
+unsigned int meta_cursor_sprite_get_current_frame_time (MetaCursorSprite *sprite);
776610
 
776610
 #endif /* META_CURSOR_H */
776610
diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c
776610
index a29f593ea..042d96ec6 100644
776610
--- a/src/backends/native/meta-backend-native.c
776610
+++ b/src/backends/native/meta-backend-native.c
776610
@@ -645,8 +645,6 @@ void meta_backend_native_resume (MetaBackendNative *native)
776610
     meta_backend_get_monitor_manager (backend);
776610
   MetaMonitorManagerKms *monitor_manager_kms =
776610
     META_MONITOR_MANAGER_KMS (monitor_manager);
776610
-  MetaCursorRenderer *cursor_renderer;
776610
-  MetaCursorRendererNative *cursor_renderer_native;
776610
   ClutterActor *stage;
776610
   MetaIdleMonitor *idle_monitor;
776610
 
776610
@@ -658,10 +656,6 @@ void meta_backend_native_resume (MetaBackendNative *native)
776610
   stage = meta_backend_get_stage (backend);
776610
   clutter_actor_queue_redraw (stage);
776610
 
776610
-  cursor_renderer = meta_backend_get_cursor_renderer (backend);
776610
-  cursor_renderer_native = META_CURSOR_RENDERER_NATIVE (cursor_renderer);
776610
-  meta_cursor_renderer_native_force_update (cursor_renderer_native);
776610
-
776610
   idle_monitor = meta_backend_get_idle_monitor (backend, 0);
776610
   meta_idle_monitor_reset_idletime (idle_monitor);
776610
 }
776610
diff --git a/src/backends/native/meta-cursor-renderer-native.c b/src/backends/native/meta-cursor-renderer-native.c
776610
index c7326af42..29800953b 100644
776610
--- a/src/backends/native/meta-cursor-renderer-native.c
776610
+++ b/src/backends/native/meta-cursor-renderer-native.c
776610
@@ -35,6 +35,7 @@
776610
 #include <meta/meta-backend.h>
776610
 
776610
 #include "backends/meta-backend-private.h"
776610
+#include "backends/meta-cursor-sprite-xcursor.h"
776610
 #include "backends/meta-logical-monitor.h"
776610
 #include "backends/meta-monitor.h"
776610
 #include "backends/meta-monitor-manager-private.h"
776610
@@ -43,6 +44,11 @@
776610
 #include "core/boxes-private.h"
776610
 #include "meta/boxes.h"
776610
 
776610
+#ifdef HAVE_WAYLAND
776610
+#include "wayland/meta-cursor-sprite-wayland.h"
776610
+#include "wayland/meta-wayland-buffer.h"
776610
+#endif
776610
+
776610
 #ifndef DRM_CAP_CURSOR_WIDTH
776610
 #define DRM_CAP_CURSOR_WIDTH 0x8
776610
 #endif
776610
@@ -113,6 +119,11 @@ static GQuark quark_cursor_renderer_native_gpu_data = 0;
776610
 
776610
 G_DEFINE_TYPE_WITH_PRIVATE (MetaCursorRendererNative, meta_cursor_renderer_native, META_TYPE_CURSOR_RENDERER);
776610
 
776610
+static void
776610
+realize_cursor_sprite (MetaCursorRenderer *renderer,
776610
+                       MetaCursorSprite   *cursor_sprite,
776610
+                       GList              *gpus);
776610
+
776610
 static MetaCursorNativeGpuState *
776610
 get_cursor_gpu_state (MetaCursorNativePrivate *cursor_priv,
776610
                       MetaGpuKms              *gpu_kms);
776610
@@ -152,7 +163,8 @@ static void
776610
 meta_cursor_renderer_native_finalize (GObject *object)
776610
 {
776610
   MetaCursorRendererNative *renderer = META_CURSOR_RENDERER_NATIVE (object);
776610
-  MetaCursorRendererNativePrivate *priv = meta_cursor_renderer_native_get_instance_private (renderer);
776610
+  MetaCursorRendererNativePrivate *priv =
776610
+    meta_cursor_renderer_native_get_instance_private (renderer);
776610
 
776610
   if (priv->animation_timeout_id)
776610
     g_source_remove (priv->animation_timeout_id);
776610
@@ -203,7 +215,8 @@ set_crtc_cursor (MetaCursorRendererNative *native,
776610
                  MetaCrtc                 *crtc,
776610
                  MetaCursorSprite         *cursor_sprite)
776610
 {
776610
-  MetaCursorRendererNativePrivate *priv = meta_cursor_renderer_native_get_instance_private (native);
776610
+  MetaCursorRendererNativePrivate *priv =
776610
+    meta_cursor_renderer_native_get_instance_private (native);
776610
   MetaCursorRendererNativeGpuData *cursor_renderer_gpu_data;
776610
   MetaGpuKms *gpu_kms;
776610
   int kms_fd;
776610
@@ -371,7 +384,8 @@ static void
776610
 update_hw_cursor (MetaCursorRendererNative *native,
776610
                   MetaCursorSprite         *cursor_sprite)
776610
 {
776610
-  MetaCursorRendererNativePrivate *priv = meta_cursor_renderer_native_get_instance_private (native);
776610
+  MetaCursorRendererNativePrivate *priv =
776610
+    meta_cursor_renderer_native_get_instance_private (native);
776610
   MetaCursorRenderer *renderer = META_CURSOR_RENDERER (native);
776610
   MetaMonitorManager *monitor_manager = priv->monitor_manager;
776610
   GList *logical_monitors;
776610
@@ -564,18 +578,15 @@ can_draw_cursor_unscaled (MetaCursorRenderer *renderer,
776610
 
776610
 static gboolean
776610
 should_have_hw_cursor (MetaCursorRenderer *renderer,
776610
-                       MetaCursorSprite   *cursor_sprite)
776610
+                       MetaCursorSprite   *cursor_sprite,
776610
+                       GList              *gpus)
776610
 {
776610
-  MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
776610
-  MetaCursorRendererNativePrivate *priv = meta_cursor_renderer_native_get_instance_private (native);
776610
-  GList *gpus;
776610
   GList *l;
776610
   CoglTexture *texture;
776610
 
776610
   if (!cursor_sprite)
776610
     return FALSE;
776610
 
776610
-  gpus = meta_monitor_manager_get_gpus (priv->monitor_manager);
776610
   for (l = gpus; l; l = l->next)
776610
     {
776610
       MetaGpuKms *gpu_kms = l->data;
776610
@@ -609,7 +620,8 @@ should_have_hw_cursor (MetaCursorRenderer *renderer,
776610
 static gboolean
776610
 meta_cursor_renderer_native_update_animation (MetaCursorRendererNative *native)
776610
 {
776610
-  MetaCursorRendererNativePrivate *priv = meta_cursor_renderer_native_get_instance_private (native);
776610
+  MetaCursorRendererNativePrivate *priv =
776610
+    meta_cursor_renderer_native_get_instance_private (native);
776610
   MetaCursorRenderer *renderer = META_CURSOR_RENDERER (native);
776610
   MetaCursorSprite *cursor_sprite = meta_cursor_renderer_get_cursor (renderer);
776610
 
776610
@@ -621,10 +633,11 @@ meta_cursor_renderer_native_update_animation (MetaCursorRendererNative *native)
776610
 }
776610
 
776610
 static void
776610
-meta_cursor_renderer_native_trigger_frame (MetaCursorRendererNative *native,
776610
-                                           MetaCursorSprite         *cursor_sprite)
776610
+maybe_schedule_cursor_sprite_animation_frame (MetaCursorRendererNative *native,
776610
+                                              MetaCursorSprite         *cursor_sprite)
776610
 {
776610
-  MetaCursorRendererNativePrivate *priv = meta_cursor_renderer_native_get_instance_private (native);
776610
+  MetaCursorRendererNativePrivate *priv =
776610
+    meta_cursor_renderer_native_get_instance_private (native);
776610
   gboolean cursor_change;
776610
   guint delay;
776610
 
776610
@@ -656,21 +669,78 @@ meta_cursor_renderer_native_trigger_frame (MetaCursorRendererNative *native,
776610
     }
776610
 }
776610
 
776610
+static GList *
776610
+calculate_cursor_sprite_gpus (MetaCursorRenderer *renderer,
776610
+                              MetaCursorSprite   *cursor_sprite)
776610
+{
776610
+  MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
776610
+  MetaCursorRendererNativePrivate *priv =
776610
+    meta_cursor_renderer_native_get_instance_private (native);
776610
+  MetaMonitorManager *monitor_manager = priv->monitor_manager;
776610
+  GList *gpus = NULL;
776610
+  GList *logical_monitors;
776610
+  GList *l;
776610
+  ClutterRect cursor_rect;
776610
+
776610
+  cursor_rect = meta_cursor_renderer_calculate_rect (renderer, cursor_sprite);
776610
+
776610
+  logical_monitors =
776610
+    meta_monitor_manager_get_logical_monitors (monitor_manager);
776610
+  for (l = logical_monitors; l; l = l->next)
776610
+    {
776610
+      MetaLogicalMonitor *logical_monitor = l->data;
776610
+      MetaRectangle logical_monitor_layout;
776610
+      ClutterRect logical_monitor_rect;
776610
+      GList *monitors, *l_mon;
776610
+
776610
+      logical_monitor_layout =
776610
+        meta_logical_monitor_get_layout (logical_monitor);
776610
+      logical_monitor_rect =
776610
+        meta_rectangle_to_clutter_rect (&logical_monitor_layout);
776610
+
776610
+      if (!clutter_rect_intersection (&cursor_rect, &logical_monitor_rect,
776610
+                                      NULL))
776610
+        continue;
776610
+
776610
+      monitors = meta_logical_monitor_get_monitors (logical_monitor);
776610
+      for (l_mon = monitors; l_mon; l_mon = l_mon->next)
776610
+        {
776610
+          MetaMonitor *monitor = l_mon->data;
776610
+          MetaGpu *gpu;
776610
+
776610
+          gpu = meta_monitor_get_gpu (monitor);
776610
+          if (!g_list_find (gpus, gpu))
776610
+            gpus = g_list_prepend (gpus, gpu);
776610
+        }
776610
+    }
776610
+
776610
+  return gpus;
776610
+}
776610
+
776610
 static gboolean
776610
 meta_cursor_renderer_native_update_cursor (MetaCursorRenderer *renderer,
776610
                                            MetaCursorSprite   *cursor_sprite)
776610
 {
776610
   MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
776610
-  MetaCursorRendererNativePrivate *priv = meta_cursor_renderer_native_get_instance_private (native);
776610
+  MetaCursorRendererNativePrivate *priv =
776610
+    meta_cursor_renderer_native_get_instance_private (native);
776610
+  g_autoptr (GList) gpus = NULL;
776610
 
776610
   if (cursor_sprite)
776610
-    meta_cursor_sprite_realize_texture (cursor_sprite);
776610
+    {
776610
+      meta_cursor_sprite_realize_texture (cursor_sprite);
776610
+      gpus = calculate_cursor_sprite_gpus (renderer, cursor_sprite);
776610
+      realize_cursor_sprite (renderer, cursor_sprite, gpus);
776610
+    }
776610
 
776610
-  meta_cursor_renderer_native_trigger_frame (native, cursor_sprite);
776610
+  maybe_schedule_cursor_sprite_animation_frame (native, cursor_sprite);
776610
 
776610
-  priv->has_hw_cursor = should_have_hw_cursor (renderer, cursor_sprite);
776610
+  priv->has_hw_cursor = should_have_hw_cursor (renderer, cursor_sprite, gpus);
776610
   update_hw_cursor (native, cursor_sprite);
776610
-  return priv->has_hw_cursor;
776610
+
776610
+  return (priv->has_hw_cursor ||
776610
+          !cursor_sprite ||
776610
+          !meta_cursor_sprite_get_cogl_texture (cursor_sprite));
776610
 }
776610
 
776610
 static void
776610
@@ -706,6 +776,24 @@ ensure_cursor_gpu_state (MetaCursorNativePrivate *cursor_priv,
776610
   return cursor_gpu_state;
776610
 }
776610
 
776610
+static void
776610
+on_cursor_sprite_texture_changed (MetaCursorSprite *cursor_sprite)
776610
+{
776610
+  MetaCursorNativePrivate *cursor_priv = get_cursor_priv (cursor_sprite);
776610
+  GHashTableIter iter;
776610
+  MetaCursorNativeGpuState *cursor_gpu_state;
776610
+
776610
+  g_hash_table_iter_init (&iter, cursor_priv->gpu_states);
776610
+  while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &cursor_gpu_state))
776610
+    {
776610
+      guint pending_bo;
776610
+      pending_bo = get_pending_cursor_sprite_gbm_bo_index (cursor_gpu_state);
776610
+      g_clear_pointer (&cursor_gpu_state->bos[pending_bo],
776610
+                       (GDestroyNotify) gbm_bo_destroy);
776610
+      cursor_gpu_state->pending_bo_state = META_CURSOR_GBM_BO_STATE_INVALIDATED;
776610
+    }
776610
+}
776610
+
776610
 static void
776610
 cursor_priv_free (MetaCursorNativePrivate *cursor_priv)
776610
 {
776610
@@ -738,6 +826,9 @@ ensure_cursor_priv (MetaCursorSprite *cursor_sprite)
776610
                            cursor_priv,
776610
                            (GDestroyNotify) cursor_priv_free);
776610
 
776610
+  g_signal_connect (cursor_sprite, "texture-changed",
776610
+                    G_CALLBACK (on_cursor_sprite_texture_changed), NULL);
776610
+
776610
   return cursor_priv;
776610
 }
776610
 
776610
@@ -805,57 +896,71 @@ load_cursor_sprite_gbm_buffer_for_gpu (MetaCursorRendererNative *native,
776610
     }
776610
 }
776610
 
776610
-static void
776610
-invalidate_pending_cursor_sprite_gbm_bo (MetaCursorSprite *cursor_sprite,
776610
-                                         MetaGpuKms       *gpu_kms)
776610
+static gboolean
776610
+is_cursor_hw_state_valid (MetaCursorSprite *cursor_sprite,
776610
+                          MetaGpuKms       *gpu_kms)
776610
 {
776610
   MetaCursorNativePrivate *cursor_priv;
776610
   MetaCursorNativeGpuState *cursor_gpu_state;
776610
-  guint pending_bo;
776610
 
776610
   cursor_priv = get_cursor_priv (cursor_sprite);
776610
   if (!cursor_priv)
776610
-    return;
776610
+    return FALSE;
776610
 
776610
   cursor_gpu_state = get_cursor_gpu_state (cursor_priv, gpu_kms);
776610
   if (!cursor_gpu_state)
776610
-    return;
776610
+    return FALSE;
776610
 
776610
-  pending_bo = get_pending_cursor_sprite_gbm_bo_index (cursor_gpu_state);
776610
-  g_clear_pointer (&cursor_gpu_state->bos[pending_bo],
776610
-                   (GDestroyNotify) gbm_bo_destroy);
776610
-  cursor_gpu_state->pending_bo_state = META_CURSOR_GBM_BO_STATE_INVALIDATED;
776610
+  switch (cursor_gpu_state->pending_bo_state)
776610
+    {
776610
+    case META_CURSOR_GBM_BO_STATE_SET:
776610
+    case META_CURSOR_GBM_BO_STATE_NONE:
776610
+      return TRUE;
776610
+    case META_CURSOR_GBM_BO_STATE_INVALIDATED:
776610
+      return FALSE;
776610
+    }
776610
+
776610
+  g_assert_not_reached ();
776610
 }
776610
 
776610
 #ifdef HAVE_WAYLAND
776610
 static void
776610
-meta_cursor_renderer_native_realize_cursor_from_wl_buffer_for_gpu (MetaCursorRenderer *renderer,
776610
-                                                                   MetaGpuKms         *gpu_kms,
776610
-                                                                   MetaCursorSprite   *cursor_sprite,
776610
-                                                                   struct wl_resource *buffer)
776610
+realize_cursor_sprite_from_wl_buffer_for_gpu (MetaCursorRenderer      *renderer,
776610
+                                              MetaGpuKms              *gpu_kms,
776610
+                                              MetaCursorSpriteWayland *sprite_wayland)
776610
 {
776610
   MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
776610
+  MetaCursorSprite *cursor_sprite = META_CURSOR_SPRITE (sprite_wayland);
776610
   MetaCursorRendererNativeGpuData *cursor_renderer_gpu_data;
776610
   uint32_t gbm_format;
776610
   uint64_t cursor_width, cursor_height;
776610
   CoglTexture *texture;
776610
   uint width, height;
776610
+  MetaWaylandBuffer *buffer;
776610
+  struct wl_resource *buffer_resource;
776610
+  struct wl_shm_buffer *shm_buffer;
776610
 
776610
   cursor_renderer_gpu_data =
776610
     meta_cursor_renderer_native_gpu_data_from_gpu (gpu_kms);
776610
   if (!cursor_renderer_gpu_data || cursor_renderer_gpu_data->hw_cursor_broken)
776610
     return;
776610
 
776610
-  /* Destroy any previous pending cursor buffer; we'll always either fail (which
776610
-   * should unset, or succeed, which will set new buffer.
776610
-   */
776610
-  invalidate_pending_cursor_sprite_gbm_bo (cursor_sprite, gpu_kms);
776610
+  if (is_cursor_hw_state_valid (cursor_sprite, gpu_kms))
776610
+    return;
776610
 
776610
   texture = meta_cursor_sprite_get_cogl_texture (cursor_sprite);
776610
   width = cogl_texture_get_width (texture);
776610
   height = cogl_texture_get_height (texture);
776610
 
776610
-  struct wl_shm_buffer *shm_buffer = wl_shm_buffer_get (buffer);
776610
+  buffer = meta_cursor_sprite_wayland_get_buffer (sprite_wayland);
776610
+  if (!buffer)
776610
+    return;
776610
+
776610
+  buffer_resource = meta_wayland_buffer_get_resource (buffer);
776610
+  if (!buffer_resource)
776610
+    return;
776610
+
776610
+  shm_buffer = wl_shm_buffer_get (buffer_resource);
776610
   if (shm_buffer)
776610
     {
776610
       int rowstride = wl_shm_buffer_get_stride (shm_buffer);
776610
@@ -929,47 +1034,27 @@ meta_cursor_renderer_native_realize_cursor_from_wl_buffer_for_gpu (MetaCursorRen
776610
       set_pending_cursor_sprite_gbm_bo (cursor_sprite, gpu_kms, bo);
776610
     }
776610
 }
776610
-
776610
-static void
776610
-meta_cursor_renderer_native_realize_cursor_from_wl_buffer (MetaCursorRenderer *renderer,
776610
-                                                           MetaCursorSprite *cursor_sprite,
776610
-                                                           struct wl_resource *buffer)
776610
-{
776610
-  MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
776610
-  MetaCursorRendererNativePrivate *priv =
776610
-	  meta_cursor_renderer_native_get_instance_private (native);
776610
-  GList *gpus;
776610
-  GList *l;
776610
-
776610
-  gpus = meta_monitor_manager_get_gpus (priv->monitor_manager);
776610
-  for (l = gpus; l; l = l->next)
776610
-    {
776610
-      MetaGpuKms *gpu_kms = l->data;
776610
-
776610
-      meta_cursor_renderer_native_realize_cursor_from_wl_buffer_for_gpu (
776610
-        renderer,
776610
-        gpu_kms,
776610
-        cursor_sprite,
776610
-        buffer);
776610
-    }
776610
-}
776610
 #endif
776610
 
776610
 static void
776610
-meta_cursor_renderer_native_realize_cursor_from_xcursor_for_gpu (MetaCursorRenderer *renderer,
776610
-                                                                 MetaGpuKms         *gpu_kms,
776610
-                                                                 MetaCursorSprite   *cursor_sprite,
776610
-                                                                 XcursorImage       *xc_image)
776610
+realize_cursor_sprite_from_xcursor_for_gpu (MetaCursorRenderer      *renderer,
776610
+                                            MetaGpuKms              *gpu_kms,
776610
+                                            MetaCursorSpriteXcursor *sprite_xcursor)
776610
 {
776610
   MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
776610
   MetaCursorRendererNativeGpuData *cursor_renderer_gpu_data;
776610
+  MetaCursorSprite *cursor_sprite = META_CURSOR_SPRITE (sprite_xcursor);
776610
+  XcursorImage *xc_image;
776610
 
776610
   cursor_renderer_gpu_data =
776610
     meta_cursor_renderer_native_gpu_data_from_gpu (gpu_kms);
776610
   if (!cursor_renderer_gpu_data || cursor_renderer_gpu_data->hw_cursor_broken)
776610
     return;
776610
 
776610
-  invalidate_pending_cursor_sprite_gbm_bo (cursor_sprite, gpu_kms);
776610
+  if (is_cursor_hw_state_valid (cursor_sprite, gpu_kms))
776610
+    return;
776610
+
776610
+  xc_image = meta_cursor_sprite_xcursor_get_current_image (sprite_xcursor);
776610
 
776610
   load_cursor_sprite_gbm_buffer_for_gpu (native,
776610
                                          gpu_kms,
776610
@@ -982,26 +1067,45 @@ meta_cursor_renderer_native_realize_cursor_from_xcursor_for_gpu (MetaCursorRende
776610
 }
776610
 
776610
 static void
776610
-meta_cursor_renderer_native_realize_cursor_from_xcursor (MetaCursorRenderer *renderer,
776610
-                                                         MetaCursorSprite   *cursor_sprite,
776610
-                                                         XcursorImage       *xc_image)
776610
+realize_cursor_sprite_for_gpu (MetaCursorRenderer *renderer,
776610
+                               MetaGpuKms         *gpu_kms,
776610
+                               MetaCursorSprite   *cursor_sprite)
776610
+{
776610
+#ifdef HAVE_WAYLAND
776610
+  if (META_IS_CURSOR_SPRITE_WAYLAND (cursor_sprite))
776610
+    {
776610
+      MetaCursorSpriteWayland *sprite_wayland =
776610
+        META_CURSOR_SPRITE_WAYLAND (cursor_sprite);
776610
+
776610
+      realize_cursor_sprite_from_wl_buffer_for_gpu (renderer,
776610
+                                                    gpu_kms,
776610
+                                                    sprite_wayland);
776610
+    }
776610
+  else
776610
+#endif
776610
+  if (META_IS_CURSOR_SPRITE_XCURSOR (cursor_sprite))
776610
+    {
776610
+      MetaCursorSpriteXcursor *sprite_xcursor =
776610
+        META_CURSOR_SPRITE_XCURSOR (cursor_sprite);
776610
+
776610
+      realize_cursor_sprite_from_xcursor_for_gpu (renderer,
776610
+                                                  gpu_kms,
776610
+                                                  sprite_xcursor);
776610
+    }
776610
+}
776610
+
776610
+static void
776610
+realize_cursor_sprite (MetaCursorRenderer *renderer,
776610
+                       MetaCursorSprite   *cursor_sprite,
776610
+                       GList              *gpus)
776610
 {
776610
-  MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
776610
-  MetaCursorRendererNativePrivate *priv =
776610
-	  meta_cursor_renderer_native_get_instance_private (native);
776610
-  GList *gpus;
776610
   GList *l;
776610
 
776610
-  gpus = meta_monitor_manager_get_gpus (priv->monitor_manager);
776610
   for (l = gpus; l; l = l->next)
776610
     {
776610
       MetaGpuKms *gpu_kms = l->data;
776610
 
776610
-      meta_cursor_renderer_native_realize_cursor_from_xcursor_for_gpu (
776610
-        renderer,
776610
-        gpu_kms,
776610
-        cursor_sprite,
776610
-        xc_image);
776610
+      realize_cursor_sprite_for_gpu (renderer, gpu_kms, cursor_sprite);
776610
     }
776610
 }
776610
 
776610
@@ -1013,12 +1117,6 @@ meta_cursor_renderer_native_class_init (MetaCursorRendererNativeClass *klass)
776610
 
776610
   object_class->finalize = meta_cursor_renderer_native_finalize;
776610
   renderer_class->update_cursor = meta_cursor_renderer_native_update_cursor;
776610
-#ifdef HAVE_WAYLAND
776610
-  renderer_class->realize_cursor_from_wl_buffer =
776610
-    meta_cursor_renderer_native_realize_cursor_from_wl_buffer;
776610
-#endif
776610
-  renderer_class->realize_cursor_from_xcursor =
776610
-    meta_cursor_renderer_native_realize_cursor_from_xcursor;
776610
 
776610
   quark_cursor_sprite = g_quark_from_static_string ("-meta-cursor-native");
776610
   quark_cursor_renderer_native_gpu_data =
776610
@@ -1033,14 +1131,13 @@ force_update_hw_cursor (MetaCursorRendererNative *native)
776610
     meta_cursor_renderer_native_get_instance_private (native);
776610
 
776610
   priv->hw_state_invalidated = TRUE;
776610
-  update_hw_cursor (native, meta_cursor_renderer_get_cursor (renderer));
776610
+  meta_cursor_renderer_force_update (renderer);
776610
 }
776610
 
776610
 static void
776610
 on_monitors_changed (MetaMonitorManager       *monitors,
776610
                      MetaCursorRendererNative *native)
776610
 {
776610
-  /* Our tracking is all messed up, so force an update. */
776610
   force_update_hw_cursor (native);
776610
 }
776610
 
776610
@@ -1112,9 +1209,3 @@ static void
776610
 meta_cursor_renderer_native_init (MetaCursorRendererNative *native)
776610
 {
776610
 }
776610
-
776610
-void
776610
-meta_cursor_renderer_native_force_update (MetaCursorRendererNative *native)
776610
-{
776610
-  force_update_hw_cursor (native);
776610
-}
776610
diff --git a/src/backends/native/meta-cursor-renderer-native.h b/src/backends/native/meta-cursor-renderer-native.h
776610
index 09203a5f7..fb4c8edc7 100644
776610
--- a/src/backends/native/meta-cursor-renderer-native.h
776610
+++ b/src/backends/native/meta-cursor-renderer-native.h
776610
@@ -32,8 +32,6 @@ G_DECLARE_FINAL_TYPE (MetaCursorRendererNative, meta_cursor_renderer_native,
776610
                       META, CURSOR_RENDERER_NATIVE,
776610
                       MetaCursorRenderer)
776610
 
776610
-void meta_cursor_renderer_native_force_update (MetaCursorRendererNative *renderer);
776610
-
776610
 MetaCursorRendererNative * meta_cursor_renderer_native_new (MetaBackend *backend);
776610
 
776610
 #endif /* META_CURSOR_RENDERER_NATIVE_H */
776610
diff --git a/src/backends/x11/cm/meta-cursor-sprite-xfixes.c b/src/backends/x11/cm/meta-cursor-sprite-xfixes.c
776610
new file mode 100644
776610
index 000000000..143ebb791
776610
--- /dev/null
776610
+++ b/src/backends/x11/cm/meta-cursor-sprite-xfixes.c
776610
@@ -0,0 +1,226 @@
776610
+/*
776610
+ * Copyright 2013, 2018 Red Hat, Inc.
776610
+ *
776610
+ * This program is free software; you can redistribute it and/or
776610
+ * modify it under the terms of the GNU General Public License as
776610
+ * published by the Free Software Foundation; either version 2 of the
776610
+ * License, or (at your option) any later version.
776610
+ *
776610
+ * This program is distributed in the hope that it will be useful, but
776610
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
776610
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
776610
+ * General Public License for more details.
776610
+ *
776610
+ * You should have received a copy of the GNU General Public License
776610
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
776610
+ *
776610
+ */
776610
+
776610
+#include "config.h"
776610
+
776610
+#include "backends/x11/cm/meta-cursor-sprite-xfixes.h"
776610
+
776610
+#include <X11/extensions/Xfixes.h>
776610
+
776610
+#include "core/display-private.h"
776610
+
776610
+enum
776610
+{
776610
+  PROP_0,
776610
+
776610
+  PROP_DISPLAY,
776610
+
776610
+  N_PROPS
776610
+};
776610
+
776610
+static GParamSpec *obj_props[N_PROPS];
776610
+
776610
+struct _MetaCursorSpriteXfixes
776610
+{
776610
+  MetaCursorSprite parent;
776610
+
776610
+  MetaDisplay *display;
776610
+};
776610
+
776610
+static void
776610
+meta_screen_cast_xfixes_init_initable_iface (GInitableIface *iface);
776610
+
776610
+G_DEFINE_TYPE_WITH_CODE (MetaCursorSpriteXfixes,
776610
+                         meta_cursor_sprite_xfixes,
776610
+                         META_TYPE_CURSOR_SPRITE,
776610
+                         G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
776610
+                                                meta_screen_cast_xfixes_init_initable_iface))
776610
+
776610
+static void
776610
+meta_cursor_sprite_xfixes_realize_texture (MetaCursorSprite *sprite)
776610
+{
776610
+}
776610
+
776610
+static gboolean
776610
+meta_cursor_sprite_xfixes_is_animated (MetaCursorSprite *sprite)
776610
+{
776610
+  return FALSE;
776610
+}
776610
+
776610
+static void
776610
+meta_cursor_sprite_xfixes_get_property (GObject    *object,
776610
+                                        guint       prop_id,
776610
+                                        GValue     *value,
776610
+                                        GParamSpec *pspec)
776610
+{
776610
+  MetaCursorSpriteXfixes *sprite_xfixes = META_CURSOR_SPRITE_XFIXES (object);
776610
+
776610
+  switch (prop_id)
776610
+    {
776610
+    case PROP_DISPLAY:
776610
+      g_value_set_object (value, sprite_xfixes->display);
776610
+      break;
776610
+    default:
776610
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
776610
+      break;
776610
+    }
776610
+}
776610
+
776610
+static void
776610
+meta_cursor_sprite_xfixes_set_property (GObject      *object,
776610
+                                        guint         prop_id,
776610
+                                        const GValue *value,
776610
+                                        GParamSpec   *pspec)
776610
+{
776610
+  MetaCursorSpriteXfixes *sprite_xfixes = META_CURSOR_SPRITE_XFIXES (object);
776610
+
776610
+  switch (prop_id)
776610
+    {
776610
+    case PROP_DISPLAY:
776610
+      sprite_xfixes->display = g_value_get_object (value);
776610
+      break;
776610
+    default:
776610
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
776610
+      break;
776610
+    }
776610
+}
776610
+
776610
+MetaCursorSpriteXfixes *
776610
+meta_cursor_sprite_xfixes_new (MetaDisplay  *display,
776610
+                               GError      **error)
776610
+{
776610
+  return g_initable_new (META_TYPE_CURSOR_SPRITE_XFIXES,
776610
+                         NULL, error,
776610
+                         "display", display,
776610
+                         NULL);
776610
+}
776610
+
776610
+static gboolean
776610
+meta_cursor_sprite_xfixes_initable_init (GInitable     *initable,
776610
+                                         GCancellable  *cancellable,
776610
+                                         GError       **error)
776610
+{
776610
+  MetaCursorSpriteXfixes *sprite_xfixes =
776610
+    META_CURSOR_SPRITE_XFIXES (initable);
776610
+  MetaCursorSprite *sprite = META_CURSOR_SPRITE (sprite_xfixes);
776610
+  XFixesCursorImage *cursor_image;
776610
+  CoglTexture2D *texture;
776610
+  uint8_t *cursor_data;
776610
+  gboolean free_cursor_data;
776610
+  ClutterBackend *clutter_backend;
776610
+  CoglContext *cogl_context;
776610
+
776610
+  cursor_image = XFixesGetCursorImage (sprite_xfixes->display->xdisplay);
776610
+  if (!cursor_image)
776610
+    {
776610
+      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
776610
+                   "Failed to get cursor image");
776610
+      return FALSE;
776610
+    }
776610
+
776610
+  /*
776610
+   * Like all X APIs, XFixesGetCursorImage() returns arrays of 32-bit
776610
+   * quantities as arrays of long; we need to convert on 64 bit
776610
+   */
776610
+  if (sizeof (long) == 4)
776610
+    {
776610
+      cursor_data = (uint8_t *) cursor_image->pixels;
776610
+      free_cursor_data = FALSE;
776610
+    }
776610
+  else
776610
+    {
776610
+      int i, j;
776610
+      uint32_t *cursor_words;
776610
+      unsigned long *p;
776610
+      uint32_t *q;
776610
+
776610
+      cursor_words = g_new (uint32_t,
776610
+                            cursor_image->width * cursor_image->height);
776610
+      cursor_data = (uint8_t *) cursor_words;
776610
+
776610
+      p = cursor_image->pixels;
776610
+      q = cursor_words;
776610
+      for (j = 0; j < cursor_image->height; j++)
776610
+        {
776610
+          for (i = 0; i < cursor_image->width; i++)
776610
+            *(q++) = *(p++);
776610
+        }
776610
+
776610
+      free_cursor_data = TRUE;
776610
+    }
776610
+
776610
+  clutter_backend = clutter_get_default_backend ();
776610
+  cogl_context = clutter_backend_get_cogl_context (clutter_backend);
776610
+  texture = cogl_texture_2d_new_from_data (cogl_context,
776610
+                                          cursor_image->width,
776610
+                                          cursor_image->height,
776610
+                                          CLUTTER_CAIRO_FORMAT_ARGB32,
776610
+                                          cursor_image->width * 4, /* stride */
776610
+                                          cursor_data,
776610
+                                          error);
776610
+
776610
+  if (free_cursor_data)
776610
+    g_free (cursor_data);
776610
+
776610
+  if (!sprite)
776610
+    return FALSE;
776610
+
776610
+  meta_cursor_sprite_set_texture (sprite,
776610
+                                  COGL_TEXTURE (texture),
776610
+                                  cursor_image->xhot,
776610
+                                  cursor_image->yhot);
776610
+  cogl_object_unref (texture);
776610
+  XFree (cursor_image);
776610
+
776610
+  return TRUE;
776610
+}
776610
+
776610
+static void
776610
+meta_screen_cast_xfixes_init_initable_iface (GInitableIface *iface)
776610
+{
776610
+  iface->init = meta_cursor_sprite_xfixes_initable_init;
776610
+}
776610
+
776610
+static void
776610
+meta_cursor_sprite_xfixes_init (MetaCursorSpriteXfixes *sprite_xfixes)
776610
+{
776610
+}
776610
+
776610
+static void
776610
+meta_cursor_sprite_xfixes_class_init (MetaCursorSpriteXfixesClass *klass)
776610
+{
776610
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
776610
+  MetaCursorSpriteClass *cursor_sprite_class = META_CURSOR_SPRITE_CLASS (klass);
776610
+
776610
+  object_class->get_property = meta_cursor_sprite_xfixes_get_property;
776610
+  object_class->set_property = meta_cursor_sprite_xfixes_set_property;
776610
+
776610
+  cursor_sprite_class->realize_texture =
776610
+    meta_cursor_sprite_xfixes_realize_texture;
776610
+  cursor_sprite_class->is_animated = meta_cursor_sprite_xfixes_is_animated;
776610
+
776610
+  obj_props[PROP_DISPLAY] =
776610
+    g_param_spec_object ("display",
776610
+                         "display",
776610
+                         "MetaDisplay",
776610
+                         META_TYPE_DISPLAY,
776610
+                         G_PARAM_READWRITE |
776610
+                         G_PARAM_CONSTRUCT_ONLY |
776610
+                         G_PARAM_STATIC_STRINGS);
776610
+  g_object_class_install_properties (object_class, N_PROPS, obj_props);
776610
+}
776610
diff --git a/src/backends/x11/cm/meta-cursor-sprite-xfixes.h b/src/backends/x11/cm/meta-cursor-sprite-xfixes.h
776610
new file mode 100644
776610
index 000000000..c7073fc2c
776610
--- /dev/null
776610
+++ b/src/backends/x11/cm/meta-cursor-sprite-xfixes.h
776610
@@ -0,0 +1,36 @@
776610
+/*
776610
+ * Copyright 2013, 2018 Red Hat, Inc.
776610
+ *
776610
+ * This program is free software; you can redistribute it and/or
776610
+ * modify it under the terms of the GNU General Public License as
776610
+ * published by the Free Software Foundation; either version 2 of the
776610
+ * License, or (at your option) any later version.
776610
+ *
776610
+ * This program is distributed in the hope that it will be useful, but
776610
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
776610
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
776610
+ * General Public License for more details.
776610
+ *
776610
+ * You should have received a copy of the GNU General Public License
776610
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
776610
+ *
776610
+ */
776610
+
776610
+#ifndef META_CURSOR_SPRITE_XFIXES_H
776610
+#define META_CURSOR_SPRITE_XFIXES_H
776610
+
776610
+#include <glib-object.h>
776610
+
776610
+#include "backends/meta-cursor.h"
776610
+#include "meta/types.h"
776610
+
776610
+#define META_TYPE_CURSOR_SPRITE_XFIXES (meta_cursor_sprite_xfixes_get_type ())
776610
+G_DECLARE_FINAL_TYPE (MetaCursorSpriteXfixes,
776610
+                      meta_cursor_sprite_xfixes,
776610
+                      META, CURSOR_SPRITE_XFIXES,
776610
+                      MetaCursorSprite)
776610
+
776610
+MetaCursorSpriteXfixes * meta_cursor_sprite_xfixes_new (MetaDisplay  *display,
776610
+                                                        GError      **error);
776610
+
776610
+#endif /* META_CURSOR_SPRITE_XFIXES_H */
776610
diff --git a/src/backends/x11/meta-cursor-renderer-x11.c b/src/backends/x11/meta-cursor-renderer-x11.c
776610
index 82109f1f3..bb3100a91 100644
776610
--- a/src/backends/x11/meta-cursor-renderer-x11.c
776610
+++ b/src/backends/x11/meta-cursor-renderer-x11.c
776610
@@ -30,6 +30,7 @@
776610
 
776610
 #include "meta-backend-x11.h"
776610
 #include "meta-stage-private.h"
776610
+#include "backends/meta-cursor-sprite-xcursor.h"
776610
 
776610
 struct _MetaCursorRendererX11Private
776610
 {
776610
@@ -59,13 +60,18 @@ meta_cursor_renderer_x11_update_cursor (MetaCursorRenderer *renderer,
776610
 
776610
   gboolean has_server_cursor = FALSE;
776610
 
776610
-  if (cursor_sprite)
776610
+  if (cursor_sprite && META_IS_CURSOR_SPRITE_XCURSOR (cursor_sprite))
776610
     {
776610
-      MetaCursor cursor = meta_cursor_sprite_get_meta_cursor (cursor_sprite);
776610
+      MetaCursorSpriteXcursor *sprite_xcursor =
776610
+        META_CURSOR_SPRITE_XCURSOR (cursor_sprite);
776610
+      MetaCursor cursor;
776610
 
776610
+      cursor = meta_cursor_sprite_xcursor_get_cursor (sprite_xcursor);
776610
       if (cursor != META_CURSOR_NONE)
776610
         {
776610
-          Cursor xcursor = meta_cursor_create_x_cursor (xdisplay, cursor);
776610
+          Cursor xcursor;
776610
+
776610
+          xcursor = meta_create_x_cursor (xdisplay, cursor);
776610
           XDefineCursor (xdisplay, xwindow, xcursor);
776610
           XFlush (xdisplay);
776610
           XFreeCursor (xdisplay, xcursor);
776610
diff --git a/src/backends/x11/nested/meta-cursor-renderer-x11-nested.c b/src/backends/x11/nested/meta-cursor-renderer-x11-nested.c
776610
index da1a56038..0daae683c 100644
776610
--- a/src/backends/x11/nested/meta-cursor-renderer-x11-nested.c
776610
+++ b/src/backends/x11/nested/meta-cursor-renderer-x11-nested.c
776610
@@ -26,6 +26,8 @@
776610
 
776610
 #include "backends/x11/nested/meta-cursor-renderer-x11-nested.h"
776610
 
776610
+#include <X11/Xcursor/Xcursor.h>
776610
+
776610
 #include "backends/x11/meta-backend-x11.h"
776610
 
776610
 struct _MetaCursorRendererX11Nested
776610
diff --git a/src/core/display.c b/src/core/display.c
776610
index d6da84b30..e7dd4534b 100644
776610
--- a/src/core/display.c
776610
+++ b/src/core/display.c
776610
@@ -3018,7 +3018,7 @@ Cursor
776610
 meta_display_create_x_cursor (MetaDisplay *display,
776610
                               MetaCursor   cursor)
776610
 {
776610
-  return meta_cursor_create_x_cursor (display->xdisplay, cursor);
776610
+  return meta_create_x_cursor (display->xdisplay, cursor);
776610
 }
776610
 
776610
 MetaGestureTracker *
776610
diff --git a/src/core/screen.c b/src/core/screen.c
776610
index c14bba0cf..048104150 100644
776610
--- a/src/core/screen.c
776610
+++ b/src/core/screen.c
776610
@@ -60,6 +60,7 @@
776610
 #include "x11/xprops.h"
776610
 
776610
 #include "backends/x11/meta-backend-x11.h"
776610
+#include "backends/meta-cursor-sprite-xcursor.h"
776610
 
776610
 static char* get_screen_name (MetaDisplay *display,
776610
                               int          number);
776610
@@ -1323,12 +1324,13 @@ find_highest_logical_monitor_scale (MetaBackend      *backend,
776610
 }
776610
 
776610
 static void
776610
-root_cursor_prepare_at (MetaCursorSprite *cursor_sprite,
776610
-                        int               x,
776610
-                        int               y,
776610
-                        MetaScreen       *screen)
776610
+root_cursor_prepare_at (MetaCursorSpriteXcursor *sprite_xcursor,
776610
+                        int                      x,
776610
+                        int                      y,
776610
+                        MetaScreen              *screen)
776610
 {
776610
   MetaBackend *backend = meta_get_backend ();
776610
+  MetaCursorSprite *cursor_sprite = META_CURSOR_SPRITE (sprite_xcursor);
776610
 
776610
   if (meta_is_stage_views_scaled ())
776610
     {
776610
@@ -1337,7 +1339,7 @@ root_cursor_prepare_at (MetaCursorSprite *cursor_sprite,
776610
       scale = find_highest_logical_monitor_scale (backend, cursor_sprite);
776610
       if (scale != 0.0)
776610
         {
776610
-          meta_cursor_sprite_set_theme_scale (cursor_sprite, scale);
776610
+          meta_cursor_sprite_xcursor_set_theme_scale (sprite_xcursor, scale);
776610
           meta_cursor_sprite_set_texture_scale (cursor_sprite, 1.0 / scale);
776610
         }
776610
     }
776610
@@ -1353,18 +1355,18 @@ root_cursor_prepare_at (MetaCursorSprite *cursor_sprite,
776610
       /* Reload the cursor texture if the scale has changed. */
776610
       if (logical_monitor)
776610
         {
776610
-          meta_cursor_sprite_set_theme_scale (cursor_sprite,
776610
-                                              logical_monitor->scale);
776610
+          meta_cursor_sprite_xcursor_set_theme_scale (sprite_xcursor,
776610
+                                                      logical_monitor->scale);
776610
           meta_cursor_sprite_set_texture_scale (cursor_sprite, 1.0);
776610
         }
776610
     }
776610
 }
776610
 
776610
 static void
776610
-manage_root_cursor_sprite_scale (MetaScreen       *screen,
776610
-                                 MetaCursorSprite *cursor_sprite)
776610
+manage_root_cursor_sprite_scale (MetaScreen              *screen,
776610
+                                 MetaCursorSpriteXcursor *sprite_xcursor)
776610
 {
776610
-  g_signal_connect_object (cursor_sprite,
776610
+  g_signal_connect_object (sprite_xcursor,
776610
                            "prepare-at",
776610
                            G_CALLBACK (root_cursor_prepare_at),
776610
                            screen,
776610
@@ -1377,17 +1379,18 @@ meta_screen_update_cursor (MetaScreen *screen)
776610
   MetaDisplay *display = screen->display;
776610
   MetaCursor cursor = screen->current_cursor;
776610
   Cursor xcursor;
776610
-  MetaCursorSprite *cursor_sprite;
776610
+  MetaCursorSpriteXcursor *sprite_xcursor;
776610
   MetaBackend *backend = meta_get_backend ();
776610
   MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
776610
 
776610
-  cursor_sprite = meta_cursor_sprite_from_theme (cursor);
776610
+  sprite_xcursor = meta_cursor_sprite_xcursor_new (cursor);
776610
 
776610
   if (meta_is_wayland_compositor ())
776610
-    manage_root_cursor_sprite_scale (screen, cursor_sprite);
776610
+    manage_root_cursor_sprite_scale (screen, sprite_xcursor);
776610
 
776610
-  meta_cursor_tracker_set_root_cursor (cursor_tracker, cursor_sprite);
776610
-  g_object_unref (cursor_sprite);
776610
+  meta_cursor_tracker_set_root_cursor (cursor_tracker,
776610
+                                       META_CURSOR_SPRITE (sprite_xcursor));
776610
+  g_object_unref (sprite_xcursor);
776610
 
776610
   /* Set a cursor for X11 applications that don't specify their own */
776610
   xcursor = meta_display_create_x_cursor (display, cursor);
776610
diff --git a/src/wayland/meta-cursor-sprite-wayland.c b/src/wayland/meta-cursor-sprite-wayland.c
776610
new file mode 100644
776610
index 000000000..7c14960ff
776610
--- /dev/null
776610
+++ b/src/wayland/meta-cursor-sprite-wayland.c
776610
@@ -0,0 +1,75 @@
776610
+/*
776610
+ * Copyright 2015, 2018 Red Hat, Inc.
776610
+ *
776610
+ * This program is free software; you can redistribute it and/or
776610
+ * modify it under the terms of the GNU General Public License as
776610
+ * published by the Free Software Foundation; either version 2 of the
776610
+ * License, or (at your option) any later version.
776610
+ *
776610
+ * This program is distributed in the hope that it will be useful, but
776610
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
776610
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
776610
+ * General Public License for more details.
776610
+ *
776610
+ * You should have received a copy of the GNU General Public License
776610
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
776610
+ *
776610
+ */
776610
+
776610
+#include "config.h"
776610
+
776610
+#include "wayland/meta-cursor-sprite-wayland.h"
776610
+
776610
+struct _MetaCursorSpriteWayland
776610
+{
776610
+  MetaCursorSprite parent;
776610
+
776610
+  MetaWaylandSurface *surface;
776610
+};
776610
+
776610
+G_DEFINE_TYPE (MetaCursorSpriteWayland,
776610
+               meta_cursor_sprite_wayland,
776610
+               META_TYPE_CURSOR_SPRITE)
776610
+
776610
+static void
776610
+meta_cursor_sprite_wayland_realize_texture (MetaCursorSprite *sprite)
776610
+{
776610
+}
776610
+
776610
+static gboolean
776610
+meta_cursor_sprite_wayland_is_animated (MetaCursorSprite *sprite)
776610
+{
776610
+  return FALSE;
776610
+}
776610
+
776610
+MetaCursorSpriteWayland *
776610
+meta_cursor_sprite_wayland_new (MetaWaylandSurface *surface)
776610
+{
776610
+  MetaCursorSpriteWayland *sprite_wayland;
776610
+
776610
+  sprite_wayland = g_object_new (META_TYPE_CURSOR_SPRITE_WAYLAND, NULL);
776610
+  sprite_wayland->surface = surface;
776610
+
776610
+  return sprite_wayland;
776610
+}
776610
+
776610
+MetaWaylandBuffer *
776610
+meta_cursor_sprite_wayland_get_buffer (MetaCursorSpriteWayland *sprite_wayland)
776610
+{
776610
+  return meta_wayland_surface_get_buffer (sprite_wayland->surface);
776610
+}
776610
+
776610
+static void
776610
+meta_cursor_sprite_wayland_init (MetaCursorSpriteWayland *sprite_wayland)
776610
+{
776610
+}
776610
+
776610
+static void
776610
+meta_cursor_sprite_wayland_class_init (MetaCursorSpriteWaylandClass *klass)
776610
+{
776610
+  MetaCursorSpriteClass *cursor_sprite_class = META_CURSOR_SPRITE_CLASS (klass);
776610
+
776610
+  cursor_sprite_class->realize_texture =
776610
+    meta_cursor_sprite_wayland_realize_texture;
776610
+  cursor_sprite_class->is_animated = meta_cursor_sprite_wayland_is_animated;
776610
+}
776610
diff --git a/src/wayland/meta-cursor-sprite-wayland.h b/src/wayland/meta-cursor-sprite-wayland.h
776610
new file mode 100644
776610
index 000000000..107698f3f
776610
--- /dev/null
776610
+++ b/src/wayland/meta-cursor-sprite-wayland.h
776610
@@ -0,0 +1,35 @@
776610
+/*
776610
+ * Copyright 2013, 2018 Red Hat, Inc.
776610
+ *
776610
+ * This program is free software; you can redistribute it and/or
776610
+ * modify it under the terms of the GNU General Public License as
776610
+ * published by the Free Software Foundation; either version 2 of the
776610
+ * License, or (at your option) any later version.
776610
+ *
776610
+ * This program is distributed in the hope that it will be useful, but
776610
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
776610
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
776610
+ * General Public License for more details.
776610
+ *
776610
+ * You should have received a copy of the GNU General Public License
776610
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
776610
+ *
776610
+ */
776610
+
776610
+#ifndef META_CURSOR_SPRITE_WAYLAND_H
776610
+#define META_CURSOR_SPRITE_WAYLAND_H
776610
+
776610
+#include <glib-object.h>
776610
+
776610
+#include "backends/meta-cursor.h"
776610
+#include "wayland/meta-wayland-surface.h"
776610
+
776610
+#define META_TYPE_CURSOR_SPRITE_WAYLAND meta_cursor_sprite_wayland_get_type ()
776610
+G_DECLARE_FINAL_TYPE (MetaCursorSpriteWayland, meta_cursor_sprite_wayland,
776610
+                      META, CURSOR_SPRITE_WAYLAND, MetaCursorSprite)
776610
+
776610
+MetaCursorSpriteWayland * meta_cursor_sprite_wayland_new (MetaWaylandSurface *surface);
776610
+
776610
+MetaWaylandBuffer * meta_cursor_sprite_wayland_get_buffer (MetaCursorSpriteWayland *sprite_wayland);
776610
+
776610
+#endif /* META_CURSOR_SPRITE_WAYLAND_H */
776610
diff --git a/src/wayland/meta-wayland-buffer.c b/src/wayland/meta-wayland-buffer.c
776610
index 55564492a..c759eefc1 100644
776610
--- a/src/wayland/meta-wayland-buffer.c
776610
+++ b/src/wayland/meta-wayland-buffer.c
776610
@@ -88,6 +88,12 @@ meta_wayland_buffer_from_resource (struct wl_resource *resource)
776610
   return buffer;
776610
 }
776610
 
776610
+struct wl_resource *
776610
+meta_wayland_buffer_get_resource (MetaWaylandBuffer *buffer)
776610
+{
776610
+  return buffer->resource;
776610
+}
776610
+
776610
 static gboolean
776610
 meta_wayland_buffer_is_realized (MetaWaylandBuffer *buffer)
776610
 {
776610
diff --git a/src/wayland/meta-wayland-buffer.h b/src/wayland/meta-wayland-buffer.h
776610
index 5345033c2..e00a41e09 100644
776610
--- a/src/wayland/meta-wayland-buffer.h
776610
+++ b/src/wayland/meta-wayland-buffer.h
776610
@@ -68,6 +68,7 @@ G_DECLARE_FINAL_TYPE (MetaWaylandBuffer, meta_wayland_buffer,
776610
                       META, WAYLAND_BUFFER, GObject);
776610
 
776610
 MetaWaylandBuffer *     meta_wayland_buffer_from_resource       (struct wl_resource    *resource);
776610
+struct wl_resource *    meta_wayland_buffer_get_resource        (MetaWaylandBuffer     *buffer);
776610
 gboolean                meta_wayland_buffer_attach              (MetaWaylandBuffer     *buffer,
776610
                                                                  GError               **error);
776610
 CoglTexture *           meta_wayland_buffer_get_texture         (MetaWaylandBuffer     *buffer);
776610
diff --git a/src/wayland/meta-wayland-surface-role-cursor.c b/src/wayland/meta-wayland-cursor-surface.c
776610
similarity index 52%
776610
rename from src/wayland/meta-wayland-surface-role-cursor.c
776610
rename to src/wayland/meta-wayland-cursor-surface.c
776610
index d118a8917..d08af9e8c 100644
776610
--- a/src/wayland/meta-wayland-surface-role-cursor.c
776610
+++ b/src/wayland/meta-wayland-cursor-surface.c
776610
@@ -23,7 +23,7 @@
776610
 
776610
 #include <cogl/cogl.h>
776610
 #include <cogl/cogl-wayland-server.h>
776610
-#include "meta-wayland-surface-role-cursor.h"
776610
+#include "meta-wayland-cursor-surface.h"
776610
 #include "meta-wayland-buffer.h"
776610
 #include "meta-xwayland.h"
776610
 #include "screen-private.h"
776610
@@ -31,35 +31,38 @@
776610
 #include "backends/meta-backend-private.h"
776610
 #include "backends/meta-logical-monitor.h"
776610
 #include "core/boxes-private.h"
776610
+#include "wayland/meta-cursor-sprite-wayland.h"
776610
 
776610
-typedef struct _MetaWaylandSurfaceRoleCursorPrivate MetaWaylandSurfaceRoleCursorPrivate;
776610
+typedef struct _MetaWaylandCursorSurfacePrivate MetaWaylandCursorSurfacePrivate;
776610
 
776610
-struct _MetaWaylandSurfaceRoleCursorPrivate
776610
+struct _MetaWaylandCursorSurfacePrivate
776610
 {
776610
   int hot_x;
776610
   int hot_y;
776610
-  MetaCursorSprite *cursor_sprite;
776610
+  MetaCursorSpriteWayland *cursor_sprite;
776610
   MetaCursorRenderer *cursor_renderer;
776610
   MetaWaylandBuffer *buffer;
776610
   struct wl_list frame_callbacks;
776610
   gulong cursor_painted_handler_id;
776610
 };
776610
 
776610
-G_DEFINE_TYPE_WITH_PRIVATE (MetaWaylandSurfaceRoleCursor,
776610
-                            meta_wayland_surface_role_cursor,
776610
+G_DEFINE_TYPE_WITH_PRIVATE (MetaWaylandCursorSurface,
776610
+                            meta_wayland_cursor_surface,
776610
                             META_TYPE_WAYLAND_SURFACE_ROLE)
776610
 
776610
 static void
776610
-update_cursor_sprite_texture (MetaWaylandSurfaceRoleCursor *cursor_role)
776610
+update_cursor_sprite_texture (MetaWaylandCursorSurface *cursor_surface)
776610
 {
776610
-  MetaWaylandSurfaceRoleCursorPrivate *priv = meta_wayland_surface_role_cursor_get_instance_private (cursor_role);
776610
-  MetaWaylandSurface *surface = meta_wayland_surface_role_get_surface (META_WAYLAND_SURFACE_ROLE (cursor_role));
776610
+  MetaWaylandCursorSurfacePrivate *priv =
776610
+    meta_wayland_cursor_surface_get_instance_private (cursor_surface);
776610
+  MetaWaylandSurface *surface =
776610
+    meta_wayland_surface_role_get_surface (META_WAYLAND_SURFACE_ROLE (cursor_surface));
776610
   MetaWaylandBuffer *buffer = meta_wayland_surface_get_buffer (surface);
776610
-  MetaCursorSprite *cursor_sprite = priv->cursor_sprite;
776610
+  MetaCursorSprite *cursor_sprite = META_CURSOR_SPRITE (priv->cursor_sprite);
776610
 
776610
   g_return_if_fail (!buffer || buffer->texture);
776610
 
776610
-  if (!priv->cursor_renderer || !cursor_sprite)
776610
+  if (!priv->cursor_renderer)
776610
     return;
776610
 
776610
   if (buffer)
776610
@@ -68,20 +71,6 @@ update_cursor_sprite_texture (MetaWaylandSurfaceRoleCursor *cursor_role)
776610
                                       buffer->texture,
776610
                                       priv->hot_x * surface->scale,
776610
                                       priv->hot_y * surface->scale);
776610
-
776610
-      if (priv->buffer)
776610
-        {
776610
-          struct wl_resource *buffer_resource;
776610
-
776610
-          g_assert (priv->buffer == buffer);
776610
-          buffer_resource = buffer->resource;
776610
-          meta_cursor_renderer_realize_cursor_from_wl_buffer (priv->cursor_renderer,
776610
-                                                              cursor_sprite,
776610
-                                                              buffer_resource);
776610
-
776610
-          meta_wayland_surface_unref_buffer_use_count (surface);
776610
-          g_clear_object (&priv->buffer);
776610
-        }
776610
     }
776610
   else
776610
     {
776610
@@ -92,12 +81,12 @@ update_cursor_sprite_texture (MetaWaylandSurfaceRoleCursor *cursor_role)
776610
 }
776610
 
776610
 static void
776610
-cursor_sprite_prepare_at (MetaCursorSprite             *cursor_sprite,
776610
-                          int                           x,
776610
-                          int                           y,
776610
-                          MetaWaylandSurfaceRoleCursor *cursor_role)
776610
+cursor_sprite_prepare_at (MetaCursorSprite         *cursor_sprite,
776610
+                          int                       x,
776610
+                          int                       y,
776610
+                          MetaWaylandCursorSurface *cursor_surface)
776610
 {
776610
-  MetaWaylandSurfaceRole *role = META_WAYLAND_SURFACE_ROLE (cursor_role);
776610
+  MetaWaylandSurfaceRole *role = META_WAYLAND_SURFACE_ROLE (cursor_surface);
776610
   MetaWaylandSurface *surface = meta_wayland_surface_role_get_surface (role);
776610
 
776610
   if (!meta_xwayland_is_xwayland_surface (surface))
776610
@@ -126,14 +115,14 @@ cursor_sprite_prepare_at (MetaCursorSprite             *cursor_sprite,
776610
 }
776610
 
776610
 static void
776610
-cursor_surface_role_assigned (MetaWaylandSurfaceRole *surface_role)
776610
+meta_wayland_cursor_surface_assigned (MetaWaylandSurfaceRole *surface_role)
776610
 {
776610
   MetaWaylandSurface *surface =
776610
     meta_wayland_surface_role_get_surface (surface_role);
776610
-  MetaWaylandSurfaceRoleCursor *cursor_role =
776610
-    META_WAYLAND_SURFACE_ROLE_CURSOR (surface_role);
776610
-  MetaWaylandSurfaceRoleCursorPrivate *priv =
776610
-    meta_wayland_surface_role_cursor_get_instance_private (cursor_role);
776610
+  MetaWaylandCursorSurface *cursor_surface =
776610
+    META_WAYLAND_CURSOR_SURFACE (surface_role);
776610
+  MetaWaylandCursorSurfacePrivate *priv =
776610
+    meta_wayland_cursor_surface_get_instance_private (cursor_surface);
776610
 
776610
   wl_list_insert_list (&priv->frame_callbacks,
776610
                        &surface->pending_frame_callback_list);
776610
@@ -141,13 +130,13 @@ cursor_surface_role_assigned (MetaWaylandSurfaceRole *surface_role)
776610
 }
776610
 
776610
 static void
776610
-cursor_surface_role_pre_commit (MetaWaylandSurfaceRole  *surface_role,
776610
-                                MetaWaylandPendingState *pending)
776610
+meta_wayland_cursor_surface_pre_commit (MetaWaylandSurfaceRole  *surface_role,
776610
+                                        MetaWaylandPendingState *pending)
776610
 {
776610
-  MetaWaylandSurfaceRoleCursor *cursor_role =
776610
-    META_WAYLAND_SURFACE_ROLE_CURSOR (surface_role);
776610
-  MetaWaylandSurfaceRoleCursorPrivate *priv =
776610
-    meta_wayland_surface_role_cursor_get_instance_private (cursor_role);
776610
+  MetaWaylandCursorSurface *cursor_surface =
776610
+    META_WAYLAND_CURSOR_SURFACE (surface_role);
776610
+  MetaWaylandCursorSurfacePrivate *priv =
776610
+    meta_wayland_cursor_surface_get_instance_private (cursor_surface);
776610
   MetaWaylandSurface *surface =
776610
     meta_wayland_surface_role_get_surface (surface_role);
776610
 
776610
@@ -159,13 +148,13 @@ cursor_surface_role_pre_commit (MetaWaylandSurfaceRole  *surface_role,
776610
 }
776610
 
776610
 static void
776610
-cursor_surface_role_commit (MetaWaylandSurfaceRole  *surface_role,
776610
-                            MetaWaylandPendingState *pending)
776610
+meta_wayland_cursor_surface_commit (MetaWaylandSurfaceRole  *surface_role,
776610
+                                    MetaWaylandPendingState *pending)
776610
 {
776610
-  MetaWaylandSurfaceRoleCursor *cursor_role =
776610
-    META_WAYLAND_SURFACE_ROLE_CURSOR (surface_role);
776610
-  MetaWaylandSurfaceRoleCursorPrivate *priv =
776610
-    meta_wayland_surface_role_cursor_get_instance_private (cursor_role);
776610
+  MetaWaylandCursorSurface *cursor_surface =
776610
+    META_WAYLAND_CURSOR_SURFACE (surface_role);
776610
+  MetaWaylandCursorSurfacePrivate *priv =
776610
+    meta_wayland_cursor_surface_get_instance_private (cursor_surface);
776610
   MetaWaylandSurface *surface =
776610
     meta_wayland_surface_role_get_surface (surface_role);
776610
   MetaWaylandBuffer *buffer = meta_wayland_surface_get_buffer (surface);
776610
@@ -182,19 +171,19 @@ cursor_surface_role_commit (MetaWaylandSurfaceRole  *surface_role,
776610
   wl_list_init (&pending->frame_callback_list);
776610
 
776610
   if (pending->newly_attached)
776610
-    update_cursor_sprite_texture (META_WAYLAND_SURFACE_ROLE_CURSOR (surface_role));
776610
+    update_cursor_sprite_texture (META_WAYLAND_CURSOR_SURFACE (surface_role));
776610
 }
776610
 
776610
 static gboolean
776610
-cursor_surface_role_is_on_logical_monitor (MetaWaylandSurfaceRole *role,
776610
-                                           MetaLogicalMonitor     *logical_monitor)
776610
+meta_wayland_cursor_surface_is_on_logical_monitor (MetaWaylandSurfaceRole *role,
776610
+                                                   MetaLogicalMonitor     *logical_monitor)
776610
 {
776610
   MetaWaylandSurface *surface =
776610
     meta_wayland_surface_role_get_surface (role);
776610
-  MetaWaylandSurfaceRoleCursor *cursor_role =
776610
-    META_WAYLAND_SURFACE_ROLE_CURSOR (surface->role);
776610
-  MetaWaylandSurfaceRoleCursorPrivate *priv =
776610
-    meta_wayland_surface_role_cursor_get_instance_private (cursor_role);
776610
+  MetaWaylandCursorSurface *cursor_surface =
776610
+    META_WAYLAND_CURSOR_SURFACE (surface->role);
776610
+  MetaWaylandCursorSurfacePrivate *priv =
776610
+    meta_wayland_cursor_surface_get_instance_private (cursor_surface);
776610
   ClutterPoint point;
776610
   ClutterRect logical_monitor_rect;
776610
 
776610
@@ -207,12 +196,12 @@ cursor_surface_role_is_on_logical_monitor (MetaWaylandSurfaceRole *role,
776610
 }
776610
 
776610
 static void
776610
-cursor_surface_role_dispose (GObject *object)
776610
+meta_wayland_cursor_surface_dispose (GObject *object)
776610
 {
776610
-  MetaWaylandSurfaceRoleCursor *cursor_role =
776610
-    META_WAYLAND_SURFACE_ROLE_CURSOR (object);
776610
-  MetaWaylandSurfaceRoleCursorPrivate *priv =
776610
-    meta_wayland_surface_role_cursor_get_instance_private (cursor_role);
776610
+  MetaWaylandCursorSurface *cursor_surface =
776610
+    META_WAYLAND_CURSOR_SURFACE (object);
776610
+  MetaWaylandCursorSurfacePrivate *priv =
776610
+    meta_wayland_cursor_surface_get_instance_private (cursor_surface);
776610
   MetaWaylandSurface *surface =
776610
     meta_wayland_surface_role_get_surface (META_WAYLAND_SURFACE_ROLE (object));
776610
   MetaWaylandFrameCallback *cb, *next;
776610
@@ -221,7 +210,7 @@ cursor_surface_role_dispose (GObject *object)
776610
     wl_resource_destroy (cb->resource);
776610
 
776610
   g_signal_handlers_disconnect_by_func (priv->cursor_sprite,
776610
-                                        cursor_sprite_prepare_at, cursor_role);
776610
+                                        cursor_sprite_prepare_at, cursor_surface);
776610
 
776610
   g_clear_object (&priv->cursor_renderer);
776610
   g_clear_object (&priv->cursor_sprite);
776610
@@ -232,18 +221,18 @@ cursor_surface_role_dispose (GObject *object)
776610
       g_clear_object (&priv->buffer);
776610
     }
776610
 
776610
-  G_OBJECT_CLASS (meta_wayland_surface_role_cursor_parent_class)->dispose (object);
776610
+  G_OBJECT_CLASS (meta_wayland_cursor_surface_parent_class)->dispose (object);
776610
 }
776610
 
776610
 static void
776610
-cursor_surface_role_constructed (GObject *object)
776610
+meta_wayland_cursor_surface_constructed (GObject *object)
776610
 {
776610
-  MetaWaylandSurfaceRoleCursor *cursor_role =
776610
-    META_WAYLAND_SURFACE_ROLE_CURSOR (object);
776610
-  MetaWaylandSurfaceRoleCursorPrivate *priv =
776610
-    meta_wayland_surface_role_cursor_get_instance_private (cursor_role);
776610
+  MetaWaylandCursorSurface *cursor_surface =
776610
+    META_WAYLAND_CURSOR_SURFACE (object);
776610
+  MetaWaylandCursorSurfacePrivate *priv =
776610
+    meta_wayland_cursor_surface_get_instance_private (cursor_surface);
776610
   MetaWaylandSurfaceRole *surface_role =
776610
-    META_WAYLAND_SURFACE_ROLE (cursor_role);
776610
+    META_WAYLAND_SURFACE_ROLE (cursor_surface);
776610
   MetaWaylandSurface *surface =
776610
     meta_wayland_surface_role_get_surface (surface_role);
776610
   MetaWaylandBuffer *buffer;
776610
@@ -257,55 +246,57 @@ cursor_surface_role_constructed (GObject *object)
776610
       g_set_object (&priv->buffer, buffer);
776610
       meta_wayland_surface_ref_buffer_use_count (surface);
776610
     }
776610
-}
776610
 
776610
-static void
776610
-meta_wayland_surface_role_cursor_init (MetaWaylandSurfaceRoleCursor *role)
776610
-{
776610
-  MetaWaylandSurfaceRoleCursorPrivate *priv =
776610
-    meta_wayland_surface_role_cursor_get_instance_private (role);
776610
-
776610
-  priv->cursor_sprite = meta_cursor_sprite_new ();
776610
+  priv->cursor_sprite = meta_cursor_sprite_wayland_new (surface);
776610
   g_signal_connect_object (priv->cursor_sprite,
776610
                            "prepare-at",
776610
                            G_CALLBACK (cursor_sprite_prepare_at),
776610
-                           role,
776610
+                           cursor_surface,
776610
                            0);
776610
+}
776610
+
776610
+static void
776610
+meta_wayland_cursor_surface_init (MetaWaylandCursorSurface *role)
776610
+{
776610
+  MetaWaylandCursorSurfacePrivate *priv =
776610
+    meta_wayland_cursor_surface_get_instance_private (role);
776610
+
776610
   wl_list_init (&priv->frame_callbacks);
776610
 }
776610
 
776610
 static void
776610
-meta_wayland_surface_role_cursor_class_init (MetaWaylandSurfaceRoleCursorClass *klass)
776610
+meta_wayland_cursor_surface_class_init (MetaWaylandCursorSurfaceClass *klass)
776610
 {
776610
   MetaWaylandSurfaceRoleClass *surface_role_class =
776610
     META_WAYLAND_SURFACE_ROLE_CLASS (klass);
776610
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
776610
 
776610
-  surface_role_class->assigned = cursor_surface_role_assigned;
776610
-  surface_role_class->pre_commit = cursor_surface_role_pre_commit;
776610
-  surface_role_class->commit = cursor_surface_role_commit;
776610
-  surface_role_class->is_on_logical_monitor = cursor_surface_role_is_on_logical_monitor;
776610
+  surface_role_class->assigned = meta_wayland_cursor_surface_assigned;
776610
+  surface_role_class->pre_commit = meta_wayland_cursor_surface_pre_commit;
776610
+  surface_role_class->commit = meta_wayland_cursor_surface_commit;
776610
+  surface_role_class->is_on_logical_monitor =
776610
+    meta_wayland_cursor_surface_is_on_logical_monitor;
776610
 
776610
-  object_class->constructed = cursor_surface_role_constructed;
776610
-  object_class->dispose = cursor_surface_role_dispose;
776610
+  object_class->constructed = meta_wayland_cursor_surface_constructed;
776610
+  object_class->dispose = meta_wayland_cursor_surface_dispose;
776610
 }
776610
 
776610
 MetaCursorSprite *
776610
-meta_wayland_surface_role_cursor_get_sprite (MetaWaylandSurfaceRoleCursor *cursor_role)
776610
+meta_wayland_cursor_surface_get_sprite (MetaWaylandCursorSurface *cursor_surface)
776610
 {
776610
-  MetaWaylandSurfaceRoleCursorPrivate *priv =
776610
-    meta_wayland_surface_role_cursor_get_instance_private (cursor_role);
776610
+  MetaWaylandCursorSurfacePrivate *priv =
776610
+    meta_wayland_cursor_surface_get_instance_private (cursor_surface);
776610
 
776610
-  return priv->cursor_sprite;
776610
+  return META_CURSOR_SPRITE (priv->cursor_sprite);
776610
 }
776610
 
776610
 void
776610
-meta_wayland_surface_role_cursor_set_hotspot (MetaWaylandSurfaceRoleCursor *cursor_role,
776610
-                                              gint                          hotspot_x,
776610
-                                              gint                          hotspot_y)
776610
+meta_wayland_cursor_surface_set_hotspot (MetaWaylandCursorSurface *cursor_surface,
776610
+                                         int                       hotspot_x,
776610
+                                         int                       hotspot_y)
776610
 {
776610
-  MetaWaylandSurfaceRoleCursorPrivate *priv =
776610
-    meta_wayland_surface_role_cursor_get_instance_private (cursor_role);
776610
+  MetaWaylandCursorSurfacePrivate *priv =
776610
+    meta_wayland_cursor_surface_get_instance_private (cursor_surface);
776610
 
776610
   if (priv->hot_x == hotspot_x &&
776610
       priv->hot_y == hotspot_y)
776610
@@ -313,16 +304,16 @@ meta_wayland_surface_role_cursor_set_hotspot (MetaWaylandSurfaceRoleCursor *curs
776610
 
776610
   priv->hot_x = hotspot_x;
776610
   priv->hot_y = hotspot_y;
776610
-  update_cursor_sprite_texture (cursor_role);
776610
+  update_cursor_sprite_texture (cursor_surface);
776610
 }
776610
 
776610
 void
776610
-meta_wayland_surface_role_cursor_get_hotspot (MetaWaylandSurfaceRoleCursor *cursor_role,
776610
-                                              gint                         *hotspot_x,
776610
-                                              gint                         *hotspot_y)
776610
+meta_wayland_cursor_surface_get_hotspot (MetaWaylandCursorSurface *cursor_surface,
776610
+                                         int                      *hotspot_x,
776610
+                                         int                      *hotspot_y)
776610
 {
776610
-  MetaWaylandSurfaceRoleCursorPrivate *priv =
776610
-    meta_wayland_surface_role_cursor_get_instance_private (cursor_role);
776610
+  MetaWaylandCursorSurfacePrivate *priv =
776610
+    meta_wayland_cursor_surface_get_instance_private (cursor_surface);
776610
 
776610
   if (hotspot_x)
776610
     *hotspot_x = priv->hot_x;
776610
@@ -331,15 +322,15 @@ meta_wayland_surface_role_cursor_get_hotspot (MetaWaylandSurfaceRoleCursor *curs
776610
 }
776610
 
776610
 static void
776610
-on_cursor_painted (MetaCursorRenderer           *renderer,
776610
-                   MetaCursorSprite             *displayed_sprite,
776610
-                   MetaWaylandSurfaceRoleCursor *cursor_role)
776610
+on_cursor_painted (MetaCursorRenderer       *renderer,
776610
+                   MetaCursorSprite         *displayed_sprite,
776610
+                   MetaWaylandCursorSurface *cursor_surface)
776610
 {
776610
-  MetaWaylandSurfaceRoleCursorPrivate *priv =
776610
-    meta_wayland_surface_role_cursor_get_instance_private (cursor_role);
776610
+  MetaWaylandCursorSurfacePrivate *priv =
776610
+    meta_wayland_cursor_surface_get_instance_private (cursor_surface);
776610
   guint32 time = (guint32) (g_get_monotonic_time () / 1000);
776610
 
776610
-  if (displayed_sprite != priv->cursor_sprite)
776610
+  if (displayed_sprite != META_CURSOR_SPRITE (priv->cursor_sprite))
776610
     return;
776610
 
776610
   while (!wl_list_empty (&priv->frame_callbacks))
776610
@@ -353,11 +344,11 @@ on_cursor_painted (MetaCursorRenderer           *renderer,
776610
 }
776610
 
776610
 void
776610
-meta_wayland_surface_role_cursor_set_renderer (MetaWaylandSurfaceRoleCursor *cursor_role,
776610
-                                               MetaCursorRenderer           *renderer)
776610
+meta_wayland_cursor_surface_set_renderer (MetaWaylandCursorSurface *cursor_surface,
776610
+                                          MetaCursorRenderer       *renderer)
776610
 {
776610
-  MetaWaylandSurfaceRoleCursorPrivate *priv =
776610
-    meta_wayland_surface_role_cursor_get_instance_private (cursor_role);
776610
+  MetaWaylandCursorSurfacePrivate *priv =
776610
+    meta_wayland_cursor_surface_get_instance_private (cursor_surface);
776610
 
776610
   if (priv->cursor_renderer == renderer)
776610
     return;
776610
@@ -373,19 +364,19 @@ meta_wayland_surface_role_cursor_set_renderer (MetaWaylandSurfaceRoleCursor *cur
776610
     {
776610
       priv->cursor_painted_handler_id =
776610
         g_signal_connect_object (renderer, "cursor-painted",
776610
-                                 G_CALLBACK (on_cursor_painted), cursor_role, 0);
776610
+                                 G_CALLBACK (on_cursor_painted), cursor_surface, 0);
776610
       g_object_ref (renderer);
776610
     }
776610
 
776610
   priv->cursor_renderer = renderer;
776610
-  update_cursor_sprite_texture (cursor_role);
776610
+  update_cursor_sprite_texture (cursor_surface);
776610
 }
776610
 
776610
 MetaCursorRenderer *
776610
-meta_wayland_surface_role_cursor_get_renderer (MetaWaylandSurfaceRoleCursor *cursor_role)
776610
+meta_wayland_cursor_surface_get_renderer (MetaWaylandCursorSurface *cursor_surface)
776610
 {
776610
-  MetaWaylandSurfaceRoleCursorPrivate *priv =
776610
-    meta_wayland_surface_role_cursor_get_instance_private (cursor_role);
776610
+  MetaWaylandCursorSurfacePrivate *priv =
776610
+    meta_wayland_cursor_surface_get_instance_private (cursor_surface);
776610
 
776610
   return priv->cursor_renderer;
776610
 }
776610
diff --git a/src/wayland/meta-wayland-cursor-surface.h b/src/wayland/meta-wayland-cursor-surface.h
776610
new file mode 100644
776610
index 000000000..2461a85b3
776610
--- /dev/null
776610
+++ b/src/wayland/meta-wayland-cursor-surface.h
776610
@@ -0,0 +1,52 @@
776610
+/*
776610
+ * Wayland Support
776610
+ *
776610
+ * Copyright (C) 2015 Red Hat, Inc.
776610
+ *
776610
+ * This program is free software; you can redistribute it and/or
776610
+ * modify it under the terms of the GNU General Public License as
776610
+ * published by the Free Software Foundation; either version 2 of the
776610
+ * License, or (at your option) any later version.
776610
+ *
776610
+ * This program is distributed in the hope that it will be useful, but
776610
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
776610
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
776610
+ * General Public License for more details.
776610
+ *
776610
+ * You should have received a copy of the GNU General Public License
776610
+ * along with this program; if not, write to the Free Software
776610
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
776610
+ * 02111-1307, USA.
776610
+ */
776610
+
776610
+#ifndef META_WAYLAND_CURSOR_SURFACE_H
776610
+#define META_WAYLAND_CURSOR_SURFACE_H
776610
+
776610
+#include "meta-wayland-surface.h"
776610
+#include "backends/meta-cursor-renderer.h"
776610
+
776610
+struct _MetaWaylandCursorSurfaceClass
776610
+{
776610
+  MetaWaylandSurfaceRoleClass parent_class;
776610
+};
776610
+
776610
+#define META_TYPE_WAYLAND_CURSOR_SURFACE (meta_wayland_cursor_surface_get_type ())
776610
+G_DECLARE_DERIVABLE_TYPE (MetaWaylandCursorSurface,
776610
+                          meta_wayland_cursor_surface,
776610
+                          META, WAYLAND_CURSOR_SURFACE,
776610
+                          MetaWaylandSurfaceRole);
776610
+
776610
+MetaCursorSprite *   meta_wayland_cursor_surface_get_sprite   (MetaWaylandCursorSurface *cursor_surface);
776610
+
776610
+void                 meta_wayland_cursor_surface_set_hotspot  (MetaWaylandCursorSurface *cursor_surface,
776610
+                                                               int                       hotspot_x,
776610
+                                                               int                       hotspot_y);
776610
+void                 meta_wayland_cursor_surface_get_hotspot  (MetaWaylandCursorSurface *cursor_surface,
776610
+                                                               int                       *hotspot_x,
776610
+                                                               int                       *hotspot_y);
776610
+void                 meta_wayland_cursor_surface_set_renderer (MetaWaylandCursorSurface *cursor_surface,
776610
+                                                               MetaCursorRenderer       *renderer);
776610
+MetaCursorRenderer * meta_wayland_cursor_surface_get_renderer (MetaWaylandCursorSurface *cursor_surface);
776610
+
776610
+
776610
+#endif /* META_WAYLAND_CURSOR_SURFACE_H */
776610
diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c
776610
index d5c90c169..e8138576e 100644
776610
--- a/src/wayland/meta-wayland-pointer.c
776610
+++ b/src/wayland/meta-wayland-pointer.c
776610
@@ -55,7 +55,7 @@
776610
 #include "meta-wayland-seat.h"
776610
 #include "meta-wayland-surface.h"
776610
 #include "meta-wayland-buffer.h"
776610
-#include "meta-wayland-surface-role-cursor.h"
776610
+#include "meta-wayland-cursor-surface.h"
776610
 #include "meta-xwayland.h"
776610
 #include "meta-cursor.h"
776610
 #include "meta-cursor-tracker-private.h"
776610
@@ -1025,10 +1025,10 @@ meta_wayland_pointer_update_cursor_surface (MetaWaylandPointer *pointer)
776610
 
776610
       if (pointer->cursor_surface)
776610
         {
776610
-          MetaWaylandSurfaceRoleCursor *cursor_role =
776610
-            META_WAYLAND_SURFACE_ROLE_CURSOR (pointer->cursor_surface->role);
776610
+          MetaWaylandCursorSurface *cursor_surface =
776610
+            META_WAYLAND_CURSOR_SURFACE (pointer->cursor_surface->role);
776610
 
776610
-          cursor_sprite = meta_wayland_surface_role_cursor_get_sprite (cursor_role);
776610
+          cursor_sprite = meta_wayland_cursor_surface_get_sprite (cursor_surface);
776610
         }
776610
 
776610
       meta_cursor_tracker_set_window_cursor (cursor_tracker, cursor_sprite);
776610
@@ -1102,7 +1102,7 @@ pointer_set_cursor (struct wl_client *client,
776610
 
776610
   if (surface &&
776610
       !meta_wayland_surface_assign_role (surface,
776610
-                                         META_TYPE_WAYLAND_SURFACE_ROLE_CURSOR,
776610
+                                         META_TYPE_WAYLAND_CURSOR_SURFACE,
776610
                                          NULL))
776610
     {
776610
       wl_resource_post_error (resource, WL_POINTER_ERROR_ROLE,
776610
@@ -1115,13 +1115,13 @@ pointer_set_cursor (struct wl_client *client,
776610
     {
776610
       MetaCursorRenderer *cursor_renderer =
776610
         meta_backend_get_cursor_renderer (meta_get_backend ());
776610
-      MetaWaylandSurfaceRoleCursor *cursor_role;
776610
+      MetaWaylandCursorSurface *cursor_surface;
776610
 
776610
-      cursor_role = META_WAYLAND_SURFACE_ROLE_CURSOR (surface->role);
776610
-      meta_wayland_surface_role_cursor_set_renderer (cursor_role,
776610
-                                                     cursor_renderer);
776610
-      meta_wayland_surface_role_cursor_set_hotspot (cursor_role,
776610
-                                                    hot_x, hot_y);
776610
+      cursor_surface = META_WAYLAND_CURSOR_SURFACE (surface->role);
776610
+      meta_wayland_cursor_surface_set_renderer (cursor_surface,
776610
+                                                cursor_renderer);
776610
+      meta_wayland_cursor_surface_set_hotspot (cursor_surface,
776610
+                                               hot_x, hot_y);
776610
     }
776610
 
776610
   meta_wayland_pointer_set_cursor_surface (pointer, surface);
776610
diff --git a/src/wayland/meta-wayland-surface-role-cursor.h b/src/wayland/meta-wayland-surface-role-cursor.h
776610
deleted file mode 100644
776610
index b6d6d4a6a..000000000
776610
--- a/src/wayland/meta-wayland-surface-role-cursor.h
776610
+++ /dev/null
776610
@@ -1,52 +0,0 @@
776610
-/*
776610
- * Wayland Support
776610
- *
776610
- * Copyright (C) 2015 Red Hat, Inc.
776610
- *
776610
- * This program is free software; you can redistribute it and/or
776610
- * modify it under the terms of the GNU General Public License as
776610
- * published by the Free Software Foundation; either version 2 of the
776610
- * License, or (at your option) any later version.
776610
- *
776610
- * This program is distributed in the hope that it will be useful, but
776610
- * WITHOUT ANY WARRANTY; without even the implied warranty of
776610
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
776610
- * General Public License for more details.
776610
- *
776610
- * You should have received a copy of the GNU General Public License
776610
- * along with this program; if not, write to the Free Software
776610
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
776610
- * 02111-1307, USA.
776610
- */
776610
-
776610
-#ifndef META_WAYLAND_SURFACE_ROLE_CURSOR_H
776610
-#define META_WAYLAND_SURFACE_ROLE_CURSOR_H
776610
-
776610
-#include "meta-wayland-surface.h"
776610
-#include "backends/meta-cursor-renderer.h"
776610
-
776610
-struct _MetaWaylandSurfaceRoleCursorClass
776610
-{
776610
-  MetaWaylandSurfaceRoleClass parent_class;
776610
-};
776610
-
776610
-#define META_TYPE_WAYLAND_SURFACE_ROLE_CURSOR (meta_wayland_surface_role_cursor_get_type ())
776610
-G_DECLARE_DERIVABLE_TYPE (MetaWaylandSurfaceRoleCursor,
776610
-                          meta_wayland_surface_role_cursor,
776610
-                          META, WAYLAND_SURFACE_ROLE_CURSOR,
776610
-                          MetaWaylandSurfaceRole);
776610
-
776610
-MetaCursorSprite *   meta_wayland_surface_role_cursor_get_sprite   (MetaWaylandSurfaceRoleCursor *cursor_role);
776610
-
776610
-void                 meta_wayland_surface_role_cursor_set_hotspot  (MetaWaylandSurfaceRoleCursor *cursor_role,
776610
-                                                                    gint                          hotspot_x,
776610
-                                                                    gint                          hotspot_y);
776610
-void                 meta_wayland_surface_role_cursor_get_hotspot  (MetaWaylandSurfaceRoleCursor *cursor_role,
776610
-                                                                    gint                         *hotspot_x,
776610
-                                                                    gint                         *hotspot_y);
776610
-void                 meta_wayland_surface_role_cursor_set_renderer (MetaWaylandSurfaceRoleCursor *cursor_role,
776610
-                                                                    MetaCursorRenderer           *renderer);
776610
-MetaCursorRenderer * meta_wayland_surface_role_cursor_get_renderer (MetaWaylandSurfaceRoleCursor *cursor_role);
776610
-
776610
-
776610
-#endif /* META_WAYLAND_SURFACE_ROLE_CURSOR_H */
776610
diff --git a/src/wayland/meta-wayland-surface-role-tablet-cursor.c b/src/wayland/meta-wayland-tablet-cursor-surface.c
776610
similarity index 63%
776610
rename from src/wayland/meta-wayland-surface-role-tablet-cursor.c
776610
rename to src/wayland/meta-wayland-tablet-cursor-surface.c
776610
index 075a5e4f6..808bf2820 100644
776610
--- a/src/wayland/meta-wayland-surface-role-tablet-cursor.c
776610
+++ b/src/wayland/meta-wayland-tablet-cursor-surface.c
776610
@@ -20,23 +20,24 @@
776610
  */
776610
 
776610
 #include "config.h"
776610
-#include "meta-wayland-surface-role-tablet-cursor.h"
776610
 
776610
-struct _MetaWaylandSurfaceRoleTabletCursor
776610
+#include "meta-wayland-tablet-cursor-surface.h"
776610
+
776610
+struct _MetaWaylandTabletCursorSurface
776610
 {
776610
-  MetaWaylandSurfaceRoleCursor parent;
776610
+  MetaWaylandCursorSurface parent;
776610
 };
776610
 
776610
-G_DEFINE_TYPE (MetaWaylandSurfaceRoleTabletCursor,
776610
-               meta_wayland_surface_role_tablet_cursor,
776610
-               META_TYPE_WAYLAND_SURFACE_ROLE_CURSOR)
776610
+G_DEFINE_TYPE (MetaWaylandTabletCursorSurface,
776610
+               meta_wayland_tablet_cursor_surface,
776610
+               META_TYPE_WAYLAND_CURSOR_SURFACE)
776610
 
776610
 static void
776610
-meta_wayland_surface_role_tablet_cursor_init (MetaWaylandSurfaceRoleTabletCursor *role)
776610
+meta_wayland_tablet_cursor_surface_init (MetaWaylandTabletCursorSurface *role)
776610
 {
776610
 }
776610
 
776610
 static void
776610
-meta_wayland_surface_role_tablet_cursor_class_init (MetaWaylandSurfaceRoleTabletCursorClass *klass)
776610
+meta_wayland_tablet_cursor_surface_class_init (MetaWaylandTabletCursorSurfaceClass *klass)
776610
 {
776610
 }
776610
diff --git a/src/wayland/meta-wayland-surface-role-tablet-cursor.h b/src/wayland/meta-wayland-tablet-cursor-surface.h
776610
similarity index 59%
776610
rename from src/wayland/meta-wayland-surface-role-tablet-cursor.h
776610
rename to src/wayland/meta-wayland-tablet-cursor-surface.h
776610
index 69fc6cf0f..5c5c198f5 100644
776610
--- a/src/wayland/meta-wayland-surface-role-tablet-cursor.h
776610
+++ b/src/wayland/meta-wayland-tablet-cursor-surface.h
776610
@@ -19,15 +19,15 @@
776610
  * 02111-1307, USA.
776610
  */
776610
 
776610
-#ifndef META_WAYLAND_SURFACE_ROLE_TABLET_CURSOR_H
776610
-#define META_WAYLAND_SURFACE_ROLE_TABLET_CURSOR_H
776610
+#ifndef META_WAYLAND_TABLET_CURSOR_SURFACE_H
776610
+#define META_WAYLAND_TABLET_CURSOR_SURFACE_H
776610
 
776610
-#include "meta-wayland-surface-role-cursor.h"
776610
+#include "meta-wayland-cursor-surface.h"
776610
 
776610
-#define META_TYPE_WAYLAND_SURFACE_ROLE_TABLET_CURSOR (meta_wayland_surface_role_tablet_cursor_get_type ())
776610
-G_DECLARE_FINAL_TYPE (MetaWaylandSurfaceRoleTabletCursor,
776610
-                      meta_wayland_surface_role_tablet_cursor,
776610
-                      META, WAYLAND_SURFACE_ROLE_TABLET_CURSOR,
776610
-                      MetaWaylandSurfaceRoleCursor);
776610
+#define META_TYPE_WAYLAND_TABLET_CURSOR_SURFACE (meta_wayland_tablet_cursor_surface_get_type ())
776610
+G_DECLARE_FINAL_TYPE (MetaWaylandTabletCursorSurface,
776610
+                      meta_wayland_tablet_cursor_surface,
776610
+                      META, WAYLAND_TABLET_CURSOR_SURFACE,
776610
+                      MetaWaylandCursorSurface)
776610
 
776610
-#endif /* META_WAYLAND_SURFACE_ROLE_TABLET_CURSOR_H */
776610
+#endif /* META_WAYLAND_TABLET_CURSOR_SURFACE_H */
776610
diff --git a/src/wayland/meta-wayland-tablet-tool.c b/src/wayland/meta-wayland-tablet-tool.c
776610
index 4b57d4156..d373f8d25 100644
776610
--- a/src/wayland/meta-wayland-tablet-tool.c
776610
+++ b/src/wayland/meta-wayland-tablet-tool.c
776610
@@ -31,7 +31,7 @@
776610
 #include <wayland-server.h>
776610
 #include "tablet-unstable-v2-server-protocol.h"
776610
 #include "meta-wayland-private.h"
776610
-#include "meta-wayland-surface-role-tablet-cursor.h"
776610
+#include "meta-wayland-tablet-cursor-surface.h"
776610
 #include "meta-surface-actor-wayland.h"
776610
 #include "meta-wayland-tablet.h"
776610
 #include "meta-wayland-tablet-seat.h"
776610
@@ -90,16 +90,16 @@ meta_wayland_tablet_tool_update_cursor_surface (MetaWaylandTabletTool *tool)
776610
       if (tool->cursor_surface &&
776610
           meta_wayland_surface_get_buffer (tool->cursor_surface))
776610
         {
776610
-          MetaWaylandSurfaceRoleCursor *cursor_role =
776610
-            META_WAYLAND_SURFACE_ROLE_CURSOR (tool->cursor_surface->role);
776610
+          MetaWaylandCursorSurface *cursor_surface =
776610
+            META_WAYLAND_CURSOR_SURFACE (tool->cursor_surface->role);
776610
 
776610
-          cursor = meta_wayland_surface_role_cursor_get_sprite (cursor_role);
776610
+          cursor = meta_wayland_cursor_surface_get_sprite (cursor_surface);
776610
         }
776610
       else
776610
         cursor = NULL;
776610
     }
776610
   else if (tool->current_tablet)
776610
-    cursor = tool->default_sprite;
776610
+    cursor = META_CURSOR_SPRITE (tool->default_sprite);
776610
   else
776610
     cursor = NULL;
776610
 
776610
@@ -382,10 +382,10 @@ tablet_tool_handle_cursor_surface_destroy (struct wl_listener *listener,
776610
 }
776610
 
776610
 static void
776610
-tool_cursor_prepare_at (MetaCursorSprite      *cursor_sprite,
776610
-                        int                    x,
776610
-                        int                    y,
776610
-                        MetaWaylandTabletTool *tool)
776610
+tool_cursor_prepare_at (MetaCursorSpriteXcursor *sprite_xcursor,
776610
+                        int                      x,
776610
+                        int                      y,
776610
+                        MetaWaylandTabletTool   *tool)
776610
 {
776610
   MetaBackend *backend = meta_get_backend ();
776610
   MetaMonitorManager *monitor_manager =
776610
@@ -397,7 +397,8 @@ tool_cursor_prepare_at (MetaCursorSprite      *cursor_sprite,
776610
 
776610
   /* Reload the cursor texture if the scale has changed. */
776610
   if (logical_monitor)
776610
-    meta_cursor_sprite_set_theme_scale (cursor_sprite, logical_monitor->scale);
776610
+    meta_cursor_sprite_xcursor_set_theme_scale (sprite_xcursor,
776610
+                                                logical_monitor->scale);
776610
 }
776610
 
776610
 MetaWaylandTabletTool *
776610
@@ -417,7 +418,7 @@ meta_wayland_tablet_tool_new (MetaWaylandTabletSeat  *seat,
776610
   tool->focus_surface_destroy_listener.notify = tablet_tool_handle_focus_surface_destroy;
776610
   tool->cursor_surface_destroy_listener.notify = tablet_tool_handle_cursor_surface_destroy;
776610
 
776610
-  tool->default_sprite = meta_cursor_sprite_from_theme (META_CURSOR_CROSSHAIR);
776610
+  tool->default_sprite = meta_cursor_sprite_xcursor_new (META_CURSOR_CROSSHAIR);
776610
   tool->prepare_at_signal_id =
776610
     g_signal_connect (tool->default_sprite, "prepare-at",
776610
                       G_CALLBACK (tool_cursor_prepare_at), tool);
776610
@@ -471,7 +472,7 @@ tool_set_cursor (struct wl_client   *client,
776610
 
776610
   if (surface &&
776610
       !meta_wayland_surface_assign_role (surface,
776610
-                                         META_TYPE_WAYLAND_SURFACE_ROLE_TABLET_CURSOR,
776610
+                                         META_TYPE_WAYLAND_TABLET_CURSOR_SURFACE,
776610
                                          NULL))
776610
     {
776610
       wl_resource_post_error (resource, WL_POINTER_ERROR_ROLE,
776610
@@ -482,13 +483,13 @@ tool_set_cursor (struct wl_client   *client,
776610
 
776610
   if (surface)
776610
     {
776610
-      MetaWaylandSurfaceRoleCursor *cursor_role;
776610
+      MetaWaylandCursorSurface *cursor_surface;
776610
 
776610
-      cursor_role = META_WAYLAND_SURFACE_ROLE_CURSOR (surface->role);
776610
-      meta_wayland_surface_role_cursor_set_renderer (cursor_role,
776610
-                                                     tool->cursor_renderer);
776610
-      meta_wayland_surface_role_cursor_set_hotspot (cursor_role,
776610
-                                                    hotspot_x, hotspot_y);
776610
+      cursor_surface = META_WAYLAND_CURSOR_SURFACE (surface->role);
776610
+      meta_wayland_cursor_surface_set_renderer (cursor_surface,
776610
+                                                tool->cursor_renderer);
776610
+      meta_wayland_cursor_surface_set_hotspot (cursor_surface,
776610
+                                               hotspot_x, hotspot_y);
776610
     }
776610
 
776610
   meta_wayland_tablet_tool_set_cursor_surface (tool, surface);
776610
diff --git a/src/wayland/meta-wayland-tablet-tool.h b/src/wayland/meta-wayland-tablet-tool.h
776610
index 8cd930086..011972fc2 100644
776610
--- a/src/wayland/meta-wayland-tablet-tool.h
776610
+++ b/src/wayland/meta-wayland-tablet-tool.h
776610
@@ -28,6 +28,7 @@
776610
 
776610
 #include "meta-wayland-types.h"
776610
 #include "meta-cursor-renderer.h"
776610
+#include "backends/meta-cursor-sprite-xcursor.h"
776610
 
776610
 struct _MetaWaylandTabletTool
776610
 {
776610
@@ -43,7 +44,7 @@ struct _MetaWaylandTabletTool
776610
   MetaWaylandSurface *cursor_surface;
776610
   struct wl_listener cursor_surface_destroy_listener;
776610
   MetaCursorRenderer *cursor_renderer;
776610
-  MetaCursorSprite *default_sprite;
776610
+  MetaCursorSpriteXcursor *default_sprite;
776610
   guint prepare_at_signal_id;
776610
 
776610
   MetaWaylandSurface *current;