mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-01-07 03:00:12 +01:00
touchpad: Only break out of tap FSM for clickpad button presses
It should be possible to initiate a drag by tapping-drag, but continue it by pressing a physical button continuing to drag by subsequent finger motions. As the generic evdev layer helps us ignore multiple button presses we can have the tap machine run completely separate from and uneffected by regular physical button presses, making the tap FSM much simpler than adding new states for handling button presse life times from outside of the tap state machine. A touchpad test is updated to test click while tapping instead of tap FSM break out. The updated test is re-added but only for clickpads only. The tap FSM svg is updated to say "clickpad button press" instead of "phys button press". Signed-off-by: Jonas Ådahl <jadahl@gmail.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
496cd6ab27
commit
94c59ef201
3 changed files with 616 additions and 538 deletions
File diff suppressed because it is too large
Load diff
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 81 KiB |
|
|
@ -542,7 +542,10 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time)
|
|||
struct tp_touch *t;
|
||||
int filter_motion = 0;
|
||||
|
||||
if (tp->queued & TOUCHPAD_EVENT_BUTTON_PRESS)
|
||||
/* Handle queued button pressed events from clickpads. For touchpads
|
||||
* with separate physical buttons, ignore button pressed events so they
|
||||
* don't interfere with tapping. */
|
||||
if (tp->buttons.is_clickpad && tp->queued & TOUCHPAD_EVENT_BUTTON_PRESS)
|
||||
tp_tap_handle_event(tp, NULL, TAP_EVENT_BUTTON, time);
|
||||
|
||||
tp_for_each_touch(tp, t) {
|
||||
|
|
|
|||
|
|
@ -256,14 +256,17 @@ START_TEST(touchpad_1fg_tap_click)
|
|||
|
||||
litest_drain_events(dev->libinput);
|
||||
|
||||
/* finger down, button click, finger up
|
||||
-> only one button left event pair */
|
||||
/* Finger down, finger up -> tap button press
|
||||
* Physical button click -> no button press/release
|
||||
* Tap timeout -> tap button release */
|
||||
litest_touch_down(dev, 0, 50, 50);
|
||||
litest_touch_up(dev, 0);
|
||||
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
||||
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
||||
litest_event(dev, EV_KEY, BTN_LEFT, 0);
|
||||
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
||||
litest_touch_up(dev, 0);
|
||||
libinput_dispatch(li);
|
||||
msleep(200);
|
||||
|
||||
libinput_dispatch(li);
|
||||
|
||||
|
|
@ -286,6 +289,42 @@ START_TEST(touchpad_2fg_tap_click)
|
|||
|
||||
litest_drain_events(dev->libinput);
|
||||
|
||||
/* two fingers down, left button click, fingers up
|
||||
-> one left button, one right button event pair */
|
||||
litest_touch_down(dev, 0, 50, 50);
|
||||
litest_touch_down(dev, 1, 70, 50);
|
||||
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
||||
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
||||
litest_event(dev, EV_KEY, BTN_LEFT, 0);
|
||||
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
||||
litest_touch_up(dev, 1);
|
||||
litest_touch_up(dev, 0);
|
||||
|
||||
libinput_dispatch(li);
|
||||
|
||||
assert_button_event(li, BTN_LEFT,
|
||||
LIBINPUT_BUTTON_STATE_PRESSED);
|
||||
assert_button_event(li, BTN_LEFT,
|
||||
LIBINPUT_BUTTON_STATE_RELEASED);
|
||||
assert_button_event(li, BTN_RIGHT,
|
||||
LIBINPUT_BUTTON_STATE_PRESSED);
|
||||
assert_button_event(li, BTN_RIGHT,
|
||||
LIBINPUT_BUTTON_STATE_RELEASED);
|
||||
|
||||
litest_assert_empty_queue(li);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(clickpad_2fg_tap_click)
|
||||
{
|
||||
struct litest_device *dev = litest_current_device();
|
||||
struct libinput *li = dev->libinput;
|
||||
|
||||
libinput_device_config_tap_set_enabled(dev->libinput_device,
|
||||
LIBINPUT_CONFIG_TAP_ENABLED);
|
||||
|
||||
litest_drain_events(dev->libinput);
|
||||
|
||||
/* two fingers down, button click, fingers up
|
||||
-> only one button left event pair */
|
||||
litest_touch_down(dev, 0, 50, 50);
|
||||
|
|
@ -684,6 +723,38 @@ START_TEST(touchpad_btn_left)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(clickpad_1fg_tap_click)
|
||||
{
|
||||
struct litest_device *dev = litest_current_device();
|
||||
struct libinput *li = dev->libinput;
|
||||
|
||||
libinput_device_config_tap_set_enabled(dev->libinput_device,
|
||||
LIBINPUT_CONFIG_TAP_ENABLED);
|
||||
|
||||
litest_drain_events(dev->libinput);
|
||||
|
||||
/* finger down, button click, finger up
|
||||
-> only one button left event pair */
|
||||
litest_touch_down(dev, 0, 50, 50);
|
||||
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
||||
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
||||
litest_event(dev, EV_KEY, BTN_LEFT, 0);
|
||||
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
||||
litest_touch_up(dev, 0);
|
||||
libinput_dispatch(li);
|
||||
msleep(200);
|
||||
|
||||
libinput_dispatch(li);
|
||||
|
||||
assert_button_event(li, BTN_LEFT,
|
||||
LIBINPUT_BUTTON_STATE_PRESSED);
|
||||
assert_button_event(li, BTN_LEFT,
|
||||
LIBINPUT_BUTTON_STATE_RELEASED);
|
||||
|
||||
litest_assert_empty_queue(li);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(clickpad_btn_left)
|
||||
{
|
||||
struct litest_device *dev = litest_current_device();
|
||||
|
|
@ -1553,8 +1624,9 @@ int main(int argc, char **argv) {
|
|||
litest_add("touchpad:tap", touchpad_1fg_tap_n_drag, LITEST_TOUCHPAD, LITEST_ANY);
|
||||
litest_add("touchpad:tap", touchpad_2fg_tap, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
|
||||
litest_add("touchpad:tap", touchpad_2fg_tap_inverted, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
|
||||
litest_add("touchpad:tap", touchpad_1fg_tap_click, LITEST_TOUCHPAD, LITEST_ANY);
|
||||
litest_add("touchpad:tap", touchpad_2fg_tap_click, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH|LITEST_APPLE_CLICKPAD);
|
||||
litest_add("touchpad:tap", touchpad_1fg_tap_click, LITEST_TOUCHPAD, LITEST_CLICKPAD);
|
||||
litest_add("touchpad:tap", touchpad_2fg_tap_click, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH|LITEST_CLICKPAD);
|
||||
|
||||
litest_add("touchpad:tap", touchpad_2fg_tap_click_apple, LITEST_APPLE_CLICKPAD, LITEST_ANY);
|
||||
litest_add("touchpad:tap", touchpad_no_2fg_tap_after_move, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
|
||||
litest_add("touchpad:tap", touchpad_no_2fg_tap_after_timeout, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
|
||||
|
|
@ -1575,6 +1647,9 @@ int main(int argc, char **argv) {
|
|||
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("touchpad:tap", clickpad_1fg_tap_click, LITEST_CLICKPAD, LITEST_ANY);
|
||||
litest_add("touchpad:tap", clickpad_2fg_tap_click, LITEST_CLICKPAD, LITEST_SINGLE_TOUCH|LITEST_APPLE_CLICKPAD);
|
||||
|
||||
litest_add_no_device("touchpad:clickfinger", touchpad_1fg_clickfinger);
|
||||
litest_add_no_device("touchpad:clickfinger", touchpad_2fg_clickfinger);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue