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
This commit is contained in:
Simon Ser 2023-12-12 12:45:33 +01:00 committed by Simon Zeni
parent d8c0707e27
commit 7ef62cc995
1 changed files with 16 additions and 9 deletions

View File

@ -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;
}
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);
}
cur->x = lx;
cur->y = ly;
struct wlr_cursor_output_cursor *output_cursor;
wl_list_for_each(output_cursor, &cur->state->output_cursors, link) {
output_cursor_move(output_cursor);
}
}
/**
@ -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);
}