[PATCH libinput 1/3] tablet: Stop redundant proximity-out events from being reported

Stephen Chandler Paul thatslyude at gmail.com
Tue Jun 24 23:30:15 PDT 2014


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.

Signed-off-by: Stephen Chandler Paul <thatslyude at gmail.com>
---
 src/evdev-tablet.c | 12 ++++++++----
 src/evdev-tablet.h |  3 ++-
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
index a6acca4..584b49e 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 504b093..89cf224 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 {
-- 
1.8.5.5



More information about the wayland-devel mailing list