tablet: handle a valid prox-out sequence after a forced proximity out
authorPeter Hutterer <peter.hutterer@who-t.net>
Fri, 27 Mar 2020 11:15:50 +0000 (21:15 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Fri, 22 May 2020 03:10:06 +0000 (03:10 +0000)
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 <peter.hutterer@who-t.net>
src/evdev-tablet.c
test/test-tablet.c

index a05aab00251d168739c1c943a9b44d73ba96dd47..7cedf5f91b945d4924a6fd909dc7dbe9e1a9d213 100644 (file)
@@ -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
index f516b409406ca505c7dad0325426085a45db81f0..48f21cfeee4742eeb93a3ffdc0b18716c06d5677 100644 (file)
@@ -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);