From f534434be6b88056d056a9b401f1704202f16dcd Mon Sep 17 00:00:00 2001 From: Kirill Primak Date: Mon, 6 May 2024 21:23:08 +0300 Subject: [PATCH] output: extract hardware cursor disabling logic --- types/output/cursor.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/types/output/cursor.c b/types/output/cursor.c index 22654b0a..4d1e0a13 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) {