From 2d010c9b84fbe874bcedea9d23c6dd78353b1a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 31 Jul 2020 21:13:45 +0200 Subject: [PATCH] cursor-renderer: Disconnect the overlay cursor from the displayed cursor The displayed cursor is the one displayed on the screen, e.g. via the hardware cursor plane, by Xorg, or using the stage overlay. When screen recording under X11, we don't get a stream of pointer and cursor updates, as they might be grabbed by some other client. Because of this, the cursor tracker or cursor renderer are not kept up to date with positional and cursor state. To be able to use the stage overlays when recording, we need to be able to update the overlay without updating the displayed cursor, as we shouldn't update the X server with cursor state we just retrieved from it. Thus, to achieve this, create a separate overlay cursor pointer. When being a display server, they are always the same, but when using X11, during screen recording, the overlay one will be polled at a fixed interval to get a somewhat up to date state. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1391 --- src/backends/meta-cursor-renderer.c | 15 ++++++++++----- src/backends/meta-cursor-renderer.h | 3 +++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/backends/meta-cursor-renderer.c b/src/backends/meta-cursor-renderer.c index d3ea5ec21..ac81deff6 100644 --- a/src/backends/meta-cursor-renderer.c +++ b/src/backends/meta-cursor-renderer.c @@ -58,6 +58,8 @@ struct _MetaCursorRendererPrivate float current_y; MetaCursorSprite *displayed_cursor; + MetaCursorSprite *overlay_cursor; + MetaOverlay *stage_overlay; gboolean handled_by_backend; gulong after_paint_handler_id; @@ -123,15 +125,17 @@ align_cursor_position (MetaCursorRenderer *renderer, graphene_rect_offset (rect, view_layout.x, view_layout.y); } -static void -update_stage_overlay (MetaCursorRenderer *renderer, - MetaCursorSprite *cursor_sprite) +void +meta_cursor_renderer_update_stage_overlay (MetaCursorRenderer *renderer, + MetaCursorSprite *cursor_sprite) { MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer); ClutterActor *stage = meta_backend_get_stage (priv->backend); CoglTexture *texture; graphene_rect_t rect = GRAPHENE_RECT_INIT_ZERO; + g_set_object (&priv->overlay_cursor, cursor_sprite); + if (cursor_sprite) { rect = meta_cursor_renderer_calculate_rect (renderer, cursor_sprite); @@ -239,6 +243,7 @@ meta_cursor_renderer_finalize (GObject *object) g_clear_signal_handler (&priv->after_paint_handler_id, stage); g_clear_object (&priv->displayed_cursor); + g_clear_object (&priv->overlay_cursor); G_OBJECT_CLASS (meta_cursor_renderer_parent_class)->finalize (object); } @@ -345,7 +350,7 @@ meta_cursor_renderer_update_cursor (MetaCursorRenderer *renderer, if (handled_by_backend != priv->handled_by_backend) priv->handled_by_backend = handled_by_backend; - update_stage_overlay (renderer, cursor_sprite); + meta_cursor_renderer_update_stage_overlay (renderer, cursor_sprite); } MetaCursorRenderer * @@ -408,7 +413,7 @@ meta_cursor_renderer_get_cursor (MetaCursorRenderer *renderer) { MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer); - return priv->displayed_cursor; + return priv->overlay_cursor; } gboolean diff --git a/src/backends/meta-cursor-renderer.h b/src/backends/meta-cursor-renderer.h index 386d029d0..7d89af487 100644 --- a/src/backends/meta-cursor-renderer.h +++ b/src/backends/meta-cursor-renderer.h @@ -84,4 +84,7 @@ graphene_rect_t meta_cursor_renderer_calculate_rect (MetaCursorRenderer *rendere void meta_cursor_renderer_emit_painted (MetaCursorRenderer *renderer, MetaCursorSprite *cursor_sprite); +void meta_cursor_renderer_update_stage_overlay (MetaCursorRenderer *renderer, + MetaCursorSprite *cursor_sprite); + #endif /* META_CURSOR_RENDERER_H */