aboutsummaryrefslogtreecommitdiff
path: root/sway/config/input.c
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2017-12-16 11:25:59 -0500
committerTony Crisci <tony@dubstepdish.com>2017-12-16 11:25:59 -0500
commitf4a5a0ead4c8b155985c242db1fa5de5fa4807a0 (patch)
treea5f7f787aa04d68f800de9bb91b0813fb57fbc25 /sway/config/input.c
parentd3d36047605e57e81d7452173a913a0c04cbcfc1 (diff)
put seat and input config in their own files
Diffstat (limited to 'sway/config/input.c')
-rw-r--r--sway/config/input.c105
1 files changed, 105 insertions, 0 deletions
diff --git a/sway/config/input.c b/sway/config/input.c
new file mode 100644
index 00000000..6f8d31f7
--- /dev/null
+++ b/sway/config/input.c
@@ -0,0 +1,105 @@
+#define _XOPEN_SOURCE 700
+#include <stdlib.h>
+#include <limits.h>
+#include <float.h>
+#include "sway/config.h"
+#include "log.h"
+
+struct input_config *new_input_config(const char* identifier) {
+ struct input_config *input = calloc(1, sizeof(struct input_config));
+ if (!input) {
+ sway_log(L_DEBUG, "Unable to allocate input config");
+ return NULL;
+ }
+ sway_log(L_DEBUG, "new_input_config(%s)", identifier);
+ if (!(input->identifier = strdup(identifier))) {
+ free(input);
+ sway_log(L_DEBUG, "Unable to allocate input config");
+ return NULL;
+ }
+
+ input->tap = INT_MIN;
+ input->drag_lock = INT_MIN;
+ input->dwt = INT_MIN;
+ input->send_events = INT_MIN;
+ input->click_method = INT_MIN;
+ input->middle_emulation = INT_MIN;
+ input->natural_scroll = INT_MIN;
+ input->accel_profile = INT_MIN;
+ input->pointer_accel = FLT_MIN;
+ input->scroll_method = INT_MIN;
+ input->left_handed = INT_MIN;
+
+ return input;
+}
+
+void merge_input_config(struct input_config *dst, struct input_config *src) {
+ if (src->identifier) {
+ free(dst->identifier);
+ dst->identifier = strdup(src->identifier);
+ }
+ if (src->accel_profile != INT_MIN) {
+ dst->accel_profile = src->accel_profile;
+ }
+ if (src->click_method != INT_MIN) {
+ dst->click_method = src->click_method;
+ }
+ if (src->drag_lock != INT_MIN) {
+ dst->drag_lock = src->drag_lock;
+ }
+ if (src->dwt != INT_MIN) {
+ dst->dwt = src->dwt;
+ }
+ if (src->middle_emulation != INT_MIN) {
+ dst->middle_emulation = src->middle_emulation;
+ }
+ if (src->natural_scroll != INT_MIN) {
+ dst->natural_scroll = src->natural_scroll;
+ }
+ if (src->pointer_accel != FLT_MIN) {
+ dst->pointer_accel = src->pointer_accel;
+ }
+ if (src->scroll_method != INT_MIN) {
+ dst->scroll_method = src->scroll_method;
+ }
+ if (src->send_events != INT_MIN) {
+ dst->send_events = src->send_events;
+ }
+ if (src->tap != INT_MIN) {
+ dst->tap = src->tap;
+ }
+ if (src->xkb_layout) {
+ free(dst->xkb_layout);
+ dst->xkb_layout = strdup(src->xkb_layout);
+ }
+ if (src->xkb_model) {
+ free(dst->xkb_model);
+ dst->xkb_model = strdup(src->xkb_model);
+ }
+ if (src->xkb_options) {
+ free(dst->xkb_options);
+ dst->xkb_options = strdup(src->xkb_options);
+ }
+ if (src->xkb_rules) {
+ free(dst->xkb_rules);
+ dst->xkb_rules = strdup(src->xkb_rules);
+ }
+ if (src->xkb_variant) {
+ free(dst->xkb_variant);
+ dst->xkb_variant = strdup(src->xkb_variant);
+ }
+}
+
+void free_input_config(struct input_config *ic) {
+ if (!ic) {
+ return;
+ }
+ free(ic->identifier);
+ free(ic);
+}
+
+int input_identifier_cmp(const void *item, const void *data) {
+ const struct input_config *ic = item;
+ const char *identifier = data;
+ return strcmp(ic->identifier, identifier);
+}