]> git.mdlowis.com Git - proto/labwc.git/commitdiff
config: add finding touch configurations
authorJens Peters <jp7677@gmail.com>
Fri, 19 Jan 2024 09:07:52 +0000 (10:07 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Mon, 22 Jan 2024 21:50:18 +0000 (21:50 +0000)
include/config/touch.h
src/config/meson.build
src/config/touch.c [new file with mode: 0644]

index 6b453fff77750f37fc6d2b93710d37fd111bc2f6..96423f9338c7ec06e3b8148404a2da93ebae1cfe 100644 (file)
@@ -11,4 +11,6 @@ struct touch_config_entry {
        struct wl_list link;     /* struct rcxml.touch_configs */
 };
 
+struct touch_config_entry *touch_find_config_for_device(char *device_name);
+
 #endif /* LABWC_TOUCH_CONFIG_H */
index a0968da81191100fbe05ed77e5df34d7d6a53e36..de08f6d0622a63aebd33da7298d78c1424b03be5 100644 (file)
@@ -3,6 +3,7 @@ labwc_sources += files(
   'keybind.c',
   'session.c',
   'mousebind.c',
+  'touch.c',
   'tablet.c',
   'libinput.c',
 )
diff --git a/src/config/touch.c b/src/config/touch.c
new file mode 100644 (file)
index 0000000..bd2bc06
--- /dev/null
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#define _POSIX_C_SOURCE 200809L
+#include <strings.h>
+#include <wlr/util/log.h>
+#include "common/list.h"
+#include "config/rcxml.h"
+
+static struct touch_config_entry *
+find_default_config(void)
+{
+       struct touch_config_entry *entry;
+       wl_list_for_each(entry, &rc.touch_configs, link) {
+               if (!entry->device_name) {
+                       wlr_log(WLR_INFO, "found default touch configuration");
+                       return entry;
+               }
+       }
+       return NULL;
+}
+
+struct touch_config_entry *
+touch_find_config_for_device(char *device_name)
+{
+       wlr_log(WLR_INFO, "find touch configuration for %s\n", device_name);
+       struct touch_config_entry *entry;
+       wl_list_for_each(entry, &rc.touch_configs, link) {
+               if (entry->device_name && !strcasecmp(entry->device_name, device_name)) {
+                       wlr_log(WLR_INFO, "found touch configuration for %s\n", device_name);
+                       return entry;
+               }
+       }
+       return find_default_config();
+}