From 986d3be7ac60859bc614c73182582fee4c9607c8 Mon Sep 17 00:00:00 2001 From: Salman Malik Date: Fri, 16 Sep 2022 20:03:53 +0000 Subject: [PATCH] virtual-stream: Paint stage properly with/without cursor This change ensures that when the painted stage is written out to the buffer, it respects the clients desire to either desire to either embed the cursor in the view or not. Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2142 Part-of: --- .../meta-screen-cast-virtual-stream-src.c | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/src/backends/meta-screen-cast-virtual-stream-src.c b/src/backends/meta-screen-cast-virtual-stream-src.c index c7174dd2a..3f33a8538 100644 --- a/src/backends/meta-screen-cast-virtual-stream-src.c +++ b/src/backends/meta-screen-cast-virtual-stream-src.c @@ -355,11 +355,38 @@ meta_screen_cast_virtual_stream_src_record_to_buffer (MetaScreenCastStreamSrc * uint8_t *data, GError **error) { - clutter_stage_capture_view_into (stage_from_src (src), - view_from_src (src), - NULL, - data, - stride); + MetaScreenCastStream *stream; + ClutterPaintFlag paint_flags; + ClutterStageView *view; + MetaRectangle view_rect; + float scale; + + stream = meta_screen_cast_stream_src_get_stream (src); + view = view_from_src (src); + scale = clutter_stage_view_get_scale (view); + clutter_stage_view_get_layout (view, &view_rect); + + paint_flags = CLUTTER_PAINT_FLAG_CLEAR; + switch (meta_screen_cast_stream_get_cursor_mode (stream)) + { + case META_SCREEN_CAST_CURSOR_MODE_METADATA: + case META_SCREEN_CAST_CURSOR_MODE_HIDDEN: + paint_flags |= CLUTTER_PAINT_FLAG_NO_CURSORS; + break; + case META_SCREEN_CAST_CURSOR_MODE_EMBEDDED: + paint_flags |= CLUTTER_PAINT_FLAG_FORCE_CURSORS; + break; + } + + if (!clutter_stage_paint_to_buffer (stage_from_src (src), + &view_rect, + scale, + data, + stride, + CLUTTER_CAIRO_FORMAT_ARGB32, + paint_flags, + error)) + return FALSE; return TRUE; }