output/cursor: fix missing second cursor

When attaching more than one cursor to wlr_output, the first one
will pick the output's hardware cursor, then for the second one
output_set_hardware_cursor() would fail (since the hardware cursor
was already taken), but we still ended up resetting the current
hardware cursor (by calling output_disable_hardware_cursor() below).
As a result only the second cursor would be displayed.

To fix this, move the current hardware cursor check to the caller.

Fixes: 510664e79b ("output: disable hardware cursor when falling back to software")
This commit is contained in:
Simon Ser 2025-08-07 11:56:49 +02:00 committed by Isaac Freund
parent 5e5842cb1a
commit fd069ad4f2

View file

@ -288,13 +288,7 @@ static struct wlr_buffer *render_cursor_buffer(struct wlr_output_cursor *cursor)
static bool output_cursor_attempt_hardware(struct wlr_output_cursor *cursor) {
struct wlr_output *output = cursor->output;
if (!output->impl->set_cursor ||
output->software_cursor_locks > 0) {
return false;
}
struct wlr_output_cursor *hwcur = output->hardware_cursor;
if (hwcur != NULL && hwcur != cursor) {
if (!output->impl->set_cursor || output->software_cursor_locks > 0) {
return false;
}
@ -422,12 +416,15 @@ bool output_cursor_set_texture(struct wlr_output_cursor *cursor,
wl_list_init(&cursor->renderer_destroy.link);
}
if (output_cursor_attempt_hardware(cursor)) {
return true;
if (output->hardware_cursor == NULL || output->hardware_cursor == cursor) {
if (output_cursor_attempt_hardware(cursor)) {
return true;
}
wlr_log(WLR_DEBUG, "Falling back to software cursor on output '%s'", output->name);
output_disable_hardware_cursor(output);
}
wlr_log(WLR_DEBUG, "Falling back to software cursor on output '%s'", output->name);
output_disable_hardware_cursor(output);
output_cursor_damage_whole(cursor);
return true;
}