diff options
author | Simon Ser <contact@emersion.fr> | 2023-12-12 12:45:33 +0100 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2023-12-12 19:39:33 +0000 |
commit | 7ef62cc995012957b53763a0bce67093ae433893 (patch) | |
tree | 09f545a0b9e424cc8f030a83ed81b40ba8c01adc | |
parent | d8c0707e2700aaaa0b09b4d9db1ab968181e625a (diff) |
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
-rw-r--r-- | types/wlr_cursor.c | 23 |
1 files 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); } |