diff options
author | Dominique Martinet <asmadeus@codewreck.org> | 2018-01-16 21:16:04 +0100 |
---|---|---|
committer | Dominique Martinet <asmadeus@codewreck.org> | 2018-01-22 07:26:37 +0100 |
commit | 5766f426aac11bf39234dcca4c479ee865081dad (patch) | |
tree | 0d1917761854db5d79c5d7478e46e3082bf14b8f /sway/input | |
parent | commands: add 'reload' command (diff) | |
download | sway-5766f426aac11bf39234dcca4c479ee865081dad.tar.gz sway-5766f426aac11bf39234dcca4c479ee865081dad.tar.zst sway-5766f426aac11bf39234dcca4c479ee865081dad.zip |
config reload: destroy old seat when removed from config
This adds new sway_seat_destroy and sway_cursor_destroy helpers
and compare new and old config on free
Diffstat (limited to 'sway/input')
-rw-r--r-- | sway/input/cursor.c | 10 | ||||
-rw-r--r-- | sway/input/input-manager.c | 2 | ||||
-rw-r--r-- | sway/input/seat.c | 10 |
3 files changed, 21 insertions, 1 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index e6a4eca8..73a8ec5c 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -149,6 +149,16 @@ static void handle_request_set_cursor(struct wl_listener *listener, | |||
149 | wlr_log(L_DEBUG, "TODO: handle request set cursor event: %p", event); | 149 | wlr_log(L_DEBUG, "TODO: handle request set cursor event: %p", event); |
150 | } | 150 | } |
151 | 151 | ||
152 | void sway_cursor_destroy(struct sway_cursor *cursor) { | ||
153 | if (!cursor) { | ||
154 | return; | ||
155 | } | ||
156 | |||
157 | wlr_xcursor_manager_destroy(cursor->xcursor_manager); | ||
158 | wlr_cursor_destroy(cursor->cursor); | ||
159 | free(cursor); | ||
160 | } | ||
161 | |||
152 | struct sway_cursor *sway_cursor_create(struct sway_seat *seat) { | 162 | struct sway_cursor *sway_cursor_create(struct sway_seat *seat) { |
153 | struct sway_cursor *cursor = calloc(1, sizeof(struct sway_cursor)); | 163 | struct sway_cursor *cursor = calloc(1, sizeof(struct sway_cursor)); |
154 | if (!sway_assert(cursor, "could not allocate sway cursor")) { | 164 | if (!sway_assert(cursor, "could not allocate sway cursor")) { |
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index 2d119cf2..12b3a430 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c | |||
@@ -23,7 +23,7 @@ struct sway_input_manager *input_manager; | |||
23 | struct input_config *current_input_config = NULL; | 23 | struct input_config *current_input_config = NULL; |
24 | struct seat_config *current_seat_config = NULL; | 24 | struct seat_config *current_seat_config = NULL; |
25 | 25 | ||
26 | static struct sway_seat *input_manager_get_seat( | 26 | struct sway_seat *input_manager_get_seat( |
27 | struct sway_input_manager *input, const char *seat_name) { | 27 | struct sway_input_manager *input, const char *seat_name) { |
28 | struct sway_seat *seat = NULL; | 28 | struct sway_seat *seat = NULL; |
29 | wl_list_for_each(seat, &input->seats, link) { | 29 | wl_list_for_each(seat, &input->seats, link) { |
diff --git a/sway/input/seat.c b/sway/input/seat.c index e9b375e0..9ea08eec 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -21,6 +21,16 @@ static void seat_device_destroy(struct sway_seat_device *seat_device) { | |||
21 | free(seat_device); | 21 | free(seat_device); |
22 | } | 22 | } |
23 | 23 | ||
24 | void sway_seat_destroy(struct sway_seat *seat) { | ||
25 | struct sway_seat_device *seat_device, *next; | ||
26 | wl_list_for_each_safe(seat_device, next, &seat->devices, link) { | ||
27 | seat_device_destroy(seat_device); | ||
28 | } | ||
29 | sway_cursor_destroy(seat->cursor); | ||
30 | wl_list_remove(&seat->link); | ||
31 | wlr_seat_destroy(seat->wlr_seat); | ||
32 | } | ||
33 | |||
24 | struct sway_seat *sway_seat_create(struct sway_input_manager *input, | 34 | struct sway_seat *sway_seat_create(struct sway_input_manager *input, |
25 | const char *seat_name) { | 35 | const char *seat_name) { |
26 | struct sway_seat *seat = calloc(1, sizeof(struct sway_seat)); | 36 | struct sway_seat *seat = calloc(1, sizeof(struct sway_seat)); |