aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/input/cursor.h1
-rw-r--r--include/sway/input/input-manager.h2
-rw-r--r--include/sway/input/seat.h2
-rw-r--r--sway/config.c19
-rw-r--r--sway/input/cursor.c10
-rw-r--r--sway/input/input-manager.c2
-rw-r--r--sway/input/seat.c10
7 files changed, 45 insertions, 1 deletions
diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h
index 2f70cf4b..a16b793b 100644
--- a/include/sway/input/cursor.h
+++ b/include/sway/input/cursor.h
@@ -25,6 +25,7 @@ struct sway_cursor {
25 struct wl_listener request_set_cursor; 25 struct wl_listener request_set_cursor;
26}; 26};
27 27
28void sway_cursor_destroy(struct sway_cursor *cursor);
28struct sway_cursor *sway_cursor_create(struct sway_seat *seat); 29struct sway_cursor *sway_cursor_create(struct sway_seat *seat);
29 30
30#endif 31#endif
diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h
index 2bf297ce..63806b8e 100644
--- a/include/sway/input/input-manager.h
+++ b/include/sway/input/input-manager.h
@@ -46,4 +46,6 @@ void sway_input_manager_apply_seat_config(struct sway_input_manager *input,
46struct sway_seat *sway_input_manager_get_default_seat( 46struct sway_seat *sway_input_manager_get_default_seat(
47 struct sway_input_manager *input); 47 struct sway_input_manager *input);
48 48
49struct sway_seat *input_manager_get_seat(struct sway_input_manager *input,
50 const char *seat_name);
49#endif 51#endif
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h
index d703f94c..b21cbccb 100644
--- a/include/sway/input/seat.h
+++ b/include/sway/input/seat.h
@@ -29,6 +29,8 @@ struct sway_seat {
29struct sway_seat *sway_seat_create(struct sway_input_manager *input, 29struct sway_seat *sway_seat_create(struct sway_input_manager *input,
30 const char *seat_name); 30 const char *seat_name);
31 31
32void sway_seat_destroy(struct sway_seat *seat);
33
32void sway_seat_add_device(struct sway_seat *seat, 34void sway_seat_add_device(struct sway_seat *seat,
33 struct sway_input_device *device); 35 struct sway_input_device *device);
34 36
diff --git a/sway/config.c b/sway/config.c
index cb22f664..0f91cce6 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -21,6 +21,7 @@
21#endif 21#endif
22#include <wlr/types/wlr_output.h> 22#include <wlr/types/wlr_output.h>
23#include "sway/input/input-manager.h" 23#include "sway/input/input-manager.h"
24#include "sway/input/seat.h"
24#include "sway/commands.h" 25#include "sway/commands.h"
25#include "sway/config.h" 26#include "sway/config.h"
26#include "sway/layout.h" 27#include "sway/layout.h"
@@ -109,6 +110,23 @@ void free_config(struct sway_config *config) {
109 free(config); 110 free(config);
110} 111}
111 112
113static void destroy_removed_seats(struct sway_config *old_config,
114 struct sway_config *new_config) {
115 struct seat_config *seat_config;
116 struct sway_seat *seat;
117 int i;
118 for (i = 0; i < old_config->seat_configs->length; i++) {
119 seat_config = old_config->seat_configs->items[i];
120 /* Also destroy seats that aren't present in new config */
121 if (new_config && list_seq_find(new_config->seat_configs,
122 seat_name_cmp, seat_config->name) < 0) {
123 seat = input_manager_get_seat(input_manager,
124 seat_config->name);
125 sway_seat_destroy(seat);
126 }
127 }
128}
129
112static void config_defaults(struct sway_config *config) { 130static void config_defaults(struct sway_config *config) {
113 if (!(config->symbols = create_list())) goto cleanup; 131 if (!(config->symbols = create_list())) goto cleanup;
114 if (!(config->modes = create_list())) goto cleanup; 132 if (!(config->modes = create_list())) goto cleanup;
@@ -382,6 +400,7 @@ bool load_main_config(const char *file, bool is_active) {
382 } 400 }
383 401
384 if (old_config) { 402 if (old_config) {
403 destroy_removed_seats(old_config, config);
385 free_config(old_config); 404 free_config(old_config);
386 } 405 }
387 config->reading = false; 406 config->reading = false;
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
152void 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
152struct sway_cursor *sway_cursor_create(struct sway_seat *seat) { 162struct 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;
23struct input_config *current_input_config = NULL; 23struct input_config *current_input_config = NULL;
24struct seat_config *current_seat_config = NULL; 24struct seat_config *current_seat_config = NULL;
25 25
26static struct sway_seat *input_manager_get_seat( 26struct 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
24void 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
24struct sway_seat *sway_seat_create(struct sway_input_manager *input, 34struct 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));