summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2017-03-07 17:08:07 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2017-03-23 10:18:09 +1000
commitae11eaa2650d5b70b7d03c542c7efe8d10fbb95d (patch)
tree3cc1515874e2c952f34eec9189edd32b342ab0e0
parenta19d18f9c68ebe962731964f177427a1c16b7ca8 (diff)
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>
-rw-r--r--src/evdev-tablet.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
index 413fb42..daef7ac 100644
--- a/src/evdev-tablet.c
+++ b/src/evdev-tablet.c
@@ -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);