]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Add `touchpad` device type
authorJared Baur <jaredbaur@fastmail.com>
Fri, 15 Dec 2023 15:36:29 +0000 (07:36 -0800)
committerJohan Malm <johanmalm@users.noreply.github.com>
Fri, 29 Dec 2023 08:08:32 +0000 (08:08 +0000)
It is nice to have finer granularity for device types to allow for
configurations such as using `naturalScroll` on touchpads, but not on
regular pointer devices such as mice.

docs/labwc-config.5.scd
docs/rc.xml.all
include/config/libinput.h
src/config/libinput.c
src/config/rcxml.c
src/seat.c

index a7c9dda35ebd23df7b4a06b2a28b657e297a71d7..ac20dcb79fc9cc1e320e0266098158cd980a1234 100644 (file)
@@ -435,11 +435,11 @@ windows using the mouse.
 *<libinput><device category="">*
        Define a category of devices to use the configuration values that
        follow. The category can be set to touch (devices that define a width
-       and height), non-touch, default, or the name of a device. You can obtain
-       your devices name by running *libinput list-devices* (you may need to
-       be root or a part of the input group to perform this.) Any members of
-       this category that are not set use the default for the device. With the
-       exception of tap-to-click, which is enabled by default.
+       and height), touchpad, non-touch, default, or the name of a device. You
+       can obtain your devices name by running *libinput list-devices* (you may
+       need to be root or a part of the input group to perform this.) Any
+       members of this category that are not set use the default for the
+       device. With the exception of tap-to-click, which is enabled by default.
 
 *<libinput><device category=""><naturalScroll>* [yes|no]
        Use natural scrolling for this category if available.
index 316586d9022505887ba2a4669bff3306af8bce0f..bc0e092c1b335b1e5eb6f0b4328848c0eeb3ed9f 100644 (file)
   </mouse>
 
   <!--
-    The *category* element can be set to touch, non-touch, default or the name
-    of a device. You can obtain device names by running *libinput list-devices*
-    as root or member of the input group.
+    The *category* element can be set to touch, touchpad, non-touch, default or
+    the name of a device. You can obtain device names by running *libinput
+    list-devices* as root or member of the input group.
 
     Tap is set to *yes* be default. All others are left blank in order to use
     device defaults.
index 61505b119fd13dd474c23669232dad433a1a2f48..83d512e4ab0e8c9ee67c2a357a0a41c84b0d90af 100644 (file)
@@ -9,6 +9,7 @@
 enum device_type {
        DEFAULT_DEVICE,
        TOUCH_DEVICE,
+       TOUCHPAD_DEVICE,
        NON_TOUCH_DEVICE,
 };
 
index e66060a0aef38eb7e39a3b5f99e66da588d560c3..8a447582ab75456304fcba822d3f66bf7231e158 100644 (file)
@@ -32,6 +32,9 @@ get_device_type(const char *s)
        if (!strcasecmp(s, "touch")) {
                return TOUCH_DEVICE;
        }
+       if (!strcasecmp(s, "touchpad")) {
+               return TOUCHPAD_DEVICE;
+       }
        if (!strcasecmp(s, "non-touch")) {
                return NON_TOUCH_DEVICE;
        }
index 0ff22edd8d49a6814438f1bc3ce4eaca2d452422..d5d575924889fe38b47f94f89b6d087147a0889d 100644 (file)
@@ -460,6 +460,7 @@ fill_libinput_category(char *nodename, char *content)
 
        if (!strcmp(nodename, "category")) {
                if (!strcmp(content, "touch")
+                               || !strcmp(content, "touchpad")
                                || !strcmp(content, "non-touch")
                                || !strcmp(content, "default")) {
                        current_libinput_category->type = get_device_type(content);
index ce78d4796d7af899703d1e6bc429b16d8d6c91fe..5a603c5a276134d335f0d4be1d5adc2e67066096 100644 (file)
@@ -33,17 +33,28 @@ input_device_destroy(struct wl_listener *listener, void *data)
        free(input);
 }
 
-static bool
-is_touch_device(struct wlr_input_device *wlr_input_device)
+static enum device_type
+device_type_from_wlr_device(struct wlr_input_device *wlr_input_device)
 {
        switch (wlr_input_device->type) {
        case WLR_INPUT_DEVICE_TOUCH:
        case WLR_INPUT_DEVICE_TABLET_TOOL:
-               return true;
+               return TOUCH_DEVICE;
        default:
                break;
        }
-       return false;
+
+       if (wlr_input_device->type == WLR_INPUT_DEVICE_POINTER &&
+                       wlr_input_device_is_libinput(wlr_input_device)) {
+               struct libinput_device *libinput_device =
+                       wlr_libinput_get_device_handle(wlr_input_device);
+
+               if (libinput_device_config_tap_get_finger_count(libinput_device) > 0) {
+                       return TOUCHPAD_DEVICE;
+               }
+       }
+
+       return NON_TOUCH_DEVICE;
 }
 
 static void
@@ -64,9 +75,8 @@ configure_libinput(struct wlr_input_device *wlr_input_device)
                return;
        }
 
-       enum device_type current_type;
-       current_type = is_touch_device(wlr_input_device)
-                       ? TOUCH_DEVICE : NON_TOUCH_DEVICE;
+       enum device_type current_type =
+               device_type_from_wlr_device(wlr_input_device);
 
        struct libinput_category *device_category, *dc = NULL;
        wl_list_for_each(device_category, &rc.libinput_categories, link) {