output/cursor: Fix double cursor bug

When we fail to render the cursor (in my case because the cursor is too
large) we bail out of the output_cursor_attempt_hardware function. This
causes output_cursor_set_texture to clean up after us, but we've already
cleared the hardware_cursor, and so output_disable_hardware_cursor
thinks we don't have a hardware cursor to disable.

We shouldn't modify the hardware_cursor variable before we've
successfully changed the hardware cursor, this way the caller can clean
up after us like it expect to.

This was brought up by an actual bug when playing the game Kaizen. Which
uses oddly sized cursors, that fell back to software cursors for me, and
left the hardware cursor hanging around. This change has been tested to
fix that.

During the testing of this change, I have noticed that the previous code
worked fine the first time the cursor was switch to software. It only
failed on subsequent attempts. I haven't figured out why that is.

(cherry picked from commit 07e92fb868)
This commit is contained in:
Jesper Jensen 2025-08-05 16:16:50 +02:00 committed by Simon Zeni
parent 52e1ad01e3
commit aa904ccf06

View file

@ -298,8 +298,6 @@ static bool output_cursor_attempt_hardware(struct wlr_output_cursor *cursor) {
return false;
}
output->hardware_cursor = NULL;
struct wlr_texture *texture = cursor->texture;
// If the cursor was hidden or was a software cursor, the hardware