From 58f5e8d16a60fd870172cc60992e9c708e807747 Mon Sep 17 00:00:00 2001 From: bi4k8 Date: Fri, 31 Dec 2021 23:30:25 +0000 Subject: [PATCH] factor keyboard/cursor cleanup into own functions --- include/labwc.h | 2 ++ src/cursor.c | 14 ++++++++++++++ src/keyboard.c | 10 ++++++++++ src/seat.c | 14 ++------------ 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/include/labwc.h b/include/labwc.h index 31385040..7459b455 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -456,8 +456,10 @@ void cursor_set(struct seat *seat, const char *cursor_name); void cursor_update_focus(struct server *server); void cursor_init(struct seat *seat); +void cursor_finish(struct seat *seat); void keyboard_init(struct seat *seat); +void keyboard_finish(struct seat *seat); void arrange_layers(struct output *output); diff --git a/src/cursor.c b/src/cursor.c index 53de192b..a6a51418 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -716,3 +716,17 @@ cursor_init(struct seat *seat) wl_signal_add(&seat->seat->events.request_set_primary_selection, &seat->request_set_primary_selection); } + +void cursor_finish(struct seat *seat) { + wl_list_remove(&seat->cursor_motion.link); + wl_list_remove(&seat->cursor_motion_absolute.link); + wl_list_remove(&seat->cursor_button.link); + wl_list_remove(&seat->cursor_axis.link); + wl_list_remove(&seat->cursor_frame.link); + + wl_list_remove(&seat->request_cursor.link); + wl_list_remove(&seat->request_set_selection.link); + + wlr_xcursor_manager_destroy(seat->xcursor_manager); + wlr_cursor_destroy(seat->cursor); +} diff --git a/src/keyboard.c b/src/keyboard.c index 5508f872..1be0c002 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -218,3 +218,13 @@ keyboard_init(struct seat *seat) seat->keyboard_modifiers.notify = keyboard_modifiers_notify; wl_signal_add(&kb->events.modifiers, &seat->keyboard_modifiers); } + +void +keyboard_finish(struct seat *seat) +{ + if (seat->keyboard_group) { + wlr_keyboard_group_destroy(seat->keyboard_group); + } + wl_list_remove(&seat->keyboard_key.link); + wl_list_remove(&seat->keyboard_modifiers.link); +} diff --git a/src/seat.c b/src/seat.c index 48e82e67..e9e8a995 100644 --- a/src/seat.c +++ b/src/seat.c @@ -243,19 +243,9 @@ void seat_finish(struct server *server) { struct seat *seat = &server->seat; - wl_list_remove(&seat->cursor_motion.link); - wl_list_remove(&seat->cursor_motion_absolute.link); - wl_list_remove(&seat->cursor_button.link); - wl_list_remove(&seat->cursor_axis.link); - wl_list_remove(&seat->cursor_frame.link); - wl_list_remove(&seat->request_cursor.link); - wl_list_remove(&seat->request_set_selection.link); wl_list_remove(&seat->new_input.link); - if (seat->keyboard_group) { - wlr_keyboard_group_destroy(seat->keyboard_group); - } - wlr_xcursor_manager_destroy(seat->xcursor_manager); - wlr_cursor_destroy(seat->cursor); + keyboard_finish(seat); + cursor_finish(seat); } void