This affects the touch device on graphics tablets.

Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
---
 src/evdev-mt-touchpad-tap.c | 18 +++++++++++++++++-
 test/touchpad.c             | 20 ++++++++++++++++----
 2 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c
index d2b2989..7b8560c 100644
--- a/src/evdev-mt-touchpad-tap.c
+++ b/src/evdev-mt-touchpad-tap.c
@@ -692,9 +692,16 @@ tp_tap_config_is_enabled(struct libinput_device *device)
 }
 
 static enum libinput_config_tap_state
-tp_tap_config_get_default(struct libinput_device *device)
+tp_tap_default(struct evdev_device *evdev)
 {
        /**
+        * If we don't have a left button we must have tapping enabled by
+        * default.
+        */
+       if (!libevdev_has_event_code(evdev->evdev, EV_KEY, BTN_LEFT))
+               return LIBINPUT_CONFIG_TAP_ENABLED;
+
+       /**
         * Tapping is disabled by default for two reasons:
         * * if you don't know that tapping is a thing (or enabled by
         *   default), you get spurious mouse events that make the desktop
@@ -706,6 +713,14 @@ tp_tap_config_get_default(struct libinput_device *device)
        return LIBINPUT_CONFIG_TAP_DISABLED;
 }
 
+static enum libinput_config_tap_state
+tp_tap_config_get_default(struct libinput_device *device)
+{
+       struct evdev_device *evdev = (struct evdev_device *)device;
+
+       return tp_tap_default(evdev);
+}
+
 int
 tp_init_tap(struct tp_dispatch *tp)
 {
@@ -716,6 +731,7 @@ tp_init_tap(struct tp_dispatch *tp)
        tp->device->base.config.tap = &tp->tap.config;
 
        tp->tap.state = TAP_STATE_IDLE;
+       tp->tap.enabled = tp_tap_default(tp->device);
 
        libinput_timer_init(&tp->tap.timer,
                            tp->device->base.seat->libinput,
diff --git a/test/touchpad.c b/test/touchpad.c
index 6741fa3..661f170 100644
--- a/test/touchpad.c
+++ b/test/touchpad.c
@@ -2169,8 +2169,6 @@ START_TEST(touchpad_tap_is_available)
        struct litest_device *dev = litest_current_device();
 
        
ck_assert_int_ge(libinput_device_config_tap_get_finger_count(dev->libinput_device),
 1);
-       
ck_assert_int_eq(libinput_device_config_tap_get_enabled(dev->libinput_device),
-                        LIBINPUT_CONFIG_TAP_DISABLED);
 }
 END_TEST
 
@@ -2187,15 +2185,28 @@ START_TEST(touchpad_tap_is_not_available)
 }
 END_TEST
 
-START_TEST(touchpad_tap_default)
+START_TEST(touchpad_tap_default_disabled)
 {
        struct litest_device *dev = litest_current_device();
 
+       /* this test is only run on specific devices */
+
        
ck_assert_int_eq(libinput_device_config_tap_get_default_enabled(dev->libinput_device),
                         LIBINPUT_CONFIG_TAP_DISABLED);
 }
 END_TEST
 
+START_TEST(touchpad_tap_default_enabled)
+{
+       struct litest_device *dev = litest_current_device();
+
+       /* this test is only run on specific devices */
+
+       
ck_assert_int_eq(libinput_device_config_tap_get_default_enabled(dev->libinput_device),
+                        LIBINPUT_CONFIG_TAP_ENABLED);
+}
+END_TEST
+
 START_TEST(touchpad_tap_invalid)
 {
        struct litest_device *dev = litest_current_device();
@@ -3346,7 +3357,8 @@ int main(int argc, char **argv) {
        litest_add("touchpad:tap", touchpad_1fg_double_tap_click, 
LITEST_CLICKPAD, LITEST_ANY);
        litest_add("touchpad:tap", touchpad_1fg_tap_n_drag_click, 
LITEST_CLICKPAD, LITEST_ANY);
 
-       litest_add("touchpad:tap", touchpad_tap_default, LITEST_TOUCHPAD, 
LITEST_ANY);
+       litest_add("touchpad:tap", touchpad_tap_default_disabled, 
LITEST_TOUCHPAD|LITEST_BUTTON, LITEST_ANY);
+       litest_add("touchpad:tap", touchpad_tap_default_enabled, 
LITEST_TOUCHPAD, LITEST_BUTTON);
        litest_add("touchpad:tap", touchpad_tap_invalid, LITEST_TOUCHPAD, 
LITEST_ANY);
        litest_add("touchpad:tap", touchpad_tap_is_available, LITEST_TOUCHPAD, 
LITEST_ANY);
        litest_add("touchpad:tap", touchpad_tap_is_not_available, LITEST_ANY, 
LITEST_TOUCHPAD);
-- 
2.1.0

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to