mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-04 05:50:26 +01:00
touchpad: Rewrite / fix tp_release_all_taps
Before this commit tp_release_all_taps would call tp_tap_handle_timeout, which is a nop when in state DRAGGING. tp_clear_state then releases all touches and calls touchpad_handle_state which moves the state to DRAGGING_WAIT, and the button 1 release will only be done after the tap-timeout, rather then directly as it should on tp_clear_state. This commit fixes this by instead of calling tp_tap_handle_timeout, directly releasing pressed buttons and switching to state DEAD or IDLE depending on fingers_down. Besides fixing this issue, this rewrite also makes it possible to use tp_release_all_taps outside of tp_clear_state, which will be used to add tap suspend / resume functionality in a follow up commit. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
50107eca3f
commit
7dc2ea22ed
2 changed files with 15 additions and 1 deletions
|
|
@ -113,6 +113,11 @@ tp_tap_notify(struct tp_dispatch *tp,
|
|||
return;
|
||||
}
|
||||
|
||||
if (state == LIBINPUT_BUTTON_STATE_PRESSED)
|
||||
tp->tap.buttons_pressed |= (1 << nfingers);
|
||||
else
|
||||
tp->tap.buttons_pressed &= ~(1 << nfingers);
|
||||
|
||||
evdev_pointer_notify_button(tp->device,
|
||||
time,
|
||||
button,
|
||||
|
|
@ -697,5 +702,13 @@ tp_destroy_tap(struct tp_dispatch *tp)
|
|||
void
|
||||
tp_release_all_taps(struct tp_dispatch *tp, uint64_t now)
|
||||
{
|
||||
tp_tap_handle_timeout(now, tp);
|
||||
int i;
|
||||
|
||||
for (i = 1; i <= 3; i++) {
|
||||
if (tp->tap.buttons_pressed & (1 << i))
|
||||
tp_tap_notify(tp, NULL, now, i,
|
||||
LIBINPUT_BUTTON_STATE_RELEASED);
|
||||
}
|
||||
|
||||
tp->tap.state = tp->nfingers_down ? TAP_STATE_DEAD : TAP_STATE_IDLE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -213,6 +213,7 @@ struct tp_dispatch {
|
|||
bool enabled;
|
||||
struct libinput_timer timer;
|
||||
enum tp_tap_state state;
|
||||
uint32_t buttons_pressed;
|
||||
} tap;
|
||||
|
||||
struct {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue