aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-12-14 01:57:51 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2019-12-14 09:31:42 -0500
commit218b5b9dc0f90693be0a77f0bd3001f1912b86aa (patch)
treeec9187d2749807334c77e1bcb67988b7de8a1684
parentinput/keyboard: defer wlr_keyboard_group destroy (diff)
downloadsway-218b5b9dc0f90693be0a77f0bd3001f1912b86aa.tar.gz
sway-218b5b9dc0f90693be0a77f0bd3001f1912b86aa.tar.zst
sway-218b5b9dc0f90693be0a77f0bd3001f1912b86aa.zip
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) {
249 } 249 }
250} 250}
251 251
252static const char *set_input_type(struct input_config *ic) {
253 struct sway_input_device *input_device;
254 wl_list_for_each(input_device, &server.input->devices, link) {
255 if (strcmp(input_device->identifier, ic->identifier) == 0) {
256 ic->input_type = input_device_get_type(input_device);
257 break;
258 }
259 }
260 return ic->input_type;
261}
262
252struct input_config *store_input_config(struct input_config *ic, 263struct input_config *store_input_config(struct input_config *ic,
253 char **error) { 264 char **error) {
254 bool wildcard = strcmp(ic->identifier, "*") == 0; 265 bool wildcard = strcmp(ic->identifier, "*") == 0;
@@ -272,6 +283,19 @@ struct input_config *store_input_config(struct input_config *ic,
272 current = config_list->items[i]; 283 current = config_list->items[i];
273 } 284 }
274 285
286 if (!current && !wildcard && !type && set_input_type(ic)) {
287 for (i = 0; i < config->input_type_configs->length; i++) {
288 struct input_config *tc = config->input_type_configs->items[i];
289 if (strcmp(ic->input_type, tc->identifier + 5) == 0) {
290 current = new_input_config(ic->identifier);
291 current->input_type = ic->input_type;
292 merge_input_config(current, tc);
293 new_current = true;
294 break;
295 }
296 }
297 }
298
275 i = list_seq_find(config->input_configs, input_identifier_cmp, "*"); 299 i = list_seq_find(config->input_configs, input_identifier_cmp, "*");
276 if (!current && i >= 0) { 300 if (!current && i >= 0) {
277 current = new_input_config(ic->identifier); 301 current = new_input_config(ic->identifier);