diff --git a/src/backends/meta-cursor-sprite-xcursor.c b/src/backends/meta-cursor-sprite-xcursor.c index 5284f28ea..188c7a254 100644 --- a/src/backends/meta-cursor-sprite-xcursor.c +++ b/src/backends/meta-cursor-sprite-xcursor.c @@ -316,13 +316,15 @@ load_cursor_from_theme (MetaCursorSprite *sprite) load_from_current_xcursor_image (sprite_xcursor); } -static void +static gboolean meta_cursor_sprite_xcursor_realize_texture (MetaCursorSprite *sprite) { MetaCursorSpriteXcursor *sprite_xcursor = META_CURSOR_SPRITE_XCURSOR (sprite); if (sprite_xcursor->theme_dirty) load_cursor_from_theme (sprite); + + return TRUE; } MetaCursorSpriteXcursor * diff --git a/src/backends/meta-cursor-tracker.c b/src/backends/meta-cursor-tracker.c index 0df4d73cd..116215195 100644 --- a/src/backends/meta-cursor-tracker.c +++ b/src/backends/meta-cursor-tracker.c @@ -130,6 +130,7 @@ update_displayed_cursor (MetaCursorTracker *tracker) if (cursor) { + meta_cursor_sprite_invalidate (cursor); g_signal_connect (cursor, "texture-changed", G_CALLBACK (cursor_texture_updated), tracker); } diff --git a/src/backends/meta-cursor.c b/src/backends/meta-cursor.c index d0fb2ba68..a0abd9cd6 100644 --- a/src/backends/meta-cursor.c +++ b/src/backends/meta-cursor.c @@ -81,6 +81,7 @@ meta_cursor_sprite_clear_texture (MetaCursorSprite *sprite) meta_cursor_sprite_get_instance_private (sprite); g_clear_pointer (&priv->texture, cogl_object_unref); + meta_cursor_sprite_invalidate (sprite); } void @@ -98,6 +99,8 @@ meta_cursor_sprite_set_texture (MetaCursorSprite *sprite, priv->hot_x = hot_x; priv->hot_y = hot_y; + meta_cursor_sprite_invalidate (sprite); + g_signal_emit (sprite, signals[TEXTURE_CHANGED], 0); } @@ -108,6 +111,9 @@ meta_cursor_sprite_set_texture_scale (MetaCursorSprite *sprite, MetaCursorSpritePrivate *priv = meta_cursor_sprite_get_instance_private (sprite); + if (priv->texture_scale != scale) + meta_cursor_sprite_invalidate (sprite); + priv->texture_scale = scale; } @@ -118,6 +124,9 @@ meta_cursor_sprite_set_texture_transform (MetaCursorSprite *sprite, MetaCursorSpritePrivate *priv = meta_cursor_sprite_get_instance_private (sprite); + if (priv->texture_transform != transform) + meta_cursor_sprite_invalidate (sprite); + priv->texture_transform = transform; } @@ -187,10 +196,19 @@ meta_cursor_sprite_prepare_at (MetaCursorSprite *sprite, g_signal_emit (sprite, signals[PREPARE_AT], 0, best_scale, x, y); } -void +gboolean meta_cursor_sprite_realize_texture (MetaCursorSprite *sprite) { - META_CURSOR_SPRITE_GET_CLASS (sprite)->realize_texture (sprite); + return META_CURSOR_SPRITE_GET_CLASS (sprite)->realize_texture (sprite); +} + +void +meta_cursor_sprite_invalidate (MetaCursorSprite *sprite) +{ + MetaCursorSpriteClass *sprite_class = META_CURSOR_SPRITE_GET_CLASS (sprite); + + if (sprite_class->invalidate) + sprite_class->invalidate (sprite); } static void diff --git a/src/backends/meta-cursor.h b/src/backends/meta-cursor.h index a65e128c4..214394dd4 100644 --- a/src/backends/meta-cursor.h +++ b/src/backends/meta-cursor.h @@ -36,7 +36,8 @@ struct _MetaCursorSpriteClass { GObjectClass parent_class; - void (* realize_texture) (MetaCursorSprite *sprite); + void (* invalidate) (MetaCursorSprite *sprite); + gboolean (* realize_texture) (MetaCursorSprite *sprite); gboolean (* is_animated) (MetaCursorSprite *sprite); void (* tick_frame) (MetaCursorSprite *sprite); unsigned int (* get_current_frame_time) (MetaCursorSprite *sprite); @@ -47,7 +48,8 @@ void meta_cursor_sprite_prepare_at (MetaCursorSprite *sprite, int x, int y); -void meta_cursor_sprite_realize_texture (MetaCursorSprite *sprite); +void meta_cursor_sprite_invalidate (MetaCursorSprite *sprite); +gboolean meta_cursor_sprite_realize_texture (MetaCursorSprite *sprite); void meta_cursor_sprite_clear_texture (MetaCursorSprite *sprite); diff --git a/src/backends/native/meta-cursor-renderer-native.c b/src/backends/native/meta-cursor-renderer-native.c index 3f6ff48ef..8efdaf777 100644 --- a/src/backends/native/meta-cursor-renderer-native.c +++ b/src/backends/native/meta-cursor-renderer-native.c @@ -1074,9 +1074,13 @@ meta_cursor_renderer_native_update_cursor (MetaCursorRenderer *renderer, if (cursor_sprite) { - meta_cursor_sprite_realize_texture (cursor_sprite); + gboolean realized; + + realized = meta_cursor_sprite_realize_texture (cursor_sprite); gpus = calculate_cursor_sprite_gpus (renderer, cursor_sprite); - realize_cursor_sprite (renderer, cursor_sprite, gpus); + + if (realized) + realize_cursor_sprite (renderer, cursor_sprite, gpus); } maybe_schedule_cursor_sprite_animation_frame (native, cursor_sprite); diff --git a/src/backends/x11/cm/meta-cursor-sprite-xfixes.c b/src/backends/x11/cm/meta-cursor-sprite-xfixes.c index 0c524668e..ae6e2b6ac 100644 --- a/src/backends/x11/cm/meta-cursor-sprite-xfixes.c +++ b/src/backends/x11/cm/meta-cursor-sprite-xfixes.c @@ -52,9 +52,10 @@ G_DEFINE_TYPE_WITH_CODE (MetaCursorSpriteXfixes, G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, meta_screen_cast_xfixes_init_initable_iface)) -static void +static gboolean meta_cursor_sprite_xfixes_realize_texture (MetaCursorSprite *sprite) { + return TRUE; } static gboolean diff --git a/src/wayland/meta-cursor-sprite-wayland.c b/src/wayland/meta-cursor-sprite-wayland.c index 7c14960ff..c4e532b0f 100644 --- a/src/wayland/meta-cursor-sprite-wayland.c +++ b/src/wayland/meta-cursor-sprite-wayland.c @@ -31,9 +31,10 @@ G_DEFINE_TYPE (MetaCursorSpriteWayland, meta_cursor_sprite_wayland, META_TYPE_CURSOR_SPRITE) -static void +static gboolean meta_cursor_sprite_wayland_realize_texture (MetaCursorSprite *sprite) { + return TRUE; } static gboolean