[PATCH libinput 12/13] tablet: reset delta and changed axes as soon as we send them

Peter Hutterer peter.hutterer at who-t.net
Thu Mar 9 11:06:56 UTC 2017


We don't have frame events for tablets so we must take care to send the
axis change notifications once only and leave the others as-is. Most of the
axes ar 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 at who-t.net>
---
 src/evdev-tablet.c | 37 ++++++++++++++++++++++++++++++++-----
 1 file 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);
 
-- 
2.9.3



More information about the wayland-devel mailing list