aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/input-manager.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-12-27 00:46:55 -0500
committerLibravatar emersion <contact@emersion.fr>2018-12-29 19:40:40 +0100
commit3e8f548d1d0acb3aba384842615e6528b3027283 (patch)
tree8c0bd5fbcc42d9ad08a4630940598719f3d6a54e /sway/input/input-manager.c
parentsway-output(5): doc scaling consideration for pos (diff)
downloadsway-3e8f548d1d0acb3aba384842615e6528b3027283.tar.gz
sway-3e8f548d1d0acb3aba384842615e6528b3027283.tar.zst
sway-3e8f548d1d0acb3aba384842615e6528b3027283.zip
Revamp seat configs
This makes seat configs work like output and input configs do. This also adds support for wildcard seat configs. A seat config is still created in the main seat command handler, but instead of creating a new one in the subcommands and destroying the main seat command's instance, the seat subcommands modify the main one. The seat config is then stored, where it is merged appropriately. The seat config returned from `store_seat_config` is then applied. When attempting to apply a wildcard seat config, a seat specific config is queried for and if found, that is used. Otherwise, the wildcard config is applied directly. Additionally, instead of adding input devices to the default seat directly when there is no seat configs, a seat config for the default seat is created with only fallback set to true, which is more explicit. It also fixes an issue where running a seat command at runtime (with no seat config in the sway config), would result in all input devices being removed from the default seat and leaving sway in an unusable state. Also, instead of checking for any seat config, the search is for a seat config with a fallback option seat. This makes it so if there are only seat configs with fallback set to -1, the default seat is still created since there is no explicit notion on what to do regarding fallbacks. However, if there is even a single fallback 0, then the default seat is not used as a fallback. This will be needed for seat subcommands like hide_cursor where the user may only want to set that property without effecting anything else.
Diffstat (limited to 'sway/input/input-manager.c')
-rw-r--r--sway/input/input-manager.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c
index 89146d5b..055f6752 100644
--- a/sway/input/input-manager.c
+++ b/sway/input/input-manager.c
@@ -82,11 +82,12 @@ static struct sway_input_device *input_sway_device_from_wlr(
82 return NULL; 82 return NULL;
83} 83}
84 84
85static bool input_has_seat_configuration(void) { 85static bool input_has_seat_fallback_configuration(void) {
86 struct sway_seat *seat = NULL; 86 struct sway_seat *seat = NULL;
87 wl_list_for_each(seat, &server.input->seats, link) { 87 wl_list_for_each(seat, &server.input->seats, link) {
88 struct seat_config *seat_config = seat_get_config(seat); 88 struct seat_config *seat_config = seat_get_config(seat);
89 if (seat_config) { 89 if (seat_config && strcmp(seat_config->name, "*") != 0
90 && seat_config->fallback != -1) {
90 return true; 91 return true;
91 } 92 }
92 } 93 }
@@ -296,11 +297,12 @@ static void handle_new_input(struct wl_listener *listener, void *data) {
296 input_device->device_destroy.notify = handle_device_destroy; 297 input_device->device_destroy.notify = handle_device_destroy;
297 298
298 struct sway_seat *seat = NULL; 299 struct sway_seat *seat = NULL;
299 if (!input_has_seat_configuration()) { 300 if (!input_has_seat_fallback_configuration()) {
300 wlr_log(WLR_DEBUG, "no seat configuration, using default seat"); 301 wlr_log(WLR_DEBUG, "no seat config - creating default seat config");
301 seat = input_manager_get_default_seat(); 302 seat = input_manager_get_default_seat();
302 seat_add_device(seat, input_device); 303 struct seat_config *sc = new_seat_config(seat->wlr_seat->name);
303 return; 304 sc->fallback = true;
305 store_seat_config(sc);
304 } 306 }
305 307
306 bool added = false; 308 bool added = false;
@@ -459,15 +461,26 @@ void input_manager_apply_input_config(struct input_config *input_config) {
459} 461}
460 462
461void input_manager_apply_seat_config(struct seat_config *seat_config) { 463void input_manager_apply_seat_config(struct seat_config *seat_config) {
462 wlr_log(WLR_DEBUG, "applying new seat config for seat %s", 464 wlr_log(WLR_DEBUG, "applying seat config for seat %s", seat_config->name);
463 seat_config->name); 465 if (strcmp(seat_config->name, "*") == 0) {
464 struct sway_seat *seat = input_manager_get_seat(seat_config->name); 466 struct sway_seat *seat = NULL;
465 if (!seat) { 467 wl_list_for_each(seat, &server.input->seats, link) {
466 return; 468 // Only apply the wildcard config directly if there is no seat
469 // specific config
470 struct seat_config *sc = seat_get_config(seat);
471 if (!sc) {
472 sc = seat_config;
473 }
474 seat_apply_config(seat, sc);
475 }
476 } else {
477 struct sway_seat *seat = input_manager_get_seat(seat_config->name);
478 if (!seat) {
479 return;
480 }
481 seat_apply_config(seat, seat_config);
467 } 482 }
468 483
469 seat_apply_config(seat, seat_config);
470
471 // for every device, try to add it to a seat and if no seat has it 484 // for every device, try to add it to a seat and if no seat has it
472 // attached, add it to the fallback seats. 485 // attached, add it to the fallback seats.
473 struct sway_input_device *input_device = NULL; 486 struct sway_input_device *input_device = NULL;