From 55077701943a5a508de9f5522e401e2fda6f3174 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 26 Apr 2024 18:41:58 +0200 Subject: [PATCH] output: require commit after hardware cursor update Up until now only the DRM backend required an output commit after updating the cursor. Unify this for all backends, because: - Screen capture can now catch cursor updates listening for output commits - In the future we want to make the cursor a regular wlr_output_layer, which would need an output commit to be updated anyways --- backend/drm/drm.c | 2 -- types/output/cursor.c | 17 +++++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 1a1af309..e838c246 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -1129,7 +1129,6 @@ static bool drm_connector_set_cursor(struct wlr_output *output, conn->cursor_height = buffer->height; } - wlr_output_update_needs_frame(output); return true; } @@ -1159,7 +1158,6 @@ static bool drm_connector_move_cursor(struct wlr_output *output, conn->cursor_x = box.x; conn->cursor_y = box.y; - wlr_output_update_needs_frame(output); return true; } diff --git a/types/output/cursor.c b/types/output/cursor.c index 7bc8d0d6..f8f5eb64 100644 --- a/types/output/cursor.c +++ b/types/output/cursor.c @@ -23,6 +23,8 @@ static bool output_set_hardware_cursor(struct wlr_output *output, return false; } + wlr_output_update_needs_frame(output); + wlr_buffer_unlock(output->cursor_front_buffer); output->cursor_front_buffer = NULL; @@ -33,6 +35,15 @@ static bool output_set_hardware_cursor(struct wlr_output *output, return true; } +static bool output_move_hardware_cursor(struct wlr_output *output, int x, int y) { + assert(output->impl->move_cursor); + if (!output->impl->move_cursor(output, x, y)) { + return false; + } + wlr_output_update_needs_frame(output); + return true; +} + static void output_cursor_damage_whole(struct wlr_output_cursor *cursor); static void output_disable_hardware_cursor(struct wlr_output *output) { @@ -302,8 +313,7 @@ static bool output_cursor_attempt_hardware(struct wlr_output_cursor *cursor) { // If the cursor was hidden or was a software cursor, the hardware // cursor position is outdated - output->impl->move_cursor(cursor->output, - (int)cursor->x, (int)cursor->y); + output_move_hardware_cursor(cursor->output, (int)cursor->x, (int)cursor->y); struct wlr_buffer *buffer = NULL; if (texture != NULL) { @@ -455,8 +465,7 @@ bool wlr_output_cursor_move(struct wlr_output_cursor *cursor, return true; } - assert(cursor->output->impl->move_cursor); - return cursor->output->impl->move_cursor(cursor->output, (int)x, (int)y); + return output_move_hardware_cursor(cursor->output, (int)x, (int)y); } struct wlr_output_cursor *wlr_output_cursor_create(struct wlr_output *output) {