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
This commit is contained in:
Jonas Ådahl 2020-04-28 18:11:52 +02:00
parent e57a4e0937
commit bbf3a09e2a
2 changed files with 10 additions and 47 deletions

View File

@ -476,8 +476,7 @@ 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,
recorder_on_stage_after_paint (ClutterActor *actor,
ShellRecorder *recorder)
{
if (recorder->state == RECORDER_STATE_RECORDING)
@ -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,

View File

@ -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);
}
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));