diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c index a6acca41..584b49ee 100644 --- a/src/evdev-tablet.c +++ b/src/evdev-tablet.c @@ -102,7 +102,7 @@ tablet_update_tool(struct tablet_dispatch *tablet, tablet_unset_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY); } else - tablet_set_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY); + tablet_set_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY); } static inline double @@ -164,7 +164,8 @@ tablet_check_notify_axes(struct tablet_dispatch *tablet, } if (axis_update_needed && - !tablet_has_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY)) + !tablet_has_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY) && + !tablet_has_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY)) tablet_notify_axis(base, time, tablet->changed_axes, @@ -378,7 +379,7 @@ tablet_flush(struct tablet_dispatch *tablet, struct evdev_device *device, uint32_t time) { - if (tablet_has_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY)) { + if (tablet_has_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY)) { /* Release all stylus buttons */ tablet->button_state.stylus_buttons = 0; tablet_set_status(tablet, TABLET_BUTTONS_RELEASED); @@ -405,8 +406,11 @@ tablet_flush(struct tablet_dispatch *tablet, tablet_unset_status(tablet, TABLET_BUTTONS_PRESSED); } - if (tablet_has_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY)) + if (tablet_has_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY)) { tablet_notify_proximity_out(&device->base, time); + tablet_set_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY); + tablet_unset_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY); + } /* Update state */ memcpy(&tablet->prev_button_state, diff --git a/src/evdev-tablet.h b/src/evdev-tablet.h index 504b0931..89cf2240 100644 --- a/src/evdev-tablet.h +++ b/src/evdev-tablet.h @@ -34,7 +34,8 @@ enum tablet_status { TABLET_BUTTONS_PRESSED = 1 << 2, TABLET_BUTTONS_RELEASED = 1 << 3, TABLET_STYLUS_IN_CONTACT = 1 << 4, - TABLET_TOOL_OUT_OF_PROXIMITY = 1 << 5 + TABLET_TOOL_LEAVING_PROXIMITY = 1 << 5, + TABLET_TOOL_OUT_OF_PROXIMITY = 1 << 6 }; struct button_state { diff --git a/test/tablet.c b/test/tablet.c index 1786375f..0846e748 100644 --- a/test/tablet.c +++ b/test/tablet.c @@ -243,15 +243,12 @@ START_TEST(bad_distance_events) { struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; - struct libinput_event_tablet *tablet_event; - struct libinput_event *event; - bool bad_distance_event_received = false, - axis_has_changed; - enum libinput_event_type type; const struct input_absinfo *absinfo; + struct axis_replacement axes[] = { + { -1, -1 }, + }; - litest_drain_events(dev->libinput); - + litest_tablet_proximity_in(dev, 10, 10, axes); litest_tablet_proximity_out(dev); litest_drain_events(dev->libinput); @@ -263,21 +260,7 @@ START_TEST(bad_distance_events) litest_event(dev, EV_ABS, ABS_DISTANCE, absinfo->minimum); litest_event(dev, EV_SYN, SYN_REPORT, 0); - /* We shouldn't be able to see any of the bad distance events that got - * sent - */ - while ((event = libinput_get_event(li))) { - tablet_event = libinput_event_get_tablet_event(event); - type = libinput_event_get_type(event); - axis_has_changed = libinput_event_tablet_axis_has_changed( - tablet_event, LIBINPUT_TABLET_AXIS_DISTANCE); - - if (type == LIBINPUT_EVENT_TABLET_AXIS && axis_has_changed) - bad_distance_event_received = true; - - libinput_event_destroy(event); - } - ck_assert(!bad_distance_event_received); + litest_assert_empty_queue(li); } END_TEST