From 3b0c194f803ee6588977cdfabc78f28cfb33b9bc Mon Sep 17 00:00:00 2001 From: satrmb <10471-satrmb_true-email-is-private_contact-via-web@gitlab.freedesktop.org> Date: Sat, 8 Aug 2020 10:30:31 +0200 Subject: [PATCH] touchpad: count only tapping fingers for clickfinger if hold-and-tap is on Unless there are only non-tapping fingers, of course. For this to work, the tapping state machine needs to hold off on marking all touches as DEAD on button down. This does not hurt because their state becomes relevant only when the button has gone up again, which marks them as DEAD by entering TAP_STATE_DEAD. Signed-off-by: satrmb <10471-satrmb@users.noreply.gitlab.freedesktop.org> --- doc/touchpad-tap-state-machine.svg | 2 +- src/evdev-mt-touchpad-buttons.c | 10 ++++++++++ src/evdev-mt-touchpad-tap.c | 1 - 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/touchpad-tap-state-machine.svg b/doc/touchpad-tap-state-machine.svg index 8429efa4..d02ffa36 100644 --- a/doc/touchpad-tap-state-machine.svg +++ b/doc/touchpad-tap-state-machine.svg @@ -1,3 +1,3 @@ -yesnoyesnoyesnonononononononononoyesnononoyesnoyesnoyesyesyesnononononononoyesyesyesnonoyesnonoyesyesyesyesyes(this section exists for [n] = 1, [n] = 2, and [n] = 3)(this section exists for [m] = 1, [m] = 2, and [m] = 3),for a total of 9 times due to combination with [n]yesyesyesyesyesyesyesyesyes
IDLE
IDLE
firstfinger downTOUCH_TOUCHTOUCHsecondfinger downTOUCH_TOUCHTOUCH_2thirdfinger downTOUCH_TOUCHTOUCH_3TOUCH_2_RELEASEyeseitherfinger upyesremainingfinger upanyfinger upTOUCH_3_RELEASEeitherfinger upTOUCH_3_RELEASE_2yesremainingfinger upTOUCH_IDLEyesTOUCH_IDLETOUCH_IDLEyesTOUCH_IDLETOUCH_IDLEpalmTOUCH_DEADeitherfinger palmTOUCH_DEADyesanyfinger palmTOUCH_DEADyeseitherfinger palmTOUCH_DEADyesremainingfinger palmTOUCH_DEADyesremainingfinger palmTOUCH_DEAD2-finger tap3-finger tapyesfinger upTOUCH_IDLE1-finger tapfourthfinger down
IDLE
IDLE
TAPPEDyes2-finger tappalmfinger upbutton [n]pressbutton [n]releaseDRAGGING_OR_DOUBLETAPyesfinger downtap-and-dragtimeouttimeoutmove >thresholdDRAGGINGpalmfinger upnoyesdrag-lockenabled?DRAGLOCK_WAITDRAGLOCK_CONTINUEfinger uppalmtimeoutmove >thresholddrag-locktimeout1-finger tapyesnonon-palmfinger count== 0?finger down1-finger taptimeouttimeouthold-and-tap enabled?HOLD3-finger tapnohold-and-tap enabled?timeouthold-and-tap enabled?3-finger tapTOUCH_2_HOLDTOUCH_3_HOLDtimeouthold-and-tap enabled?timeoutyesnohold-and-tap enabled?timeouthold-and-tap enabled?palmfinger upTOUCH_DEADTOUCH_IDLEeitherfinger palmeitherfinger upTOUCH_DEADTOUCH_IDLEanyfinger palmanyfinger upTOUCH_DEADTOUCH_IDLETOUCH_TOUCHTOUCH_4_PLUSyesanyfinger palmyesanyfinger upTOUCH_IDLEyesTOUCH_DEADTOUCH_4_PLUS_HOLDtimeouthold-and-tap enabled?anyfinger upTOUCH_IDLEanyfinger palmTOUCH_DEADfourthfinger downTOUCH_TOUCHTOUCH_4_PLUS_RELEASEyesanyfinger palmyesanyfinger upyesTOUCH_DEADTOUCH_IDLEtimeouthold-and-tap enabled?TOUCH_4_PLUS_RELEASE_2timeouthold-and-tap enabled?yesanyfinger palmyesanyfinger upTOUCH_DEADTOUCH_IDLETOUCH_4_PLUS_RELEASE_3timeouthold-and-tap enabled?yesanyfinger palmyesanyfinger upyesTOUCH_DEADTOUCH_IDLE1-finger tap2-finger tap3-finger tapDEADBUTTONclickpadbuttonreleaseall fingersTOUCH_DEADnoyesnon-palmfinger count== 0?clickpadbuttonpressanyfinger upTOUCH_IDLEanyfinger palmmove >thresholdmove >thresholdmove >thresholdmove >thresholdmove >thresholdmove >thresholdmove >thresholdmove >thresholdmove >thresholdhold-and-tap enabled?move >thresholdmove >thresholdhold-and-tap enabled?yesnohold-and-tap enabled?move >thresholdhold-and-tap enabled?3-finger tapmove >thresholdyesnohold-and-tap enabled?move >thresholdyesnohold-and-tap enabled?clickpadbuttonpressclickpadbuttonpressclickpadbuttonpressyesnohold-and-tap enabled?1-finger tapclickpadbuttonpressyesnohold-and-tap enabled?2-finger tapclickpadbuttonpressclickpadbuttonpress3-finger tapyeshold-and-tap enabled?clickpadbuttonpressclickpadbuttonpressclickpadbuttonpressclickpadbuttonpressclickpadbuttonpressclickpadbuttonpressclickpadbuttonpressclickpadbuttonpress1-finger tap3-finger tapbutton [n]releaseBUTTONclickpadbuttonreleaseclickpadbuttonpressbutton [n]releaseclickpadbuttonpressclickpadbuttonpressclickpadbuttonpressclickpadbuttonpressclickpadbuttonpressbutton [n]press
[n] = 1
[n] = 1
[n] = 1
[n] = 1
[n] = 2
[n] = 2
[n] = 3
[n] = 3
notap-and-dragenabled?move >thresholdnonon-palmfinger count== 1?nonon-palmfinger count== 0?secondfinger downsecondfinger downDRAGGING_OR_TAPPED1-finger tap2-finger tap
[m] = 1
[m] = 1
yes
[m] = 2
[m] = 2
3-finger tap
[m] = 3
[m] = 3
noyesnon-palmfinger count== 0?finger uppalm
[n] = [m]
[n] = [m]
noyes[n] == [m]?no[n] == [m]?button [m]pressbutton [n]releaseyesclickpadbuttonpressno[n] == [m]?button [m]releasetap-and-dragtimeoutmove >thresholdadditionalfinger downnoyes[n] == [m]?button [m]releaseset tap stateto DEADfinger downTOUCH_TOUCHyeshold-and-tap enabled?TOUCH_DEADnoyesnothat fingerTOUCH_TOUCH?nothat fingerTOUCH_TOUCH?that fingerTOUCH_TOUCH?nothat fingerTOUCH_TOUCH?that fingerTOUCH_TOUCH?nothat fingerTOUCH_TOUCH?that fingerTOUCH_TOUCH?nothat fingerTOUCH_TOUCH?TOUCH_IDLETOUCH_IDLETOUCH_IDLETOUCH_IDLETOUCH_TOUCHfinger count == 0?yesthat fingerTOUCH_TOUCH?nothat fingerTOUCH_TOUCH?TOUCH_IDLEthat fingerTOUCH_TOUCH?nothat fingerTOUCH_TOUCH?nothat fingerTOUCH_TOUCH?that fingerTOUCH_TOUCH?TOUCH_IDLETOUCH_IDLEthat fingerTOUCH_TOUCH?that fingerTOUCH_TOUCH?nothat fingerTOUCH_TOUCH?nothat fingerTOUCH_TOUCH?TOUCH_IDLETOUCH_IDLEnothat fingerTOUCH_TOUCH?nothat fingerTOUCH_TOUCH?TOUCH_IDLETOUCH_TOUCHfinger count == 1?TOUCH_TOUCHfinger count == 2?noTOUCH_TOUCHfinger count == 3?thumbyesnodrag state== IDLE?yesnon-palmfinger count== 1?TOUCH_DEADthumbTOUCH_DEADnoyesnodrag state== IDLE?drag state== IDLE?drag state== IDLE?drag state== IDLE?yesnodrag state== DRAGLOCK_CONTINUE?1-finger tapnoTOUCH_TOUCHfinger count == 3?nohold-and-tap enabled?3-finger tapnohold-and-tap enabled?nohold-and-tap enabled?nonon-palmfinger count== 1?nononon-palmfinger count== 2?nonon-palmfinger count== 3?finger downTOUCH_TOUCHnohold-and-tap enabled?3-finger tapfinger downTOUCH_TOUCHhold-and-tap enabled?finger downTOUCH_TOUCHnohold-and-tap enabled?3-finger tapfinger downTOUCH_TOUCHyeshold-and-tap enabled?finger downTOUCH_TOUCHyeshold-and-tap enabled?finger downTOUCH_TOUCHyeshold-and-tap enabled?1-finger tap2-finger tap3-finger tapall fingersexcept the new oneTOUCH_DEADfinger downTOUCH_TOUCHfinger downTOUCH_TOUCHall fingersTOUCH_DEADno
Viewer does not support full SVG 1.1
\ No newline at end of file +yesnoyesnoyesnonononononononononoyesnononoyesnoyesnoyesyesyesnononononononoyesyesyesnonoyesnonoyesyesyesyesyes(this section exists for [n] = 1, [n] = 2, and [n] = 3)(this section exists for [m] = 1, [m] = 2, and [m] = 3),for a total of 9 times due to combination with [n]yesyesyesyesyesyesyesyesyes
IDLE
IDLE
firstfinger downTOUCH_TOUCHTOUCHsecondfinger downTOUCH_TOUCHTOUCH_2thirdfinger downTOUCH_TOUCHTOUCH_3TOUCH_2_RELEASEyeseitherfinger upyesremainingfinger upanyfinger upTOUCH_3_RELEASEeitherfinger upTOUCH_3_RELEASE_2yesremainingfinger upTOUCH_IDLEyesTOUCH_IDLETOUCH_IDLEyesTOUCH_IDLETOUCH_IDLEpalmTOUCH_DEADeitherfinger palmTOUCH_DEADyesanyfinger palmTOUCH_DEADyeseitherfinger palmTOUCH_DEADyesremainingfinger palmTOUCH_DEADyesremainingfinger palmTOUCH_DEAD2-finger tap3-finger tapyesfinger upTOUCH_IDLE1-finger tapfourthfinger down
IDLE
IDLE
TAPPEDyes2-finger tappalmfinger upbutton [n]pressbutton [n]releaseDRAGGING_OR_DOUBLETAPyesfinger downtap-and-dragtimeouttimeoutmove >thresholdDRAGGINGpalmfinger upnoyesdrag-lockenabled?DRAGLOCK_WAITDRAGLOCK_CONTINUEfinger uppalmtimeoutmove >thresholddrag-locktimeout1-finger tapyesnonon-palmfinger count== 0?finger down1-finger taptimeouttimeouthold-and-tap enabled?HOLD3-finger tapnohold-and-tap enabled?timeouthold-and-tap enabled?3-finger tapTOUCH_2_HOLDTOUCH_3_HOLDtimeouthold-and-tap enabled?timeoutyesnohold-and-tap enabled?timeouthold-and-tap enabled?palmfinger upTOUCH_DEADTOUCH_IDLEeitherfinger palmeitherfinger upTOUCH_DEADTOUCH_IDLEanyfinger palmanyfinger upTOUCH_DEADTOUCH_IDLETOUCH_TOUCHTOUCH_4_PLUSyesanyfinger palmyesanyfinger upTOUCH_IDLEyesTOUCH_DEADTOUCH_4_PLUS_HOLDtimeouthold-and-tap enabled?anyfinger upTOUCH_IDLEanyfinger palmTOUCH_DEADfourthfinger downTOUCH_TOUCHTOUCH_4_PLUS_RELEASEyesanyfinger palmyesanyfinger upyesTOUCH_DEADTOUCH_IDLEtimeouthold-and-tap enabled?TOUCH_4_PLUS_RELEASE_2timeouthold-and-tap enabled?yesanyfinger palmyesanyfinger upTOUCH_DEADTOUCH_IDLETOUCH_4_PLUS_RELEASE_3timeouthold-and-tap enabled?yesanyfinger palmyesanyfinger upyesTOUCH_DEADTOUCH_IDLE1-finger tap2-finger tap3-finger tapDEADBUTTONclickpadbuttonreleaseall fingersTOUCH_DEADnoyesnon-palmfinger count== 0?clickpadbuttonpressanyfinger upTOUCH_IDLEanyfinger palmmove >thresholdmove >thresholdmove >thresholdmove >thresholdmove >thresholdmove >thresholdmove >thresholdmove >thresholdmove >thresholdhold-and-tap enabled?move >thresholdmove >thresholdhold-and-tap enabled?yesnohold-and-tap enabled?move >thresholdhold-and-tap enabled?3-finger tapmove >thresholdyesnohold-and-tap enabled?move >thresholdyesnohold-and-tap enabled?clickpadbuttonpressclickpadbuttonpressclickpadbuttonpressyesnohold-and-tap enabled?1-finger tapclickpadbuttonpressyesnohold-and-tap enabled?2-finger tapclickpadbuttonpressclickpadbuttonpress3-finger tapyesnohold-and-tap enabled?clickpadbuttonpressclickpadbuttonpressclickpadbuttonpressclickpadbuttonpressclickpadbuttonpressclickpadbuttonpressclickpadbuttonpressclickpadbuttonpress1-finger tap3-finger tapbutton [n]releaseBUTTONclickpadbuttonreleaseclickpadbuttonpressbutton [n]releaseclickpadbuttonpressclickpadbuttonpressclickpadbuttonpressclickpadbuttonpressclickpadbuttonpressbutton [n]press
[n] = 1
[n] = 1
[n] = 1
[n] = 1
[n] = 2
[n] = 2
[n] = 3
[n] = 3
notap-and-dragenabled?move >thresholdnonon-palmfinger count== 1?nonon-palmfinger count== 0?secondfinger downsecondfinger downDRAGGING_OR_TAPPED1-finger tap2-finger tap
[m] = 1
[m] = 1
yes
[m] = 2
[m] = 2
3-finger tap
[m] = 3
[m] = 3
noyesnon-palmfinger count== 0?finger uppalm
[n] = [m]
[n] = [m]
noyes[n] == [m]?no[n] == [m]?button [m]pressbutton [n]releaseyesclickpadbuttonpressno[n] == [m]?button [m]releasetap-and-dragtimeoutmove >thresholdadditionalfinger downnoyes[n] == [m]?button [m]releaseset tap stateto DEADfinger downTOUCH_TOUCHyeshold-and-tap enabled?TOUCH_DEADnoyesnothat fingerTOUCH_TOUCH?nothat fingerTOUCH_TOUCH?that fingerTOUCH_TOUCH?nothat fingerTOUCH_TOUCH?that fingerTOUCH_TOUCH?nothat fingerTOUCH_TOUCH?that fingerTOUCH_TOUCH?nothat fingerTOUCH_TOUCH?TOUCH_IDLETOUCH_IDLETOUCH_IDLETOUCH_IDLETOUCH_TOUCHfinger count == 0?yesthat fingerTOUCH_TOUCH?nothat fingerTOUCH_TOUCH?TOUCH_IDLEthat fingerTOUCH_TOUCH?nothat fingerTOUCH_TOUCH?nothat fingerTOUCH_TOUCH?that fingerTOUCH_TOUCH?TOUCH_IDLETOUCH_IDLEthat fingerTOUCH_TOUCH?that fingerTOUCH_TOUCH?nothat fingerTOUCH_TOUCH?nothat fingerTOUCH_TOUCH?TOUCH_IDLETOUCH_IDLEnothat fingerTOUCH_TOUCH?nothat fingerTOUCH_TOUCH?TOUCH_IDLETOUCH_TOUCHfinger count == 1?TOUCH_TOUCHfinger count == 2?noTOUCH_TOUCHfinger count == 3?thumbyesnodrag state== IDLE?yesnon-palmfinger count== 1?TOUCH_DEADthumbTOUCH_DEADnoyesnodrag state== IDLE?drag state== IDLE?drag state== IDLE?drag state== IDLE?yesnodrag state== DRAGLOCK_CONTINUE?1-finger tapnoTOUCH_TOUCHfinger count == 3?nohold-and-tap enabled?3-finger tapnohold-and-tap enabled?nohold-and-tap enabled?nonon-palmfinger count== 1?nononon-palmfinger count== 2?nonon-palmfinger count== 3?finger downTOUCH_TOUCHnohold-and-tap enabled?3-finger tapfinger downTOUCH_TOUCHhold-and-tap enabled?finger downTOUCH_TOUCHnohold-and-tap enabled?3-finger tapfinger downTOUCH_TOUCHyeshold-and-tap enabled?finger downTOUCH_TOUCHyeshold-and-tap enabled?finger downTOUCH_TOUCHyeshold-and-tap enabled?1-finger tap2-finger tap3-finger tapall fingersexcept the new oneTOUCH_DEADfinger downTOUCH_TOUCHfinger downTOUCH_TOUCH
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c index 23817da8..2ac889ec 100644 --- a/src/evdev-mt-touchpad-buttons.c +++ b/src/evdev-mt-touchpad-buttons.c @@ -1170,11 +1170,13 @@ tp_clickfinger_set_button(struct tp_dispatch *tp) struct tp_touch *t; struct tp_touch *first = NULL, *second = NULL; + bool only_taps = tp->tap.hold_tap_enabled; int32_t button_map[2][3] = { { BTN_LEFT, BTN_RIGHT, BTN_MIDDLE }, { BTN_LEFT, BTN_MIDDLE, BTN_RIGHT }, }; +again: tp_for_each_touch(tp, t) { if (t->state != TOUCH_BEGIN && t->state != TOUCH_UPDATE) continue; @@ -1185,6 +1187,9 @@ tp_clickfinger_set_button(struct tp_dispatch *tp) if (t->palm.state != PALM_NONE) continue; + if (only_taps && t->tap.state != TAP_TOUCH_STATE_TOUCH) + continue; + nfingers++; if (!first) @@ -1193,6 +1198,11 @@ tp_clickfinger_set_button(struct tp_dispatch *tp) second = t; } + if (only_taps && nfingers == 0) { + only_taps = false; + goto again; + } + /* Only check for finger distance when there are 2 fingers on the * touchpad */ if (nfingers != 2) diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c index 2977062d..69eecb14 100644 --- a/src/evdev-mt-touchpad-tap.c +++ b/src/evdev-mt-touchpad-tap.c @@ -2027,7 +2027,6 @@ tp_tap_handle_event(struct tp_dispatch *tp, tp_tap_clear_timer(tp); if ((tp->tap.state == TAP_STATE_IDLE || - tp->tap.state == TAP_STATE_BUTTON || tp->tap.state == TAP_STATE_DEAD)) tp_tap_kill_all_touches(tp, NULL); }