From bbf3a09e2a683513ca15afa49ec615c236ee554b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 28 Apr 2020 18:11:52 +0200 Subject: [PATCH] shell Always draw the cursor ourself when capturing stage Mutter changed to never draw the cursor with the used API, as it can't be done in a predictable manner, so always draw it ourself. https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1224 --- src/shell-recorder.c | 11 +++++----- src/shell-screenshot.c | 46 +++++------------------------------------- 2 files changed, 10 insertions(+), 47 deletions(-) diff --git a/src/shell-recorder.c b/src/shell-recorder.c index 7a01d5fd1..95d9c0b33 100644 --- a/src/shell-recorder.c +++ b/src/shell-recorder.c @@ -476,9 +476,8 @@ recorder_record_frame (ShellRecorder *recorder, * by clutter before glSwapBuffers() makes it visible to the user. */ static void -recorder_on_stage_paint (ClutterActor *actor, - ClutterPaintContext *paint_context, - ShellRecorder *recorder) +recorder_on_stage_after_paint (ClutterActor *actor, + ShellRecorder *recorder) { if (recorder->state == RECORDER_STATE_RECORDING) recorder_record_frame (recorder, FALSE); @@ -612,8 +611,8 @@ recorder_connect_stage_callbacks (ShellRecorder *recorder) { g_signal_connect (recorder->stage, "destroy", G_CALLBACK (recorder_on_stage_destroy), recorder); - g_signal_connect_after (recorder->stage, "paint", - G_CALLBACK (recorder_on_stage_paint), recorder); + g_signal_connect_after (recorder->stage, "after-paint", + G_CALLBACK (recorder_on_stage_after_paint), recorder); g_signal_connect (recorder->stage, "notify::width", G_CALLBACK (recorder_on_stage_notify_size), recorder); g_signal_connect (recorder->stage, "notify::height", @@ -629,7 +628,7 @@ recorder_disconnect_stage_callbacks (ShellRecorder *recorder) (void *)recorder_on_stage_destroy, recorder); g_signal_handlers_disconnect_by_func (recorder->stage, - (void *)recorder_on_stage_paint, + (void *)recorder_on_stage_after_paint, recorder); g_signal_handlers_disconnect_by_func (recorder->stage, (void *)recorder_on_stage_notify_size, diff --git a/src/shell-screenshot.c b/src/shell-screenshot.c index e60d5891b..6c59781ca 100644 --- a/src/shell-screenshot.c +++ b/src/shell-screenshot.c @@ -163,23 +163,6 @@ do_grab_screenshot (ShellScreenshot *screenshot, g_free (captures); } -static gboolean -should_draw_cursor_image (ShellScreenshotMode mode) -{ - if (mode == SHELL_SCREENSHOT_WINDOW || !meta_is_wayland_compositor ()) - { - StSettings *settings = st_settings_get (); - gboolean magnifier_active = FALSE; - - g_object_get (settings, "magnifier-active", &magnifier_active, NULL); - - if (!magnifier_active) - return TRUE; - } - - return FALSE; -} - static void draw_cursor_image (cairo_surface_t *surface, cairo_rectangle_int_t area) @@ -468,7 +451,6 @@ shell_screenshot_screenshot (ShellScreenshot *screenshot, { ClutterActor *stage; ShellScreenshotPrivate *priv; - gboolean use_paint_signal = FALSE; GTask *result; g_return_if_fail (SHELL_IS_SCREENSHOT (screenshot)); @@ -493,32 +475,15 @@ shell_screenshot_screenshot (ShellScreenshot *screenshot, g_task_set_source_tag (result, shell_screenshot_screenshot); priv->stream = g_object_ref (stream); - priv->include_cursor = FALSE; + priv->include_cursor = include_cursor; stage = CLUTTER_ACTOR (shell_global_get_stage (priv->global)); meta_disable_unredirect_for_display (shell_global_get_display (priv->global)); - if (include_cursor) - { - if (should_draw_cursor_image (SHELL_SCREENSHOT_SCREEN)) - priv->include_cursor = TRUE; - else - use_paint_signal = TRUE; - } - - if (use_paint_signal) - { - g_signal_connect_after (stage, "paint", - G_CALLBACK (on_paint), - result); - } - else - { - g_signal_connect_after (stage, "actors-painted", - G_CALLBACK (on_actors_painted), - result); - } + g_signal_connect_after (stage, "actors-painted", + G_CALLBACK (on_actors_painted), + result); clutter_actor_queue_redraw (stage); } @@ -696,8 +661,7 @@ shell_screenshot_screenshot_window (ShellScreenshot *screenshot, priv->stream = g_object_ref (stream); priv->include_frame = include_frame; - priv->include_cursor = include_cursor && - should_draw_cursor_image (SHELL_SCREENSHOT_WINDOW); + priv->include_cursor = include_cursor; stage = CLUTTER_ACTOR (shell_global_get_stage (priv->global));