From 7ef62cc995012957b53763a0bce67093ae433893 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 12 Dec 2023 12:45:33 +0100 Subject: [PATCH] cursor: fix initial cursor position for new outputs The fresh new wlr_output_cursor is positioned at (0, 0). Call wlr_output_cursor_move() after creating the wlr_output_cursor to fix this. Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3777 --- types/wlr_cursor.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/types/wlr_cursor.c b/types/wlr_cursor.c index cf8f7359..e33b3ba7 100644 --- a/types/wlr_cursor.c +++ b/types/wlr_cursor.c @@ -265,6 +265,16 @@ static struct wlr_cursor_device *get_cursor_device(struct wlr_cursor *cur, return ret; } +static void output_cursor_move(struct wlr_cursor_output_cursor *output_cursor) { + struct wlr_cursor *cur = output_cursor->cursor; + + double output_x = cur->x, output_y = cur->y; + wlr_output_layout_output_coords(cur->state->layout, + output_cursor->output_cursor->output, &output_x, &output_y); + wlr_output_cursor_move(output_cursor->output_cursor, + output_x, output_y); +} + static void cursor_warp_unchecked(struct wlr_cursor *cur, double lx, double ly) { assert(cur->state->layout); @@ -273,17 +283,13 @@ static void cursor_warp_unchecked(struct wlr_cursor *cur, return; } + cur->x = lx; + cur->y = ly; + struct wlr_cursor_output_cursor *output_cursor; wl_list_for_each(output_cursor, &cur->state->output_cursors, link) { - double output_x = lx, output_y = ly; - wlr_output_layout_output_coords(cur->state->layout, - output_cursor->output_cursor->output, &output_x, &output_y); - wlr_output_cursor_move(output_cursor->output_cursor, - output_x, output_y); + output_cursor_move(output_cursor); } - - cur->x = lx; - cur->y = ly; } /** @@ -1104,6 +1110,7 @@ static void layout_add(struct wlr_cursor_state *state, &output_cursor->output_commit); output_cursor->output_commit.notify = output_cursor_output_handle_output_commit; + output_cursor_move(output_cursor); cursor_output_cursor_update(output_cursor); }