From 0b221c6c97e80cdb619ba17b654eb057c516a130 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 27 Mar 2020 21:15:50 +1000 Subject: [PATCH] tablet: handle a valid prox-out sequence after a forced proximity out With the previous patches a tablet would ignore a valid proximity out sequence where it happends after a forced prox-out. Fix this by checking the state when we're in forced proximity out - if we have a zero tool state but a tool updated then we did get a proximity out. And fix the existing test to check for that case. Signed-off-by: Peter Hutterer --- src/evdev-tablet.c | 10 ++++++++++ test/test-tablet.c | 13 ++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c index a05aab00..7cedf5f9 100644 --- a/src/evdev-tablet.c +++ b/src/evdev-tablet.c @@ -1766,6 +1766,16 @@ tablet_update_tool_state(struct tablet_dispatch *tablet, int state; uint32_t doubled_up_new_tool_bit = 0; + /* we were already out of proximity but now got a tool update but + * our tool state is zero - i.e. we got a valid prox out from the + * device. + */ + if (tablet->quirks.proximity_out_forced && + tablet_has_status(tablet, TABLET_TOOL_UPDATED) && + !tablet->tool_state) { + tablet->quirks.need_to_force_prox_out = false; + tablet->quirks.proximity_out_forced = false; + } /* We need to emulate a BTN_TOOL_PEN if we get an axis event (i.e. * stylus is def. in proximity) and: * - we forced a proximity out before, or diff --git a/test/test-tablet.c b/test/test-tablet.c index f516b409..48f21cfe 100644 --- a/test/test-tablet.c +++ b/test/test-tablet.c @@ -5813,17 +5813,10 @@ START_TEST(huion_static_btn_tool_pen_disable_quirk_on_prox_out) LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT); } - litest_push_event_frame(dev); - litest_tablet_proximity_out(dev); - litest_event(dev, EV_KEY, BTN_TOOL_PEN, 0); - litest_event(dev, EV_SYN, SYN_REPORT, 0); - litest_pop_event_frame(dev); - litest_tablet_proximity_in(dev, 50, 50, NULL); libinput_dispatch(li); litest_assert_tablet_proximity_event(li, LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN); - libinput_dispatch(li); for (i = 0; i < 10; i++) { litest_tablet_motion(dev, 50 + i, 50 + i, NULL); @@ -5833,6 +5826,12 @@ START_TEST(huion_static_btn_tool_pen_disable_quirk_on_prox_out) litest_assert_only_typed_events(li, LIBINPUT_EVENT_TABLET_TOOL_AXIS); + libinput_dispatch(li); + litest_timeout_tablet_proxout(); + libinput_dispatch(li); + + litest_assert_empty_queue(li); + litest_push_event_frame(dev); litest_tablet_proximity_out(dev); litest_event(dev, EV_KEY, BTN_TOOL_PEN, 0);