[PATCH libinput 9/9] tablet: simplify marking axes as changed

Peter Hutterer peter.hutterer at who-t.net
Sun Dec 20 21:57:05 PST 2015


The only time we need this is on proximity in, so move it to where we handle
that to have better locality. And rather than looping through and checking
each bit, just memcpy the axis capabilities, because by definition they
represent the set of axes that can possibly change.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev-tablet.c | 35 ++++++++++++++++++++---------------
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
index af705b7..24a54df 100644
--- a/src/evdev-tablet.c
+++ b/src/evdev-tablet.c
@@ -156,20 +156,6 @@ tablet_process_absolute(struct tablet_dispatch *tablet,
 }
 
 static void
-tablet_mark_all_axes_changed(struct tablet_dispatch *tablet,
-			     struct evdev_device *device)
-{
-	enum libinput_tablet_tool_axis a;
-
-	for (a = LIBINPUT_TABLET_TOOL_AXIS_X; a <= LIBINPUT_TABLET_TOOL_AXIS_MAX; a++) {
-		if (tablet_device_has_axis(tablet, a))
-			set_bit(tablet->changed_axes, a);
-	}
-
-	tablet_set_status(tablet, TABLET_AXES_UPDATED);
-}
-
-static void
 tablet_change_to_left_handed(struct evdev_device *device)
 {
 	struct tablet_dispatch *tablet =
@@ -194,7 +180,6 @@ tablet_update_tool(struct tablet_dispatch *tablet,
 
 	if (enabled) {
 		tablet->current_tool_type = tool;
-		tablet_mark_all_axes_changed(tablet, device);
 		tablet_set_status(tablet, TABLET_TOOL_ENTERING_PROXIMITY);
 		tablet_unset_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY);
 	}
@@ -782,6 +767,9 @@ tool_set_bits(const struct tablet_dispatch *tablet,
 {
 	enum libinput_tablet_tool_type type = tool->type;
 
+	copy_axis_cap(tablet, tool, LIBINPUT_TABLET_TOOL_AXIS_X);
+	copy_axis_cap(tablet, tool, LIBINPUT_TABLET_TOOL_AXIS_Y);
+
 #if HAVE_LIBWACOM
 	if (tool_set_bits_from_libwacom(tablet, tool) == 0)
 		return;
@@ -1059,6 +1047,20 @@ detect_pressure_offset(struct tablet_dispatch *tablet,
 }
 
 static void
+tablet_mark_all_axes_changed(struct tablet_dispatch *tablet,
+			     struct evdev_device *device,
+			     struct libinput_tablet_tool *tool)
+{
+	static_assert(sizeof(tablet->changed_axes) ==
+			      sizeof(tool->axis_caps),
+		      "Mismatching array sizes");
+
+	memcpy(tablet->changed_axes,
+	       tool->axis_caps,
+	       sizeof(tablet->changed_axes));
+}
+
+static void
 tablet_flush(struct tablet_dispatch *tablet,
 	     struct evdev_device *device,
 	     uint64_t time)
@@ -1082,6 +1084,9 @@ tablet_flush(struct tablet_dispatch *tablet,
 			tablet_set_status(tablet, TABLET_TOOL_LEAVING_CONTACT);
 	} else if (tablet_has_status(tablet, TABLET_AXES_UPDATED) ||
 		   tablet_has_status(tablet, TABLET_TOOL_ENTERING_PROXIMITY)) {
+		if (tablet_has_status(tablet,
+				      TABLET_TOOL_ENTERING_PROXIMITY))
+			tablet_mark_all_axes_changed(tablet, device, tool);
 		detect_pressure_offset(tablet, device, tool);
 		sanitize_tablet_axes(tablet);
 		tablet_check_notify_axes(tablet, device, time, tool);
-- 
2.5.0



More information about the wayland-devel mailing list