aboutsummaryrefslogtreecommitdiff
path: root/sway/config/input.c
diff options
context:
space:
mode:
authorTudor Brindus <me@tbrindus.ca>2020-06-19 14:11:57 -0400
committerSimon Ser <contact@emersion.fr>2020-10-12 15:01:37 +0200
commited247c031cb9783deb5c04631b53c5ac6c432eb7 (patch)
tree3b8aa74d49d6e6cb1518cd749854cba13728f259 /sway/config/input.c
parent136add4e1208fe631dd8f8590a69ef9b959cfe34 (diff)
input/tablet: add tool_mode option to set tablet tools as relative input
Closes #4139.
Diffstat (limited to 'sway/config/input.c')
-rw-r--r--sway/config/input.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/sway/config/input.c b/sway/config/input.c
index 2ed9c016..a998e170 100644
--- a/sway/config/input.c
+++ b/sway/config/input.c
@@ -40,6 +40,7 @@ struct input_config *new_input_config(const char* identifier) {
input->xkb_numlock = INT_MIN;
input->xkb_capslock = INT_MIN;
input->xkb_file_is_set = false;
+ input->tools = create_list();
return input;
}
@@ -153,6 +154,22 @@ void merge_input_config(struct input_config *dst, struct input_config *src) {
memcpy(dst->calibration_matrix.matrix, src->calibration_matrix.matrix,
sizeof(src->calibration_matrix.matrix));
}
+ for (int i = 0; i < src->tools->length; i++) {
+ struct input_config_tool *src_tool = src->tools->items[i];
+ for (int j = 0; j < dst->tools->length; j++) {
+ struct input_config_tool *dst_tool = dst->tools->items[j];
+ if (src_tool->type == dst_tool->type) {
+ dst_tool->mode = src_tool->mode;
+ goto tool_merge_outer;
+ }
+ }
+
+ struct input_config_tool *dst_tool = malloc(sizeof(*dst_tool));
+ memcpy(dst_tool, src_tool, sizeof(*dst_tool));
+ list_add(dst->tools, dst_tool);
+
+ tool_merge_outer:;
+ }
}
static bool validate_xkb_merge(struct input_config *dest,
@@ -358,6 +375,7 @@ void free_input_config(struct input_config *ic) {
free(ic->mapped_from_region);
free(ic->mapped_to_output);
free(ic->mapped_to_region);
+ list_free_items_and_destroy(ic->tools);
free(ic);
}