]> git.mdlowis.com Git - proto/labwc.git/commitdiff
config: parse multiple touch configurations
authorJens Peters <jp7677@gmail.com>
Fri, 19 Jan 2024 09:06:53 +0000 (10:06 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Mon, 22 Jan 2024 21:50:18 +0000 (21:50 +0000)
Also temporary disable touch output mapping.
Will be restored later.

include/config/rcxml.h
src/config/rcxml.c
src/seat.c

index b9294d5e77834b5992e9441cf9ffd971c212adc5..76094c99c370ad8472b24c21cb3766b5166e16a6 100644 (file)
@@ -9,6 +9,7 @@
 #include "common/border.h"
 #include "common/buf.h"
 #include "common/font.h"
+#include "config/touch.h"
 #include "config/tablet.h"
 #include "config/libinput.h"
 #include "resize_indicator.h"
@@ -92,9 +93,7 @@ struct rcxml {
        double scroll_factor;
 
        /* touch tablet */
-       struct touch_config {
-               char *output_name;
-       } touch;
+       struct wl_list touch_configs;
 
        /* graphics tablet */
        struct tablet_config {
index c8c4b4464cec528443cf4475c5807f4ada1646ce..9dd97ecb5dd741e3d31508726744f37c87f55c8c 100644 (file)
@@ -36,6 +36,7 @@ static bool in_regions;
 static bool in_usable_area_override;
 static bool in_keybind;
 static bool in_mousebind;
+static bool in_touch;
 static bool in_libinput_category;
 static bool in_window_switcher_field;
 static bool in_window_rules;
@@ -46,6 +47,7 @@ static bool in_action_else_branch;
 static struct usable_area_override *current_usable_area_override;
 static struct keybind *current_keybind;
 static struct mousebind *current_mousebind;
+static struct touch_config_entry *current_touch;
 static struct libinput_category *current_libinput_category;
 static const char *current_mouse_context;
 static struct action *current_keybind_action;
@@ -428,6 +430,22 @@ fill_mousebind(char *nodename, char *content)
        }
 }
 
+static void
+fill_touch(char *nodename, char *content)
+{
+       if (!strcasecmp(nodename, "touch")) {
+               current_touch = znew(*current_touch);
+               wl_list_append(&rc.touch_configs, &current_touch->link);
+       } else if (!strcasecmp(nodename, "deviceName.touch")) {
+               current_touch->device_name = xstrdup(content);
+       } else if (!strcasecmp(nodename, "mapToOutput.touch")) {
+               current_touch->output_name = xstrdup(content);
+       } else {
+               wlr_log(WLR_ERROR, "Unexpected data in touch parser: %s=\"%s\"",
+                       nodename, content);
+       }
+}
+
 static int
 get_accel_profile(const char *s)
 {
@@ -687,6 +705,10 @@ entry(xmlNode *node, char *nodename, char *content)
                        fill_mousebind(nodename, content);
                }
        }
+       if (in_touch) {
+               fill_touch(nodename, content);
+               return;
+       }
        if (in_libinput_category) {
                fill_libinput_category(nodename, content);
                return;
@@ -866,8 +888,6 @@ entry(xmlNode *node, char *nodename, char *content)
                } else {
                        wlr_log(WLR_ERROR, "Invalid value for <resize popupShow />");
                }
-       } else if (!strcasecmp(nodename, "mapToOutput.touch")) {
-               rc.touch.output_name = xstrdup(content);
        } else if (!strcasecmp(nodename, "mapToOutput.tablet")) {
                rc.tablet.output_name = xstrdup(content);
        } else if (!strcasecmp(nodename, "rotate.tablet")) {
@@ -948,6 +968,12 @@ xml_tree_walk(xmlNode *node)
                        in_mousebind = false;
                        continue;
                }
+               if (!strcasecmp((char *)n->name, "touch")) {
+                       in_touch = true;
+                       traverse(n);
+                       in_touch = false;
+                       continue;
+               }
                if (!strcasecmp((char *)n->name, "device")) {
                        in_libinput_category = true;
                        traverse(n);
@@ -1030,6 +1056,7 @@ rcxml_init(void)
                wl_list_init(&rc.regions);
                wl_list_init(&rc.window_switcher.fields);
                wl_list_init(&rc.window_rules);
+               wl_list_init(&rc.touch_configs);
        }
        has_run = true;
 
@@ -1051,8 +1078,6 @@ rcxml_init(void)
        rc.doubleclick_time = 500;
        rc.scroll_factor = 1.0;
 
-       rc.touch.output_name = NULL;
-
        rc.tablet.output_name = NULL;
        rc.tablet.rotation = 0;
        rc.tablet.box = (struct wlr_fbox){0};
@@ -1574,7 +1599,13 @@ rcxml_finish(void)
                zfree(m);
        }
 
-       zfree(rc.touch.output_name);
+       struct touch_config_entry *touch_config, *touch_config_tmp;
+       wl_list_for_each_safe(touch_config, touch_config_tmp, &rc.touch_configs, link) {
+               wl_list_remove(&touch_config->link);
+               zfree(touch_config->device_name);
+               zfree(touch_config->output_name);
+               zfree(touch_config);
+       }
 
        zfree(rc.tablet.output_name);
 
@@ -1609,6 +1640,7 @@ rcxml_finish(void)
        current_usable_area_override = NULL;
        current_keybind = NULL;
        current_mousebind = NULL;
+       current_touch = NULL;
        current_libinput_category = NULL;
        current_mouse_context = NULL;
        current_keybind_action = NULL;
index 36ecb5d37e4a585adf193d6cc24287069130bcce..b0cb3855d83d7145a3a610ac4dbec548ae889d90 100644 (file)
@@ -273,7 +273,7 @@ static void
 map_touch_to_output(struct seat *seat, struct wlr_input_device *dev)
 {
        struct wlr_touch *touch = wlr_touch_from_input_device(dev);
-       char *output_name = touch->output_name ? touch->output_name : rc.touch.output_name;
+       char *output_name = touch->output_name ? touch->output_name : NULL;
        wlr_log(WLR_INFO, "map touch to output %s\n", output_name);
        map_input_to_output(seat, dev, output_name);
 }