mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-04 04:40:25 +01:00
touchpad: ignore hovering touches when tapping
We need to remember whether a tap was down or just hovering, otherwise we mess up the state machine when we send tap release events for taps that never switched to TOUCH_BEGIN. This is quick fix, really we should have a new state here, but that's a lot harder to implement. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
618ee6ac94
commit
3170b3519b
4 changed files with 29 additions and 1 deletions
|
|
@ -774,6 +774,9 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time)
|
|||
if (t->tap.is_thumb)
|
||||
continue;
|
||||
|
||||
if (t->state == TOUCH_HOVERING)
|
||||
continue;
|
||||
|
||||
if (t->state == TOUCH_BEGIN) {
|
||||
/* The simple version: if a touch is a thumb on
|
||||
* begin we ignore it. All other thumb touches
|
||||
|
|
@ -795,7 +798,8 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time)
|
|||
tp_tap_handle_event(tp, t, TAP_EVENT_MOTION, time);
|
||||
|
||||
} else if (t->state == TOUCH_END) {
|
||||
tp_tap_handle_event(tp, t, TAP_EVENT_RELEASE, time);
|
||||
if (t->was_down)
|
||||
tp_tap_handle_event(tp, t, TAP_EVENT_RELEASE, time);
|
||||
t->tap.state = TAP_TOUCH_STATE_IDLE;
|
||||
} else if (tp->tap.state != TAP_STATE_IDLE &&
|
||||
tp_tap_exceeds_motion_threshold(tp, t)) {
|
||||
|
|
|
|||
|
|
@ -214,6 +214,7 @@ tp_new_touch(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
|||
tp_motion_history_reset(t);
|
||||
t->dirty = true;
|
||||
t->has_ended = false;
|
||||
t->was_down = false;
|
||||
t->state = TOUCH_HOVERING;
|
||||
t->pinned.is_pinned = false;
|
||||
t->millis = time;
|
||||
|
|
@ -226,6 +227,7 @@ tp_begin_touch(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
|||
t->dirty = true;
|
||||
t->state = TOUCH_BEGIN;
|
||||
t->millis = time;
|
||||
t->was_down = true;
|
||||
tp->nfingers_down++;
|
||||
t->palm.time = time;
|
||||
t->thumb.state = THUMB_STATE_MAYBE;
|
||||
|
|
|
|||
|
|
@ -156,6 +156,9 @@ struct tp_touch {
|
|||
int distance; /* distance == 0 means touch */
|
||||
int pressure;
|
||||
|
||||
bool was_down; /* if distance == 0, false for pure hovering
|
||||
touches */
|
||||
|
||||
struct {
|
||||
/* A quirk mostly used on Synaptics touchpads. In a
|
||||
transition to/from fake touches > num_slots, the current
|
||||
|
|
|
|||
|
|
@ -2152,6 +2152,24 @@ START_TEST(touchpad_hover_2fg_1fg_down)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(touchpad_hover_1fg_tap)
|
||||
{
|
||||
struct litest_device *dev = litest_current_device();
|
||||
struct libinput *li = dev->libinput;
|
||||
|
||||
litest_enable_tap(dev->libinput_device);
|
||||
|
||||
litest_drain_events(li);
|
||||
|
||||
litest_hover_start(dev, 0, 50, 50);
|
||||
litest_hover_end(dev, 0);
|
||||
|
||||
libinput_dispatch(li);
|
||||
litest_assert_empty_queue(li);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
static void
|
||||
assert_btnevent_from_device(struct litest_device *device,
|
||||
unsigned int button,
|
||||
|
|
@ -4740,6 +4758,7 @@ litest_setup_tests_touchpad(void)
|
|||
litest_add("touchpad:hover", touchpad_hover_down_hover_down, LITEST_TOUCHPAD|LITEST_HOVER, LITEST_ANY);
|
||||
litest_add("touchpad:hover", touchpad_hover_2fg_noevent, LITEST_TOUCHPAD|LITEST_HOVER, LITEST_ANY);
|
||||
litest_add("touchpad:hover", touchpad_hover_2fg_1fg_down, LITEST_TOUCHPAD|LITEST_HOVER, LITEST_ANY);
|
||||
litest_add("touchpad:hover", touchpad_hover_1fg_tap, LITEST_TOUCHPAD|LITEST_HOVER, LITEST_ANY);
|
||||
|
||||
litest_add_for_device("touchpad:trackpoint", touchpad_trackpoint_buttons, LITEST_SYNAPTICS_TRACKPOINT_BUTTONS);
|
||||
litest_add_for_device("touchpad:trackpoint", touchpad_trackpoint_mb_scroll, LITEST_SYNAPTICS_TRACKPOINT_BUTTONS);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue