output: extract hardware cursor disabling logic

master
Kirill Primak 7 months ago committed by Alexander Orzechowski
parent 9c50cd71b6
commit f534434be6

@ -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_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) { void wlr_output_lock_software_cursors(struct wlr_output *output, bool lock) {
if (lock) { if (lock) {
++output->software_cursor_locks; ++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, lock ? "Disabling" : "Enabling", output->name,
output->software_cursor_locks); output->software_cursor_locks);
if (output->software_cursor_locks > 0 && output->hardware_cursor != NULL) { if (output->software_cursor_locks > 0) {
output_set_hardware_cursor(output, NULL, 0, 0); output_disable_hardware_cursor(output);
output_cursor_damage_whole(output->hardware_cursor);
output->hardware_cursor = NULL;
} }
// If it's possible to use hardware cursors again, don't switch immediately // 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); output_cursor_reset(cursor);
if (cursor->output->hardware_cursor == cursor) { if (cursor->output->hardware_cursor == cursor) {
// If this cursor was the hardware cursor, disable it // If this cursor was the hardware cursor, disable it
output_set_hardware_cursor(cursor->output, NULL, 0, 0); output_disable_hardware_cursor(cursor->output);
cursor->output->hardware_cursor = NULL;
} }
wl_list_remove(&cursor->renderer_destroy.link); wl_list_remove(&cursor->renderer_destroy.link);
if (cursor->own_texture) { if (cursor->own_texture) {

Loading…
Cancel
Save