[mutter] backends: Add MetaCursorSprite::texture-changed signal



commit bcbcd6a68ccb1910a885fcad869dbf1624df4000
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Nov 16 19:16:54 2017 +0100

    backends: Add MetaCursorSprite::texture-changed signal
    
    As wayland implements the cursor role, it consists of a persistent
    MetaCursorSprite that gets the backing texture changed. This is
    inconvenient for the places using MetaCursorTracker to track cursor
    changes, as they actually track MetaCursorSprites.
    
    This signal will be used to trigger emission of
    MetaCursorTracker::cursor-changed, which will make users able to
    update accordingly.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=754806

 src/backends/meta-cursor.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/src/backends/meta-cursor.c b/src/backends/meta-cursor.c
index 256b0ca..ccd0ab0 100644
--- a/src/backends/meta-cursor.c
+++ b/src/backends/meta-cursor.c
@@ -37,6 +37,7 @@
 
 enum {
   PREPARE_AT,
+  TEXTURE_CHANGED,
 
   LAST_SIGNAL
 };
@@ -266,11 +267,18 @@ meta_cursor_sprite_set_texture (MetaCursorSprite *self,
                                 int               hot_x,
                                 int               hot_y)
 {
+  if (self->texture == COGL_TEXTURE_2D (texture) &&
+      self->hot_x == hot_x &&
+      self->hot_y == hot_y)
+    return;
+
   g_clear_pointer (&self->texture, cogl_object_unref);
   if (texture)
     self->texture = cogl_object_ref (texture);
   self->hot_x = hot_x;
   self->hot_y = hot_y;
+
+  g_signal_emit (self, signals[TEXTURE_CHANGED], 0);
 }
 
 void
@@ -365,4 +373,10 @@ meta_cursor_sprite_class_init (MetaCursorSpriteClass *klass)
                                       G_TYPE_NONE, 2,
                                       G_TYPE_INT,
                                       G_TYPE_INT);
+  signals[TEXTURE_CHANGED] = g_signal_new ("texture-changed",
+                                           G_TYPE_FROM_CLASS (object_class),
+                                           G_SIGNAL_RUN_LAST,
+                                           0,
+                                           NULL, NULL, NULL,
+                                           G_TYPE_NONE, 0);
 }


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