diff --git a/types/output/cursor.c b/types/output/cursor.c index 22654b0a3..4d1e0a133 100644 --- a/types/output/cursor.c +++ b/types/output/cursor.c @@ -34,6 +34,16 @@ static bool output_set_hardware_cursor(struct wlr_output *output, static void output_cursor_damage_whole(struct wlr_output_cursor *cursor); +static void output_disable_hardware_cursor(struct wlr_output *output) { + if (output->hardware_cursor == NULL) { + return; + } + + output_set_hardware_cursor(output, NULL, 0, 0); + output_cursor_damage_whole(output->hardware_cursor); + output->hardware_cursor = NULL; +} + void wlr_output_lock_software_cursors(struct wlr_output *output, bool lock) { if (lock) { ++output->software_cursor_locks; @@ -45,10 +55,8 @@ void wlr_output_lock_software_cursors(struct wlr_output *output, bool lock) { lock ? "Disabling" : "Enabling", output->name, output->software_cursor_locks); - if (output->software_cursor_locks > 0 && output->hardware_cursor != NULL) { - output_set_hardware_cursor(output, NULL, 0, 0); - output_cursor_damage_whole(output->hardware_cursor); - output->hardware_cursor = NULL; + if (output->software_cursor_locks > 0) { + output_disable_hardware_cursor(output); } // If it's possible to use hardware cursors again, don't switch immediately @@ -441,8 +449,7 @@ void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor) { output_cursor_reset(cursor); if (cursor->output->hardware_cursor == cursor) { // If this cursor was the hardware cursor, disable it - output_set_hardware_cursor(cursor->output, NULL, 0, 0); - cursor->output->hardware_cursor = NULL; + output_disable_hardware_cursor(cursor->output); } wl_list_remove(&cursor->renderer_destroy.link); if (cursor->own_texture) {