diff options
author | Tony Crisci <tony@dubstepdish.com> | 2018-04-02 10:37:31 -0400 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2018-04-02 10:37:31 -0400 |
commit | 53bb7ea9962c5d97e0672eabcf1b9dfb7ffad0f1 (patch) | |
tree | 83856846c12de678ac15b5c41e9623f54df725fd /sway/input | |
parent | rename input-manager functions (diff) | |
download | sway-53bb7ea9962c5d97e0672eabcf1b9dfb7ffad0f1.tar.gz sway-53bb7ea9962c5d97e0672eabcf1b9dfb7ffad0f1.tar.zst sway-53bb7ea9962c5d97e0672eabcf1b9dfb7ffad0f1.zip |
dont copy seat config on the seat
Diffstat (limited to 'sway/input')
-rw-r--r-- | sway/input/input-manager.c | 25 | ||||
-rw-r--r-- | sway/input/seat.c | 27 |
2 files changed, 32 insertions, 20 deletions
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index 4f3c3ee5..d9d20200 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c | |||
@@ -83,7 +83,8 @@ static struct sway_input_device *input_sway_device_from_wlr( | |||
83 | static bool input_has_seat_configuration(struct sway_input_manager *input) { | 83 | static bool input_has_seat_configuration(struct sway_input_manager *input) { |
84 | struct sway_seat *seat = NULL; | 84 | struct sway_seat *seat = NULL; |
85 | wl_list_for_each(seat, &input->seats, link) { | 85 | wl_list_for_each(seat, &input->seats, link) { |
86 | if (seat->config) { | 86 | struct seat_config *seat_config = seat_get_config(seat); |
87 | if (seat_config) { | ||
87 | return true; | 88 | return true; |
88 | } | 89 | } |
89 | } | 90 | } |
@@ -225,11 +226,13 @@ static void handle_new_input(struct wl_listener *listener, void *data) { | |||
225 | return; | 226 | return; |
226 | } | 227 | } |
227 | 228 | ||
229 | struct seat_config *seat_config = seat_get_config(seat); | ||
230 | |||
228 | bool added = false; | 231 | bool added = false; |
229 | wl_list_for_each(seat, &input->seats, link) { | 232 | wl_list_for_each(seat, &input->seats, link) { |
230 | bool has_attachment = seat->config && | 233 | bool has_attachment = config && |
231 | (seat_config_get_attachment(seat->config, input_device->identifier) || | 234 | (seat_config_get_attachment(seat_config, input_device->identifier) || |
232 | seat_config_get_attachment(seat->config, "*")); | 235 | seat_config_get_attachment(seat_config, "*")); |
233 | 236 | ||
234 | if (has_attachment) { | 237 | if (has_attachment) { |
235 | seat_add_device(seat, input_device); | 238 | seat_add_device(seat, input_device); |
@@ -239,7 +242,7 @@ static void handle_new_input(struct wl_listener *listener, void *data) { | |||
239 | 242 | ||
240 | if (!added) { | 243 | if (!added) { |
241 | wl_list_for_each(seat, &input->seats, link) { | 244 | wl_list_for_each(seat, &input->seats, link) { |
242 | if (seat->config && seat->config->fallback == 1) { | 245 | if (seat_config && seat_config->fallback == 1) { |
243 | seat_add_device(seat, input_device); | 246 | seat_add_device(seat, input_device); |
244 | added = true; | 247 | added = true; |
245 | } | 248 | } |
@@ -326,7 +329,7 @@ void input_manager_apply_seat_config(struct sway_input_manager *input, | |||
326 | return; | 329 | return; |
327 | } | 330 | } |
328 | 331 | ||
329 | seat_set_config(seat, seat_config); | 332 | seat_apply_config(seat, seat_config); |
330 | 333 | ||
331 | // for every device, try to add it to a seat and if no seat has it | 334 | // for every device, try to add it to a seat and if no seat has it |
332 | // attached, add it to the fallback seats. | 335 | // attached, add it to the fallback seats. |
@@ -335,11 +338,12 @@ void input_manager_apply_seat_config(struct sway_input_manager *input, | |||
335 | list_t *seat_list = create_list(); | 338 | list_t *seat_list = create_list(); |
336 | struct sway_seat *seat = NULL; | 339 | struct sway_seat *seat = NULL; |
337 | wl_list_for_each(seat, &input->seats, link) { | 340 | wl_list_for_each(seat, &input->seats, link) { |
338 | if (!seat->config) { | 341 | struct seat_config *seat_config = seat_get_config(seat); |
342 | if (!seat_config) { | ||
339 | continue; | 343 | continue; |
340 | } | 344 | } |
341 | if (seat_config_get_attachment(seat->config, "*") || | 345 | if (seat_config_get_attachment(seat_config, "*") || |
342 | seat_config_get_attachment(seat->config, | 346 | seat_config_get_attachment(seat_config, |
343 | input_device->identifier)) { | 347 | input_device->identifier)) { |
344 | list_add(seat_list, seat); | 348 | list_add(seat_list, seat); |
345 | } | 349 | } |
@@ -362,7 +366,8 @@ void input_manager_apply_seat_config(struct sway_input_manager *input, | |||
362 | } | 366 | } |
363 | } else { | 367 | } else { |
364 | wl_list_for_each(seat, &input->seats, link) { | 368 | wl_list_for_each(seat, &input->seats, link) { |
365 | if (seat->config && seat->config->fallback == 1) { | 369 | struct seat_config *seat_config = seat_get_config(seat); |
370 | if (seat_config && seat_config->fallback == 1) { | ||
366 | seat_add_device(seat, input_device); | 371 | seat_add_device(seat, input_device); |
367 | } else { | 372 | } else { |
368 | seat_remove_device(seat, input_device); | 373 | seat_remove_device(seat, input_device); |
diff --git a/sway/input/seat.c b/sway/input/seat.c index c2ecd1c4..91a9e32b 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -199,9 +199,11 @@ void seat_configure_device(struct sway_seat *seat, | |||
199 | return; | 199 | return; |
200 | } | 200 | } |
201 | 201 | ||
202 | if (seat->config) { | 202 | struct seat_config *seat_config = seat_get_config(seat); |
203 | |||
204 | if (seat_config) { | ||
203 | seat_device->attachment_config = | 205 | seat_device->attachment_config = |
204 | seat_config_get_attachment(seat->config, input_device->identifier); | 206 | seat_config_get_attachment(seat_config, input_device->identifier); |
205 | } | 207 | } |
206 | 208 | ||
207 | switch (input_device->wlr_device->type) { | 209 | switch (input_device->wlr_device->type) { |
@@ -415,12 +417,8 @@ struct sway_container *seat_get_focus_by_type(struct sway_seat *seat, | |||
415 | return container_parent(focus, type); | 417 | return container_parent(focus, type); |
416 | } | 418 | } |
417 | 419 | ||
418 | void seat_set_config(struct sway_seat *seat, | 420 | void seat_apply_config(struct sway_seat *seat, |
419 | struct seat_config *seat_config) { | 421 | struct seat_config *seat_config) { |
420 | // clear configs | ||
421 | free_seat_config(seat->config); | ||
422 | seat->config = NULL; | ||
423 | |||
424 | struct sway_seat_device *seat_device = NULL; | 422 | struct sway_seat_device *seat_device = NULL; |
425 | wl_list_for_each(seat_device, &seat->devices, link) { | 423 | wl_list_for_each(seat_device, &seat->devices, link) { |
426 | seat_device->attachment_config = NULL; | 424 | seat_device->attachment_config = NULL; |
@@ -430,10 +428,19 @@ void seat_set_config(struct sway_seat *seat, | |||
430 | return; | 428 | return; |
431 | } | 429 | } |
432 | 430 | ||
433 | // add configs | ||
434 | seat->config = copy_seat_config(seat_config); | ||
435 | |||
436 | wl_list_for_each(seat_device, &seat->devices, link) { | 431 | wl_list_for_each(seat_device, &seat->devices, link) { |
437 | seat_configure_device(seat, seat_device->input_device); | 432 | seat_configure_device(seat, seat_device->input_device); |
438 | } | 433 | } |
439 | } | 434 | } |
435 | |||
436 | struct seat_config *seat_get_config(struct sway_seat *seat) { | ||
437 | struct seat_config *seat_config = NULL; | ||
438 | for (int i = 0; i < config->seat_configs->length; ++i ) { | ||
439 | seat_config = config->seat_configs->items[i]; | ||
440 | if (strcmp(seat->wlr_seat->name, seat_config->name) == 0) { | ||
441 | return seat_config; | ||
442 | } | ||
443 | } | ||
444 | |||
445 | return NULL; | ||
446 | } | ||