summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2019-12-14 01:57:51 -0500
committerFurkan Sahin <furkan-dev@proton.me>2019-12-14 01:57:51 -0500
commit492818087259958a28c03f854ed559cefed2fd42 (patch)
treeec9187d2749807334c77e1bcb67988b7de8a1684
parentac581ffb82efdae30fc6b1c185de1f40baa06f1b (diff)
config/input: set type for new identifier configs
When an input becomes available, the input type config for that device type will be merged underneath the input identifier config, provided they both exist. If an input type config gets added or modified at a later point, then those changes get merged onto the input identifier configs for that type. However there was a missing case of the input identifier config being added after the device is already available and the input type config existing. This makes it so that the first time an input identifier config gets stored, there will be a check to see if it matched any of the available devices. If it does, then there will be a search for the associated input type config, which will be merged underneath the input identifier config if found.
-rw-r--r--sway/config/input.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/sway/config/input.c b/sway/config/input.c
index 0993e9ab..2ed9c016 100644
--- a/sway/config/input.c
+++ b/sway/config/input.c
@@ -249,6 +249,17 @@ static void merge_type_on_existing(struct input_config *type_wildcard) {
}
}
+static const char *set_input_type(struct input_config *ic) {
+ struct sway_input_device *input_device;
+ wl_list_for_each(input_device, &server.input->devices, link) {
+ if (strcmp(input_device->identifier, ic->identifier) == 0) {
+ ic->input_type = input_device_get_type(input_device);
+ break;
+ }
+ }
+ return ic->input_type;
+}
+
struct input_config *store_input_config(struct input_config *ic,
char **error) {
bool wildcard = strcmp(ic->identifier, "*") == 0;
@@ -272,6 +283,19 @@ struct input_config *store_input_config(struct input_config *ic,
current = config_list->items[i];
}
+ if (!current && !wildcard && !type && set_input_type(ic)) {
+ for (i = 0; i < config->input_type_configs->length; i++) {
+ struct input_config *tc = config->input_type_configs->items[i];
+ if (strcmp(ic->input_type, tc->identifier + 5) == 0) {
+ current = new_input_config(ic->identifier);
+ current->input_type = ic->input_type;
+ merge_input_config(current, tc);
+ new_current = true;
+ break;
+ }
+ }
+ }
+
i = list_seq_find(config->input_configs, input_identifier_cmp, "*");
if (!current && i >= 0) {
current = new_input_config(ic->identifier);