Now that we have run-time changes of the tap.enabled state move the check to the IDLE state only. Otherwise the tap machine may hang if tapping is disabled while a gesture is in progress.
Two basic tests are added to check for the tap default setting - which is now "tap disabled by default", for two reasons: * if you don't know that tapping is a thing (or enabled by default), you get spurious button events that make the desktop feel buggy. * if you do know what tapping is and you want it, you usually know where to enable it, or at least you can search for it. Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> --- Changes to v1: - changed to simple enabled/disabled configuration - updated tests for rebase on master - add comments why tapping is disabled by default src/evdev-mt-touchpad-tap.c | 66 +++++++++++++++++++++++++++++++++++++++++---- src/evdev-mt-touchpad.h | 1 + test/touchpad.c | 54 +++++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+), 5 deletions(-) diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c index 2541218..324a90c 100644 --- a/src/evdev-mt-touchpad-tap.c +++ b/src/evdev-mt-touchpad-tap.c @@ -433,13 +433,12 @@ tp_tap_handle_event(struct tp_dispatch *tp, enum tap_event event, uint64_t time) struct libinput *libinput = tp->device->base.seat->libinput; enum tp_tap_state current; - if (!tp->tap.enabled) - return; - current = tp->tap.state; switch(tp->tap.state) { case TAP_STATE_IDLE: + if (!tp->tap.enabled) + break; tp_tap_idle_handle_event(tp, event, time); break; case TAP_STATE_TOUCH: @@ -554,17 +553,74 @@ tp_tap_handle_timeout(uint64_t time, void *data) tp_tap_handle_event(tp, TAP_EVENT_TIMEOUT, time); } +static int +tp_tap_config_count(struct libinput_device *device) +{ + struct evdev_dispatch *dispatch; + struct tp_dispatch *tp; + + dispatch = ((struct evdev_device *) device)->dispatch; + tp = container_of(dispatch, tp, base); + + return min(tp->ntouches, 3); /* we only do up to 3 finger tap */ +} + +static enum libinput_config_status +tp_tap_config_set_enabled(struct libinput_device *device, int enabled) +{ + struct evdev_dispatch *dispatch; + struct tp_dispatch *tp; + + dispatch = ((struct evdev_device *) device)->dispatch; + tp = container_of(dispatch, tp, base); + + tp->tap.enabled = enabled; + + return LIBINPUT_CONFIG_STATUS_SUCCESS; +} + +static int +tp_tap_config_is_enabled(struct libinput_device *device) +{ + struct evdev_dispatch *dispatch; + struct tp_dispatch *tp; + + dispatch = ((struct evdev_device *) device)->dispatch; + tp = container_of(dispatch, tp, base); + + return tp->tap.enabled; +} + +static int +tp_tap_config_get_default(struct libinput_device *device) +{ + /** + * 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 + * feel buggy. + * * if you do know what tapping is and you want it, you + * usually know where to enable it, or at least you can search for + * it. + */ + return false; +} + int tp_init_tap(struct tp_dispatch *tp) { + tp->tap.config.count = tp_tap_config_count; + tp->tap.config.set_enabled = tp_tap_config_set_enabled; + tp->tap.config.get_enabled = tp_tap_config_is_enabled; + tp->tap.config.get_default = tp_tap_config_get_default; + tp->device->base.config.tap = &tp->tap.config; + tp->tap.state = TAP_STATE_IDLE; libinput_timer_init(&tp->tap.timer, tp->device->base.seat->libinput, tp_tap_handle_timeout, tp); - tp->tap.enabled = 1; /* FIXME */ - return 0; } diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h index 7afb3c4..cf2ea41 100644 --- a/src/evdev-mt-touchpad.h +++ b/src/evdev-mt-touchpad.h @@ -193,6 +193,7 @@ struct tp_dispatch { enum touchpad_event queued; struct { + struct libinput_device_config_tap config; bool enabled; struct libinput_timer timer; enum tp_tap_state state; diff --git a/test/touchpad.c b/test/touchpad.c index 288805e..7d81f14 100644 --- a/test/touchpad.c +++ b/test/touchpad.c @@ -116,6 +116,8 @@ START_TEST(touchpad_1fg_tap) struct libinput *li = dev->libinput; struct libinput_event *event; + libinput_device_config_tap_set_enabled(dev->libinput_device, 1); + litest_drain_events(li); litest_touch_down(dev, 0, 50, 50); @@ -141,6 +143,8 @@ START_TEST(touchpad_1fg_tap_n_drag) struct libinput *li = dev->libinput; struct libinput_event *event; + libinput_device_config_tap_set_enabled(dev->libinput_device, 1); + litest_drain_events(li); litest_touch_down(dev, 0, 50, 50); @@ -191,6 +195,8 @@ START_TEST(touchpad_2fg_tap) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; + libinput_device_config_tap_set_enabled(dev->libinput_device, 1); + litest_drain_events(dev->libinput); litest_touch_down(dev, 0, 50, 50); @@ -215,6 +221,8 @@ START_TEST(touchpad_2fg_tap_inverted) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; + libinput_device_config_tap_set_enabled(dev->libinput_device, 1); + litest_drain_events(dev->libinput); litest_touch_down(dev, 0, 50, 50); @@ -239,6 +247,8 @@ START_TEST(touchpad_1fg_tap_click) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; + libinput_device_config_tap_set_enabled(dev->libinput_device, 1); + litest_drain_events(dev->libinput); /* finger down, button click, finger up @@ -266,6 +276,8 @@ START_TEST(touchpad_2fg_tap_click) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; + libinput_device_config_tap_set_enabled(dev->libinput_device, 1); + litest_drain_events(dev->libinput); /* two fingers down, button click, fingers up @@ -295,6 +307,8 @@ START_TEST(touchpad_2fg_tap_click_apple) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; + libinput_device_config_tap_set_enabled(dev->libinput_device, 1); + litest_drain_events(dev->libinput); /* two fingers down, button click, fingers up @@ -325,6 +339,8 @@ START_TEST(touchpad_1fg_double_tap_click) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; + libinput_device_config_tap_set_enabled(dev->libinput_device, 1); + litest_drain_events(dev->libinput); /* one finger down, up, down, button click, finger up @@ -359,6 +375,8 @@ START_TEST(touchpad_1fg_tap_n_drag_click) struct libinput *li = dev->libinput; struct libinput_event *event; + libinput_device_config_tap_set_enabled(dev->libinput_device, 1); + litest_drain_events(dev->libinput); /* one finger down, up, down, move, button click, finger up @@ -599,6 +617,8 @@ START_TEST(clickpad_softbutton_left_tap_n_drag) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; + libinput_device_config_tap_set_enabled(dev->libinput_device, 1); + litest_drain_events(li); /* Tap in left button area, then finger down, button click @@ -639,6 +659,8 @@ START_TEST(clickpad_softbutton_right_tap_n_drag) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; + libinput_device_config_tap_set_enabled(dev->libinput_device, 1); + litest_drain_events(li); /* Tap in right button area, then finger down, button click @@ -1115,6 +1137,34 @@ START_TEST(touchpad_2fg_scroll) } END_TEST +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), 0); +} +END_TEST + +START_TEST(touchpad_tap_is_not_available) +{ + struct litest_device *dev = litest_current_device(); + + ck_assert_int_eq(libinput_device_config_tap_get_finger_count(dev->libinput_device), 0); + ck_assert_int_eq(libinput_device_config_tap_get_enabled(dev->libinput_device), 0); + ck_assert_int_eq(libinput_device_config_tap_set_enabled(dev->libinput_device, 1), + LIBINPUT_CONFIG_STATUS_UNSUPPORTED); +} +END_TEST + +START_TEST(touchpad_tap_default) +{ + struct litest_device *dev = litest_current_device(); + + ck_assert_int_eq(libinput_device_config_tap_get_default_enabled(dev->libinput_device), 0); +} +END_TEST + int main(int argc, char **argv) { litest_add("touchpad:motion", touchpad_1fg_motion, LITEST_TOUCHPAD, LITEST_ANY); @@ -1132,6 +1182,10 @@ 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_is_available, LITEST_TOUCHPAD, LITEST_ANY); + litest_add("touchpad:tap", touchpad_tap_is_not_available, LITEST_ANY, LITEST_TOUCHPAD); + litest_add_no_device("touchpad:clickfinger", touchpad_1fg_clickfinger); litest_add_no_device("touchpad:clickfinger", touchpad_2fg_clickfinger); -- 1.9.3 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel