mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-01-06 03:40:13 +01:00
tablet: Stop redundant proximity-out events from being reported
Because bad distance events still trigger calls to tablet_flush(), tablet_flush() will see that the tablet is out of proximity and assume it's an appropriate time to send a proximity-out event, even when we've already sent one. This results in multiple proximity-out events being sent in a row instead of just one. In addition, the bad distance events test has been modified to pick up on this. We shouldn't be receiving /any/ events when we get false distance events from evdev anyway. Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
9a2f2ab46b
commit
62a0995d19
3 changed files with 15 additions and 27 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue