]> git.mdlowis.com Git - proto/labwc.git/commitdiff
config: add configuration for tablet tool motion
authorJens Peters <jp7677@gmail.com>
Fri, 5 Jul 2024 04:17:29 +0000 (06:17 +0200)
committerJohan Malm <johanmalm@users.noreply.github.com>
Fri, 19 Jul 2024 21:45:41 +0000 (22:45 +0100)
include/config/rcxml.h
include/config/tablet-tool.h [new file with mode: 0644]
include/input/tablet.h
src/config/meson.build
src/config/rcxml.c
src/config/tablet-tool.c [new file with mode: 0644]
src/input/tablet.c

index a9e895894ba41c3b302cfd0b01f11813c99114ab..a6172d83b5b190531f83d43ee76488b2ac16d017 100644 (file)
@@ -11,6 +11,7 @@
 #include "common/font.h"
 #include "config/touch.h"
 #include "config/tablet.h"
+#include "config/tablet-tool.h"
 #include "config/libinput.h"
 #include "resize-indicator.h"
 #include "theme.h"
@@ -102,6 +103,9 @@ struct rcxml {
                uint16_t button_map_count;
                struct button_map_entry button_map[BUTTON_MAP_MAX];
        } tablet;
+       struct tablet_tool_config {
+               enum motion motion;
+       } tablet_tool;
 
        /* libinput */
        struct wl_list libinput_categories;
diff --git a/include/config/tablet-tool.h b/include/config/tablet-tool.h
new file mode 100644 (file)
index 0000000..bd1943a
--- /dev/null
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef LABWC_TABLET_TOOL_CONFIG_H
+#define LABWC_TABLET_TOOL_CONFIG_H
+
+#include <stdint.h>
+
+enum motion {
+       LAB_TABLET_MOTION_ABSOLUTE = 0,
+       LAB_TABLET_MOTION_RELATIVE,
+};
+
+enum motion tablet_parse_motion(const char *name);
+
+#endif /* LABWC_TABLET_TOOL_CONFIG_H */
index 1603598ea7e2413c55f83c516fd3e13610713379..93fdda5aa4593293a42f8c06999297a4df01d88c 100644 (file)
@@ -9,17 +9,12 @@ struct seat;
 struct wlr_device;
 struct wlr_input_device;
 
-enum lab_tablet_motion_mode {
-       LAB_TABLET_MOTION_ABSOLUTE = 0,
-       LAB_TABLET_MOTION_RELATIVE,
-};
-
 struct drawing_tablet {
        struct wlr_input_device *wlr_input_device;
        struct seat *seat;
        struct wlr_tablet *tablet;
        struct wlr_tablet_v2_tablet *tablet_v2;
-       enum lab_tablet_motion_mode motion_mode;
+       enum motion motion_mode;
        double x, y, dx, dy;
        double distance;
        double pressure;
index de08f6d0622a63aebd33da7298d78c1424b03be5..70b1baa371da54e4e4aada14384d8e181935ef3b 100644 (file)
@@ -5,5 +5,6 @@ labwc_sources += files(
   'mousebind.c',
   'touch.c',
   'tablet.c',
+  'tablet-tool.c',
   'libinput.c',
 )
index 84c117b60a2de8b55e938066c19e6ff4e141e0ef..fac2cbf15c6ea17d6d1c9b40f93d72e593268447 100644 (file)
@@ -1061,6 +1061,8 @@ entry(xmlNode *node, char *nodename, char *content)
                } else {
                        wlr_log(WLR_ERROR, "Missing 'button' argument for tablet button mapping");
                }
+       } else if (!strcasecmp(nodename, "motion.tabletTool")) {
+               rc.tablet_tool.motion = tablet_parse_motion(content);
        } else if (!strcasecmp(nodename, "ignoreButtonReleasePeriod.menu")) {
                rc.menu_ignore_button_release_period = atoi(content);
        } else if (!strcasecmp(nodename, "width.magnifier")) {
@@ -1258,6 +1260,7 @@ rcxml_init(void)
        rc.tablet.rotation = 0;
        rc.tablet.box = (struct wlr_fbox){0};
        tablet_load_default_button_mappings();
+       rc.tablet_tool.motion = LAB_TABLET_MOTION_ABSOLUTE;
 
        rc.repeat_rate = 25;
        rc.repeat_delay = 600;
diff --git a/src/config/tablet-tool.c b/src/config/tablet-tool.c
new file mode 100644 (file)
index 0000000..7e17141
--- /dev/null
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#define _POSIX_C_SOURCE 200809L
+#include <strings.h>
+#include <wlr/util/log.h>
+#include "config/tablet-tool.h"
+
+enum motion
+tablet_parse_motion(const char *name)
+{
+       if (!strcasecmp(name, "Absolute")) {
+               return LAB_TABLET_MOTION_ABSOLUTE;
+       } else if (!strcasecmp(name, "Relative")) {
+               return LAB_TABLET_MOTION_RELATIVE;
+       }
+       wlr_log(WLR_ERROR, "Invalid value for tablet motion: %s", name);
+       return LAB_TABLET_MOTION_ABSOLUTE;
+}
index e533533422ac90211ed1f22bdf15a352126b2291..b417ea95c6524e6a23eed9ad765f36feac94b6c8 100644 (file)
@@ -19,7 +19,7 @@
 #include "idle.h"
 #include "action.h"
 
-static enum lab_tablet_motion_mode
+static enum motion
 tool_motion_mode(struct wlr_tablet_tool *tool)
 {
        /*