aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Tony Crisci <tony@dubstepdish.com>2018-01-17 09:49:02 -0500
committerLibravatar Tony Crisci <tony@dubstepdish.com>2018-01-17 09:49:02 -0500
commit9f54cd89359119897fed2747c373879c09ae8706 (patch)
tree024ecf284c38c5017068b82902d66ec4342f8291 /sway
parentMerge pull request #1566 from acrisci/render-loop (diff)
downloadsway-9f54cd89359119897fed2747c373879c09ae8706.tar.gz
sway-9f54cd89359119897fed2747c373879c09ae8706.tar.zst
sway-9f54cd89359119897fed2747c373879c09ae8706.zip
copy config references for input and seat
Diffstat (limited to 'sway')
-rw-r--r--sway/config.c7
-rw-r--r--sway/config/input.c10
-rw-r--r--sway/config/seat.c11
-rw-r--r--sway/input/input-manager.c7
-rw-r--r--sway/input/seat.c7
5 files changed, 35 insertions, 7 deletions
diff --git a/sway/config.c b/sway/config.c
index 5ec45b17..cbd9a8b2 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -84,7 +84,12 @@ void free_config(struct sway_config *config) {
84 } 84 }
85 list_free(config->input_configs); 85 list_free(config->input_configs);
86 } 86 }
87 list_free(config->seat_configs); 87 if (config->seat_configs) {
88 for (i = 0; i < config->seat_configs->length; i++) {
89 free_seat_config(config->seat_configs->items[i]);
90 }
91 list_free(config->seat_configs);
92 }
88 list_free(config->criteria); 93 list_free(config->criteria);
89 list_free(config->no_focus); 94 list_free(config->no_focus);
90 list_free(config->active_bar_modifiers); 95 list_free(config->active_bar_modifiers);
diff --git a/sway/config/input.c b/sway/config/input.c
index 96181302..c4f6211d 100644
--- a/sway/config/input.c
+++ b/sway/config/input.c
@@ -90,6 +90,16 @@ void merge_input_config(struct input_config *dst, struct input_config *src) {
90 } 90 }
91} 91}
92 92
93struct input_config *copy_input_config(struct input_config *ic) {
94 struct input_config *copy = calloc(1, sizeof(struct input_config));
95 if (copy == NULL) {
96 wlr_log(L_ERROR, "could not allocate input config");
97 return NULL;
98 }
99 merge_input_config(copy, ic);
100 return copy;
101}
102
93void free_input_config(struct input_config *ic) { 103void free_input_config(struct input_config *ic) {
94 if (!ic) { 104 if (!ic) {
95 return; 105 return;
diff --git a/sway/config/seat.c b/sway/config/seat.c
index 03cc6d4e..bd8b45c8 100644
--- a/sway/config/seat.c
+++ b/sway/config/seat.c
@@ -99,6 +99,17 @@ void merge_seat_config(struct seat_config *dest, struct seat_config *source) {
99 } 99 }
100} 100}
101 101
102struct seat_config *copy_seat_config(struct seat_config *seat) {
103 struct seat_config *copy = new_seat_config(seat->name);
104 if (copy == NULL) {
105 return NULL;
106 }
107
108 merge_seat_config(copy, seat);
109
110 return copy;
111}
112
102void free_seat_config(struct seat_config *seat) { 113void free_seat_config(struct seat_config *seat) {
103 if (!seat) { 114 if (!seat) {
104 return; 115 return;
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c
index 26cf5035..bfe9d9c4 100644
--- a/sway/input/input-manager.c
+++ b/sway/input/input-manager.c
@@ -174,7 +174,8 @@ static void input_add_notify(struct wl_listener *listener, void *data) {
174 for (int i = 0; i < config->input_configs->length; ++i) { 174 for (int i = 0; i < config->input_configs->length; ++i) {
175 struct input_config *input_config = config->input_configs->items[i]; 175 struct input_config *input_config = config->input_configs->items[i];
176 if (strcmp(input_config->identifier, input_device->identifier) == 0) { 176 if (strcmp(input_config->identifier, input_device->identifier) == 0) {
177 input_device->config = input_config; 177 free_input_config(input_device->config);
178 input_device->config = copy_input_config(input_config);
178 break; 179 break;
179 } 180 }
180 } 181 }
@@ -240,6 +241,7 @@ static void input_remove_notify(struct wl_listener *listener, void *data) {
240 } 241 }
241 242
242 wl_list_remove(&input_device->link); 243 wl_list_remove(&input_device->link);
244 free_input_config(input_device->config);
243 free(input_device->identifier); 245 free(input_device->identifier);
244 free(input_device); 246 free(input_device);
245} 247}
@@ -293,7 +295,8 @@ void sway_input_manager_apply_input_config(struct sway_input_manager *input,
293 struct sway_input_device *input_device = NULL; 295 struct sway_input_device *input_device = NULL;
294 wl_list_for_each(input_device, &input->devices, link) { 296 wl_list_for_each(input_device, &input->devices, link) {
295 if (strcmp(input_device->identifier, input_config->identifier) == 0) { 297 if (strcmp(input_device->identifier, input_config->identifier) == 0) {
296 input_device->config = input_config; 298 free_input_config(input_device->config);
299 input_device->config = copy_input_config(input_config);
297 300
298 if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) { 301 if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) {
299 sway_input_manager_libinput_config_pointer(input_device); 302 sway_input_manager_libinput_config_pointer(input_device);
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 268486ab..d134bc68 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -230,6 +230,7 @@ void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container) {
230void sway_seat_set_config(struct sway_seat *seat, 230void sway_seat_set_config(struct sway_seat *seat,
231 struct seat_config *seat_config) { 231 struct seat_config *seat_config) {
232 // clear configs 232 // clear configs
233 free_seat_config(seat->config);
233 seat->config = NULL; 234 seat->config = NULL;
234 235
235 struct sway_seat_device *seat_device = NULL; 236 struct sway_seat_device *seat_device = NULL;
@@ -242,11 +243,9 @@ void sway_seat_set_config(struct sway_seat *seat,
242 } 243 }
243 244
244 // add configs 245 // add configs
245 seat->config = seat_config; 246 seat->config = copy_seat_config(seat_config);
246 247
247 wl_list_for_each(seat_device, &seat->devices, link) { 248 wl_list_for_each(seat_device, &seat->devices, link) {
248 seat_device->attachment_config = 249 sway_seat_configure_device(seat, seat_device->input_device);
249 seat_config_get_attachment(seat_config,
250 seat_device->input_device->identifier);
251 } 250 }
252} 251}