From bcbcd6a68ccb1910a885fcad869dbf1624df4000 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 16 Nov 2017 19:16:54 +0100 Subject: [PATCH] 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 file changed, 14 insertions(+) diff --git a/src/backends/meta-cursor.c b/src/backends/meta-cursor.c index 256b0ca56..ccd0ab017 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); }