tablet: reset delta and changed axes as soon as we send them

We don't have frame events for tablets so we must take care to send the
axis change notifications only once and leave the others as-is. Most of the
axes are absolute so it doesn't really matter, but we need to reset the delta
to make sure clients don't receive the same delta twice.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Ping Cheng <pingc@wacom.com>
This commit is contained in:
Peter Hutterer 2017-03-07 17:08:07 +10:00
parent a19d18f9c6
commit ae11eaa265

View file

@ -120,6 +120,12 @@ tablet_history_get(const struct tablet_dispatch *tablet, unsigned int index)
return &tablet->history.samples[index];
}
static inline void
tablet_reset_changed_axes(struct tablet_dispatch *tablet)
{
memset(tablet->changed_axes, 0, sizeof(tablet->changed_axes));
}
static bool
tablet_device_has_axis(struct tablet_dispatch *tablet,
enum libinput_tablet_tool_axis axis)
@ -1328,7 +1334,7 @@ static inline bool
tablet_send_proximity_in(struct tablet_dispatch *tablet,
struct libinput_tablet_tool *tool,
struct evdev_device *device,
const struct tablet_axes *axes,
struct tablet_axes *axes,
uint64_t time)
{
if (!tablet_has_status(tablet, TABLET_TOOL_ENTERING_PROXIMITY))
@ -1343,6 +1349,10 @@ tablet_send_proximity_in(struct tablet_dispatch *tablet,
tablet_unset_status(tablet, TABLET_TOOL_ENTERING_PROXIMITY);
tablet_unset_status(tablet, TABLET_AXES_UPDATED);
tablet_reset_changed_axes(tablet);
axes->delta.x = 0;
axes->delta.y = 0;
return true;
}
@ -1350,7 +1360,7 @@ static inline bool
tablet_send_proximity_out(struct tablet_dispatch *tablet,
struct libinput_tablet_tool *tool,
struct evdev_device *device,
const struct tablet_axes *axes,
struct tablet_axes *axes,
uint64_t time)
{
if (!tablet_has_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY))
@ -1366,6 +1376,10 @@ tablet_send_proximity_out(struct tablet_dispatch *tablet,
tablet_set_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY);
tablet_unset_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY);
tablet_reset_changed_axes(tablet);
axes->delta.x = 0;
axes->delta.y = 0;
return true;
}
@ -1373,7 +1387,7 @@ static inline bool
tablet_send_tip(struct tablet_dispatch *tablet,
struct libinput_tablet_tool *tool,
struct evdev_device *device,
const struct tablet_axes *axes,
struct tablet_axes *axes,
uint64_t time)
{
if (tablet_has_status(tablet, TABLET_TOOL_ENTERING_CONTACT)) {
@ -1386,6 +1400,11 @@ tablet_send_tip(struct tablet_dispatch *tablet,
tablet_unset_status(tablet, TABLET_AXES_UPDATED);
tablet_unset_status(tablet, TABLET_TOOL_ENTERING_CONTACT);
tablet_set_status(tablet, TABLET_TOOL_IN_CONTACT);
tablet_reset_changed_axes(tablet);
axes->delta.x = 0;
axes->delta.y = 0;
return true;
}
@ -1399,6 +1418,11 @@ tablet_send_tip(struct tablet_dispatch *tablet,
tablet_unset_status(tablet, TABLET_AXES_UPDATED);
tablet_unset_status(tablet, TABLET_TOOL_LEAVING_CONTACT);
tablet_unset_status(tablet, TABLET_TOOL_IN_CONTACT);
tablet_reset_changed_axes(tablet);
axes->delta.x = 0;
axes->delta.y = 0;
return true;
}
@ -1409,7 +1433,7 @@ static inline void
tablet_send_axes(struct tablet_dispatch *tablet,
struct libinput_tablet_tool *tool,
struct evdev_device *device,
const struct tablet_axes *axes,
struct tablet_axes *axes,
uint64_t time)
{
enum libinput_tablet_tool_tip_state tip_state;
@ -1430,6 +1454,9 @@ tablet_send_axes(struct tablet_dispatch *tablet,
tablet->changed_axes,
axes);
tablet_unset_status(tablet, TABLET_AXES_UPDATED);
tablet_reset_changed_axes(tablet);
axes->delta.x = 0;
axes->delta.y = 0;
}
static inline void
@ -1486,8 +1513,8 @@ tablet_send_events(struct tablet_dispatch *tablet,
if (!tablet_send_tip(tablet, tool, device, &axes, time))
tablet_send_axes(tablet, tool, device, &axes, time);
memset(tablet->changed_axes, 0, sizeof(tablet->changed_axes));
tablet_unset_status(tablet, TABLET_TOOL_ENTERING_CONTACT);
tablet_reset_changed_axes(tablet);
tablet_send_buttons(tablet, tool, device, time);