[mutter/wip/carlosg/unthrottled-wayland: 974/978] wayland: Mark sprite as invalid after cursor changes




commit 70a80623e108544ac5281ebdecb2193e3fb8439b
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Jul 5 15:50:06 2021 +0200

    wayland: Mark sprite as invalid after cursor changes
    
    This will be used to hint the backend that the cursor surface
    might need uploading again.

 src/wayland/meta-cursor-sprite-wayland.c | 19 ++++++++++++++++++-
 src/wayland/meta-cursor-sprite-wayland.h |  2 ++
 src/wayland/meta-wayland-pointer.c       |  5 +++++
 3 files changed, 25 insertions(+), 1 deletion(-)
---
diff --git a/src/wayland/meta-cursor-sprite-wayland.c b/src/wayland/meta-cursor-sprite-wayland.c
index c4e532b0f4..9b8558a63b 100644
--- a/src/wayland/meta-cursor-sprite-wayland.c
+++ b/src/wayland/meta-cursor-sprite-wayland.c
@@ -25,6 +25,7 @@ struct _MetaCursorSpriteWayland
   MetaCursorSprite parent;
 
   MetaWaylandSurface *surface;
+  gboolean invalidated;
 };
 
 G_DEFINE_TYPE (MetaCursorSpriteWayland,
@@ -34,7 +35,17 @@ G_DEFINE_TYPE (MetaCursorSpriteWayland,
 static gboolean
 meta_cursor_sprite_wayland_realize_texture (MetaCursorSprite *sprite)
 {
-  return TRUE;
+  MetaCursorSpriteWayland *sprite_wayland;
+
+  sprite_wayland = META_CURSOR_SPRITE_WAYLAND (sprite);
+
+  if (sprite_wayland->invalidated)
+    {
+      sprite_wayland->invalidated = FALSE;
+      return TRUE;
+    }
+
+  return FALSE;
 }
 
 static gboolean
@@ -74,3 +85,9 @@ meta_cursor_sprite_wayland_class_init (MetaCursorSpriteWaylandClass *klass)
     meta_cursor_sprite_wayland_realize_texture;
   cursor_sprite_class->is_animated = meta_cursor_sprite_wayland_is_animated;
 }
+
+void
+meta_cursor_sprite_wayland_invalidate (MetaCursorSpriteWayland *sprite_wayland)
+{
+  sprite_wayland->invalidated = TRUE;
+}
diff --git a/src/wayland/meta-cursor-sprite-wayland.h b/src/wayland/meta-cursor-sprite-wayland.h
index 107698f3f9..98e1527958 100644
--- a/src/wayland/meta-cursor-sprite-wayland.h
+++ b/src/wayland/meta-cursor-sprite-wayland.h
@@ -32,4 +32,6 @@ MetaCursorSpriteWayland * meta_cursor_sprite_wayland_new (MetaWaylandSurface *su
 
 MetaWaylandBuffer * meta_cursor_sprite_wayland_get_buffer (MetaCursorSpriteWayland *sprite_wayland);
 
+void meta_cursor_sprite_wayland_invalidate (MetaCursorSpriteWayland *sprite_wayland);
+
 #endif /* META_CURSOR_SPRITE_WAYLAND_H */
diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c
index 3132abfd22..f670b8e97b 100644
--- a/src/wayland/meta-wayland-pointer.c
+++ b/src/wayland/meta-wayland-pointer.c
@@ -55,6 +55,7 @@
 #include "cogl/cogl.h"
 #include "compositor/meta-surface-actor-wayland.h"
 #include "meta/meta-cursor-tracker.h"
+#include "wayland/meta-cursor-sprite-wayland.h"
 #include "wayland/meta-wayland-buffer.h"
 #include "wayland/meta-wayland-cursor-surface.h"
 #include "wayland/meta-wayland-pointer.h"
@@ -1150,12 +1151,16 @@ pointer_set_cursor (struct wl_client *client,
         meta_backend_get_cursor_renderer_for_device (meta_get_backend (),
                                                      device);
       MetaWaylandCursorSurface *cursor_surface;
+      MetaCursorSprite *cursor_sprite;
 
       cursor_surface = META_WAYLAND_CURSOR_SURFACE (surface->role);
       meta_wayland_cursor_surface_set_renderer (cursor_surface,
                                                 cursor_renderer);
       meta_wayland_cursor_surface_set_hotspot (cursor_surface,
                                                hot_x, hot_y);
+
+      cursor_sprite = meta_wayland_cursor_surface_get_sprite (cursor_surface);
+      meta_cursor_sprite_wayland_invalidate (META_CURSOR_SPRITE_WAYLAND (cursor_sprite));
     }
 
   meta_wayland_pointer_set_cursor_surface (pointer, surface);


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