aboutsummaryrefslogtreecommitdiff
path: root/sway/input/input-manager.c
diff options
context:
space:
mode:
authorBrian Ashworth <bosrsf04@gmail.com>2018-12-27 00:46:55 -0500
committeremersion <contact@emersion.fr>2018-12-29 19:40:40 +0100
commit3e8f548d1d0acb3aba384842615e6528b3027283 (patch)
tree8c0bd5fbcc42d9ad08a4630940598719f3d6a54e /sway/input/input-manager.c
parent4503ad2d19d5039259b572729115fef149f1b44e (diff)
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(
return NULL;
}
-static bool input_has_seat_configuration(void) {
+static bool input_has_seat_fallback_configuration(void) {
struct sway_seat *seat = NULL;
wl_list_for_each(seat, &server.input->seats, link) {
struct seat_config *seat_config = seat_get_config(seat);
- if (seat_config) {
+ if (seat_config && strcmp(seat_config->name, "*") != 0
+ && seat_config->fallback != -1) {
return true;
}
}
@@ -296,11 +297,12 @@ static void handle_new_input(struct wl_listener *listener, void *data) {
input_device->device_destroy.notify = handle_device_destroy;
struct sway_seat *seat = NULL;
- if (!input_has_seat_configuration()) {
- wlr_log(WLR_DEBUG, "no seat configuration, using default seat");
+ if (!input_has_seat_fallback_configuration()) {
+ wlr_log(WLR_DEBUG, "no seat config - creating default seat config");
seat = input_manager_get_default_seat();
- seat_add_device(seat, input_device);
- return;
+ struct seat_config *sc = new_seat_config(seat->wlr_seat->name);
+ sc->fallback = true;
+ store_seat_config(sc);
}
bool added = false;
@@ -459,15 +461,26 @@ void input_manager_apply_input_config(struct input_config *input_config) {
}
void input_manager_apply_seat_config(struct seat_config *seat_config) {
- wlr_log(WLR_DEBUG, "applying new seat config for seat %s",
- seat_config->name);
- struct sway_seat *seat = input_manager_get_seat(seat_config->name);
- if (!seat) {
- return;
+ wlr_log(WLR_DEBUG, "applying seat config for seat %s", seat_config->name);
+ if (strcmp(seat_config->name, "*") == 0) {
+ struct sway_seat *seat = NULL;
+ wl_list_for_each(seat, &server.input->seats, link) {
+ // Only apply the wildcard config directly if there is no seat
+ // specific config
+ struct seat_config *sc = seat_get_config(seat);
+ if (!sc) {
+ sc = seat_config;
+ }
+ seat_apply_config(seat, sc);
+ }
+ } else {
+ struct sway_seat *seat = input_manager_get_seat(seat_config->name);
+ if (!seat) {
+ return;
+ }
+ seat_apply_config(seat, seat_config);
}
- seat_apply_config(seat, seat_config);
-
// for every device, try to add it to a seat and if no seat has it
// attached, add it to the fallback seats.
struct sway_input_device *input_device = NULL;