[PATCH libinput 1/5] tablet: rename axis_has_changed into an axis-specific API set

Peter Hutterer peter.hutterer at who-t.net
Sun Dec 13 18:00:10 PST 2015


First part of the big revamp to get rid of libinput_tablet_tool_axis and
replace it with a set of axis-specific APIs.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/libinput.c      | 128 +++++++++++++++++++++++++++++++++++++++++++--
 src/libinput.h      | 146 +++++++++++++++++++++++++++++++++++++++++++++++++---
 src/libinput.sym    |  10 +++-
 test/tablet.c       | 112 ++++++++++++++++------------------------
 tools/event-debug.c |  43 +++++-----------
 5 files changed, 328 insertions(+), 111 deletions(-)

diff --git a/src/libinput.c b/src/libinput.c
index df44e7e..f37d174 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -913,8 +913,8 @@ libinput_event_gesture_get_angle_delta(struct libinput_event_gesture *event)
 }
 
 LIBINPUT_EXPORT int
-libinput_event_tablet_tool_axis_has_changed(struct libinput_event_tablet_tool *event,
-				       enum libinput_tablet_tool_axis axis)
+libinput_event_tablet_tool_x_has_changed(
+				struct libinput_event_tablet_tool *event)
 {
 	require_event_type(libinput_event_get_context(&event->base),
 			   event->base.type,
@@ -923,8 +923,128 @@ libinput_event_tablet_tool_axis_has_changed(struct libinput_event_tablet_tool *e
 			   LIBINPUT_EVENT_TABLET_TOOL_TIP,
 			   LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
 
-	return (NCHARS(axis) <= sizeof(event->changed_axes)) ?
-		bit_is_set(event->changed_axes, axis) : 0;
+	return bit_is_set(event->changed_axes,
+			  LIBINPUT_TABLET_TOOL_AXIS_X);
+}
+
+LIBINPUT_EXPORT int
+libinput_event_tablet_tool_y_has_changed(
+				struct libinput_event_tablet_tool *event)
+{
+	require_event_type(libinput_event_get_context(&event->base),
+			   event->base.type,
+			   0,
+			   LIBINPUT_EVENT_TABLET_TOOL_AXIS,
+			   LIBINPUT_EVENT_TABLET_TOOL_TIP,
+			   LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
+
+	return bit_is_set(event->changed_axes,
+			  LIBINPUT_TABLET_TOOL_AXIS_Y);
+}
+
+LIBINPUT_EXPORT int
+libinput_event_tablet_tool_pressure_has_changed(
+				struct libinput_event_tablet_tool *event)
+{
+	require_event_type(libinput_event_get_context(&event->base),
+			   event->base.type,
+			   0,
+			   LIBINPUT_EVENT_TABLET_TOOL_AXIS,
+			   LIBINPUT_EVENT_TABLET_TOOL_TIP,
+			   LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
+
+	return bit_is_set(event->changed_axes,
+			  LIBINPUT_TABLET_TOOL_AXIS_PRESSURE);
+}
+
+LIBINPUT_EXPORT int
+libinput_event_tablet_tool_distance_has_changed(
+				struct libinput_event_tablet_tool *event)
+{
+	require_event_type(libinput_event_get_context(&event->base),
+			   event->base.type,
+			   0,
+			   LIBINPUT_EVENT_TABLET_TOOL_AXIS,
+			   LIBINPUT_EVENT_TABLET_TOOL_TIP,
+			   LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
+
+	return bit_is_set(event->changed_axes,
+			  LIBINPUT_TABLET_TOOL_AXIS_DISTANCE);
+}
+
+LIBINPUT_EXPORT int
+libinput_event_tablet_tool_tilt_x_has_changed(
+				struct libinput_event_tablet_tool *event)
+{
+	require_event_type(libinput_event_get_context(&event->base),
+			   event->base.type,
+			   0,
+			   LIBINPUT_EVENT_TABLET_TOOL_AXIS,
+			   LIBINPUT_EVENT_TABLET_TOOL_TIP,
+			   LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
+
+	return bit_is_set(event->changed_axes,
+			  LIBINPUT_TABLET_TOOL_AXIS_TILT_X);
+}
+
+LIBINPUT_EXPORT int
+libinput_event_tablet_tool_tilt_y_has_changed(
+				struct libinput_event_tablet_tool *event)
+{
+	require_event_type(libinput_event_get_context(&event->base),
+			   event->base.type,
+			   0,
+			   LIBINPUT_EVENT_TABLET_TOOL_AXIS,
+			   LIBINPUT_EVENT_TABLET_TOOL_TIP,
+			   LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
+
+	return bit_is_set(event->changed_axes,
+			  LIBINPUT_TABLET_TOOL_AXIS_TILT_Y);
+}
+
+LIBINPUT_EXPORT int
+libinput_event_tablet_tool_rotation_has_changed(
+				struct libinput_event_tablet_tool *event)
+{
+	require_event_type(libinput_event_get_context(&event->base),
+			   event->base.type,
+			   0,
+			   LIBINPUT_EVENT_TABLET_TOOL_AXIS,
+			   LIBINPUT_EVENT_TABLET_TOOL_TIP,
+			   LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
+
+	return bit_is_set(event->changed_axes,
+			  LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
+}
+
+LIBINPUT_EXPORT int
+libinput_event_tablet_tool_slider_has_changed(
+				struct libinput_event_tablet_tool *event)
+{
+	require_event_type(libinput_event_get_context(&event->base),
+			   event->base.type,
+			   0,
+			   LIBINPUT_EVENT_TABLET_TOOL_AXIS,
+			   LIBINPUT_EVENT_TABLET_TOOL_TIP,
+			   LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
+
+	return bit_is_set(event->changed_axes,
+			  LIBINPUT_TABLET_TOOL_AXIS_SLIDER);
+}
+
+LIBINPUT_EXPORT int
+libinput_event_tablet_tool_wheel_has_changed(
+				struct libinput_event_tablet_tool *event)
+{
+	require_event_type(libinput_event_get_context(&event->base),
+			   event->base.type,
+			   0,
+			   LIBINPUT_EVENT_TABLET_TOOL_AXIS,
+			   LIBINPUT_EVENT_TABLET_TOOL_TIP,
+			   LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
+
+	return bit_is_set(event->changed_axes,
+			  LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL);
 }
 
 LIBINPUT_EXPORT double
diff --git a/src/libinput.h b/src/libinput.h
index 48f72a1..8bd1480 100644
--- a/src/libinput.h
+++ b/src/libinput.h
@@ -1360,7 +1360,7 @@ libinput_event_tablet_tool_get_base_event(struct libinput_event_tablet_tool *eve
 /**
  * @ingroup event_tablet
  *
- * Checks if an axis was updated in this event or return 0 otherwise.
+ * Check if the x axis was updated in this event.
  * For tablet events that are not of type @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS or
  * type @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY, this function returns 0.
  *
@@ -1368,12 +1368,144 @@ libinput_event_tablet_tool_get_base_event(struct libinput_event_tablet_tool *eve
  * @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS and @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY.
  *
  * @param event The libinput tablet event
- * @param axis The axis to check for updates
  * @return 1 if the axis was updated or 0 otherwise
  */
 int
-libinput_event_tablet_tool_axis_has_changed(struct libinput_event_tablet_tool *event,
-					    enum libinput_tablet_tool_axis axis);
+libinput_event_tablet_tool_x_has_changed(
+				struct libinput_event_tablet_tool *event);
+
+/**
+ * @ingroup event_tablet
+ *
+ * Check if the y axis was updated in this event.
+ * For tablet events that are not of type @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS or
+ * type @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY, this function returns 0.
+ *
+ * @note It is an application bug to call this function for events other than
+ * @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS and @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY.
+ *
+ * @param event The libinput tablet event
+ * @return 1 if the axis was updated or 0 otherwise
+ */
+int
+libinput_event_tablet_tool_y_has_changed(
+				struct libinput_event_tablet_tool *event);
+
+/**
+ * @ingroup event_tablet
+ *
+ * Check if the pressure axis was updated in this event.
+ * For tablet events that are not of type @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS or
+ * type @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY, this function returns 0.
+ *
+ * @note It is an application bug to call this function for events other than
+ * @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS and @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY.
+ *
+ * @param event The libinput tablet event
+ * @return 1 if the axis was updated or 0 otherwise
+ */
+int
+libinput_event_tablet_tool_pressure_has_changed(
+				struct libinput_event_tablet_tool *event);
+
+/**
+ * @ingroup event_tablet
+ *
+ * Check if the distance axis was updated in this event.
+ * For tablet events that are not of type @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS or
+ * type @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY, this function returns 0.
+ *
+ * @note It is an application bug to call this function for events other than
+ * @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS and @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY.
+ *
+ * @param event The libinput tablet event
+ * @return 1 if the axis was updated or 0 otherwise
+ */
+int
+libinput_event_tablet_tool_distance_has_changed(
+				struct libinput_event_tablet_tool *event);
+
+/**
+ * @ingroup event_tablet
+ *
+ * Check if the tilt x axis was updated in this event.
+ * For tablet events that are not of type @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS or
+ * type @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY, this function returns 0.
+ *
+ * @note It is an application bug to call this function for events other than
+ * @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS and @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY.
+ *
+ * @param event The libinput tablet event
+ * @return 1 if the axis was updated or 0 otherwise
+ */
+int
+libinput_event_tablet_tool_tilt_x_has_changed(
+				struct libinput_event_tablet_tool *event);
+
+/**
+ * @ingroup event_tablet
+ *
+ * Check if the tilt y axis was updated in this event.
+ * For tablet events that are not of type @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS or
+ * type @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY, this function returns 0.
+ *
+ * @note It is an application bug to call this function for events other than
+ * @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS and @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY.
+ *
+ * @param event The libinput tablet event
+ * @return 1 if the axis was updated or 0 otherwise
+ */
+int
+libinput_event_tablet_tool_tilt_y_has_changed(
+				struct libinput_event_tablet_tool *event);
+/**
+ * @ingroup event_tablet
+ *
+ * Check if the z-rotation axis was updated in this event.
+ * For tablet events that are not of type @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS or
+ * type @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY, this function returns 0.
+ *
+ * @note It is an application bug to call this function for events other than
+ * @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS and @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY.
+ *
+ * @param event The libinput tablet event
+ * @return 1 if the axis was updated or 0 otherwise
+ */
+int
+libinput_event_tablet_tool_rotation_has_changed(
+				struct libinput_event_tablet_tool *event);
+/**
+ * @ingroup event_tablet
+ *
+ * Check if the slider axis was updated in this event.
+ * For tablet events that are not of type @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS or
+ * type @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY, this function returns 0.
+ *
+ * @note It is an application bug to call this function for events other than
+ * @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS and @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY.
+ *
+ * @param event The libinput tablet event
+ * @return 1 if the axis was updated or 0 otherwise
+ */
+int
+libinput_event_tablet_tool_slider_has_changed(
+				struct libinput_event_tablet_tool *event);
+/**
+ * @ingroup event_tablet
+ *
+ * Check if the wheel axis was updated in this event.
+ * For tablet events that are not of type @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS or
+ * type @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY, this function returns 0.
+ *
+ * @note It is an application bug to call this function for events other than
+ * @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS and @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY.
+ *
+ * @param event The libinput tablet event
+ * @return 1 if the axis was updated or 0 otherwise
+ */
+int
+libinput_event_tablet_tool_wheel_has_changed(
+				struct libinput_event_tablet_tool *event);
 
 /**
  * @ingroup event_tablet
@@ -1405,7 +1537,7 @@ libinput_event_tablet_tool_axis_has_changed(struct libinput_event_tablet_tool *e
  *   libinput_event_tablet_tool_get_axis_delta() instead.
  *
  * @note This function may be called for a specific axis even if
- * libinput_event_tablet_tool_axis_has_changed() returns 0 for that axis.
+ * libinput_event_tablet_tool_*_has_changed() returns 0 for that axis.
  * libinput always includes all device axes in the event.
  *
  * If the event is of type @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY and the
@@ -1464,7 +1596,7 @@ libinput_event_tablet_tool_get_axis_delta_discrete(
  * screen coordinates.
  *
  * @note This function may be called for a specific axis even if
- * libinput_event_tablet_tool_axis_has_changed() returns 0 for that axis.
+ * libinput_event_tablet_tool_*_has_changed() returns 0 for that axis.
  * libinput always includes all device axes in the event.
  *
  * @param event The libinput tablet event
@@ -1482,7 +1614,7 @@ libinput_event_tablet_tool_get_x_transformed(struct libinput_event_tablet_tool *
  * screen coordinates.
  *
  * @note This function may be called for a specific axis even if
- * libinput_event_tablet_tool_axis_has_changed() returns 0 for that axis.
+ * libinput_event_tablet_tool_*_has_changed() returns 0 for that axis.
  * libinput always includes all device axes in the event.
  *
  * @param event The libinput tablet event
diff --git a/src/libinput.sym b/src/libinput.sym
index 1704903..bee03b9 100644
--- a/src/libinput.sym
+++ b/src/libinput.sym
@@ -185,7 +185,15 @@ LIBINPUT_1.1 {
  * keep them separate */
 LIBINPUT_TABLET_SUPPORT {
 	libinput_event_get_tablet_tool_event;
-	libinput_event_tablet_tool_axis_has_changed;
+	libinput_event_tablet_tool_x_has_changed;
+	libinput_event_tablet_tool_y_has_changed;
+	libinput_event_tablet_tool_pressure_has_changed;
+	libinput_event_tablet_tool_distance_has_changed;
+	libinput_event_tablet_tool_rotation_has_changed;
+	libinput_event_tablet_tool_tilt_x_has_changed;
+	libinput_event_tablet_tool_tilt_y_has_changed;
+	libinput_event_tablet_tool_wheel_has_changed;
+	libinput_event_tablet_tool_slider_has_changed;
 	libinput_event_tablet_tool_get_axis_delta;
 	libinput_event_tablet_tool_get_axis_delta_discrete;
 	libinput_event_tablet_tool_get_axis_value;
diff --git a/test/tablet.c b/test/tablet.c
index 4cd5cef..724feb3 100644
--- a/test/tablet.c
+++ b/test/tablet.c
@@ -721,10 +721,8 @@ START_TEST(proximity_has_axes)
 	tablet_event = libinput_event_get_tablet_tool_event(event);
 	tool = libinput_event_tablet_tool_get_tool(tablet_event);
 
-	ck_assert(libinput_event_tablet_tool_axis_has_changed(
-			tablet_event, LIBINPUT_TABLET_TOOL_AXIS_X));
-	ck_assert(libinput_event_tablet_tool_axis_has_changed(
-			tablet_event, LIBINPUT_TABLET_TOOL_AXIS_Y));
+	ck_assert(libinput_event_tablet_tool_x_has_changed(tablet_event));
+	ck_assert(libinput_event_tablet_tool_y_has_changed(tablet_event));
 
 	x = libinput_event_tablet_tool_get_axis_value(tablet_event,
 						 LIBINPUT_TABLET_TOOL_AXIS_X);
@@ -735,9 +733,8 @@ START_TEST(proximity_has_axes)
 	litest_assert_double_ne(y, 0);
 
 	if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_DISTANCE)) {
-		ck_assert(libinput_event_tablet_tool_axis_has_changed(
-				tablet_event,
-				LIBINPUT_TABLET_TOOL_AXIS_DISTANCE));
+		ck_assert(libinput_event_tablet_tool_distance_has_changed(
+				tablet_event));
 
 		distance = libinput_event_tablet_tool_get_axis_value(
 			tablet_event,
@@ -747,12 +744,10 @@ START_TEST(proximity_has_axes)
 
 	if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_X) &&
 	    libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_Y)) {
-		ck_assert(libinput_event_tablet_tool_axis_has_changed(
-				tablet_event,
-				LIBINPUT_TABLET_TOOL_AXIS_TILT_X));
-		ck_assert(libinput_event_tablet_tool_axis_has_changed(
-				tablet_event,
-				LIBINPUT_TABLET_TOOL_AXIS_TILT_Y));
+		ck_assert(libinput_event_tablet_tool_tilt_x_has_changed(
+				tablet_event));
+		ck_assert(libinput_event_tablet_tool_tilt_y_has_changed(
+				tablet_event));
 
 		x = libinput_event_tablet_tool_get_axis_value(
 			tablet_event,
@@ -806,10 +801,8 @@ START_TEST(proximity_has_axes)
 	tablet_event = libinput_event_get_tablet_tool_event(event);
 	tool = libinput_event_tablet_tool_get_tool(tablet_event);
 
-	ck_assert(!libinput_event_tablet_tool_axis_has_changed(
-			tablet_event, LIBINPUT_TABLET_TOOL_AXIS_X));
-	ck_assert(!libinput_event_tablet_tool_axis_has_changed(
-			tablet_event, LIBINPUT_TABLET_TOOL_AXIS_Y));
+	ck_assert(!libinput_event_tablet_tool_x_has_changed(tablet_event));
+	ck_assert(!libinput_event_tablet_tool_y_has_changed(tablet_event));
 
 	x = libinput_event_tablet_tool_get_axis_value(tablet_event,
 						 LIBINPUT_TABLET_TOOL_AXIS_X);
@@ -819,9 +812,8 @@ START_TEST(proximity_has_axes)
 	litest_assert_double_eq(y, last_y);
 
 	if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_DISTANCE)) {
-		ck_assert(!libinput_event_tablet_tool_axis_has_changed(
-				tablet_event,
-				LIBINPUT_TABLET_TOOL_AXIS_DISTANCE));
+		ck_assert(!libinput_event_tablet_tool_distance_has_changed(
+				tablet_event));
 
 		distance = libinput_event_tablet_tool_get_axis_value(
 			tablet_event,
@@ -831,12 +823,10 @@ START_TEST(proximity_has_axes)
 
 	if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_X) &&
 	    libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_Y)) {
-		ck_assert(!libinput_event_tablet_tool_axis_has_changed(
-				tablet_event,
-				LIBINPUT_TABLET_TOOL_AXIS_TILT_X));
-		ck_assert(!libinput_event_tablet_tool_axis_has_changed(
-				tablet_event,
-				LIBINPUT_TABLET_TOOL_AXIS_TILT_Y));
+		ck_assert(!libinput_event_tablet_tool_tilt_x_has_changed(
+				tablet_event));
+		ck_assert(!libinput_event_tablet_tool_tilt_y_has_changed(
+				tablet_event));
 
 		x = libinput_event_tablet_tool_get_axis_value(
 			tablet_event,
@@ -885,10 +875,10 @@ START_TEST(motion)
 		ck_assert_int_eq(libinput_event_get_type(event),
 				 LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
 
-		x_changed = libinput_event_tablet_tool_axis_has_changed(
-		    tablet_event, LIBINPUT_TABLET_TOOL_AXIS_X);
-		y_changed = libinput_event_tablet_tool_axis_has_changed(
-		    tablet_event, LIBINPUT_TABLET_TOOL_AXIS_Y);
+		x_changed = libinput_event_tablet_tool_x_has_changed(
+							tablet_event);
+		y_changed = libinput_event_tablet_tool_y_has_changed(
+							tablet_event);
 
 		ck_assert(x_changed);
 		ck_assert(y_changed);
@@ -920,10 +910,10 @@ START_TEST(motion)
 			type = libinput_event_get_type(event);
 
 			if (type == LIBINPUT_EVENT_TABLET_TOOL_AXIS) {
-				x_changed = libinput_event_tablet_tool_axis_has_changed(
-				    tablet_event, LIBINPUT_TABLET_TOOL_AXIS_X);
-				y_changed = libinput_event_tablet_tool_axis_has_changed(
-				    tablet_event, LIBINPUT_TABLET_TOOL_AXIS_Y);
+				x_changed = libinput_event_tablet_tool_x_has_changed(
+							    tablet_event);
+				y_changed = libinput_event_tablet_tool_y_has_changed(
+							    tablet_event);
 
 				ck_assert(x_changed);
 				ck_assert(y_changed);
@@ -1036,20 +1026,17 @@ START_TEST(motion_delta_partial)
 	event = libinput_get_event(li);
 	tablet_event = libinput_event_get_tablet_tool_event(event);
 
-	ck_assert(!libinput_event_tablet_tool_axis_has_changed(tablet_event,
-						LIBINPUT_TABLET_TOOL_AXIS_X));
+	ck_assert(!libinput_event_tablet_tool_x_has_changed(tablet_event));
 	dx = libinput_event_tablet_tool_get_axis_delta(tablet_event,
 						LIBINPUT_TABLET_TOOL_AXIS_X);
 	litest_assert_double_eq(dx, 0.0);
 
-	ck_assert(!libinput_event_tablet_tool_axis_has_changed(tablet_event,
-						LIBINPUT_TABLET_TOOL_AXIS_Y));
+	ck_assert(!libinput_event_tablet_tool_y_has_changed(tablet_event));
 	dy = libinput_event_tablet_tool_get_axis_delta(tablet_event,
 						LIBINPUT_TABLET_TOOL_AXIS_Y);
 	litest_assert_double_eq(dy, 0.0);
 
-	ck_assert(libinput_event_tablet_tool_axis_has_changed(tablet_event,
-						LIBINPUT_TABLET_TOOL_AXIS_DISTANCE));
+	ck_assert(libinput_event_tablet_tool_distance_has_changed(tablet_event));
 	ddist = libinput_event_tablet_tool_get_axis_delta(tablet_event,
 						LIBINPUT_TABLET_TOOL_AXIS_DISTANCE);
 	ck_assert_double_gt(ddist, 0);
@@ -1334,18 +1321,16 @@ START_TEST(normalization)
 		if (libinput_event_get_type(event) == LIBINPUT_EVENT_TABLET_TOOL_AXIS) {
 			tablet_event = libinput_event_get_tablet_tool_event(event);
 
-			if (libinput_event_tablet_tool_axis_has_changed(
-				tablet_event,
-				LIBINPUT_TABLET_TOOL_AXIS_PRESSURE)) {
+			if (libinput_event_tablet_tool_pressure_has_changed(
+							tablet_event)) {
 				pressure = libinput_event_tablet_tool_get_axis_value(
 				    tablet_event, LIBINPUT_TABLET_TOOL_AXIS_PRESSURE);
 
 				litest_assert_double_eq(pressure, 0);
 			}
 
-			if (libinput_event_tablet_tool_axis_has_changed(
-				tablet_event,
-				LIBINPUT_TABLET_TOOL_AXIS_TILT_X)) {
+			if (libinput_event_tablet_tool_tilt_x_has_changed(
+							tablet_event)) {
 				tilt_vertical =
 					libinput_event_tablet_tool_get_axis_value(
 					    tablet_event,
@@ -1354,9 +1339,8 @@ START_TEST(normalization)
 				litest_assert_double_eq(tilt_vertical, -1);
 			}
 
-			if (libinput_event_tablet_tool_axis_has_changed(
-				tablet_event,
-				LIBINPUT_TABLET_TOOL_AXIS_TILT_Y)) {
+			if (libinput_event_tablet_tool_tilt_y_has_changed(
+							tablet_event)) {
 				tilt_horizontal =
 					libinput_event_tablet_tool_get_axis_value(
 					    tablet_event,
@@ -1396,18 +1380,16 @@ START_TEST(normalization)
 		if (libinput_event_get_type(event) == LIBINPUT_EVENT_TABLET_TOOL_AXIS) {
 			tablet_event = libinput_event_get_tablet_tool_event(event);
 
-			if (libinput_event_tablet_tool_axis_has_changed(
-				tablet_event,
-				LIBINPUT_TABLET_TOOL_AXIS_PRESSURE)) {
+			if (libinput_event_tablet_tool_pressure_has_changed(
+							tablet_event)) {
 				pressure = libinput_event_tablet_tool_get_axis_value(
 				    tablet_event, LIBINPUT_TABLET_TOOL_AXIS_PRESSURE);
 
 				litest_assert_double_eq(pressure, 1);
 			}
 
-			if (libinput_event_tablet_tool_axis_has_changed(
-				tablet_event,
-				LIBINPUT_TABLET_TOOL_AXIS_TILT_X)) {
+			if (libinput_event_tablet_tool_tilt_x_has_changed(
+							tablet_event)) {
 				tilt_vertical =
 					libinput_event_tablet_tool_get_axis_value(
 					    tablet_event,
@@ -1416,9 +1398,8 @@ START_TEST(normalization)
 				litest_assert_double_eq(tilt_vertical, 1);
 			}
 
-			if (libinput_event_tablet_tool_axis_has_changed(
-				tablet_event,
-				LIBINPUT_TABLET_TOOL_AXIS_TILT_Y)) {
+			if (libinput_event_tablet_tool_tilt_y_has_changed(
+							tablet_event)) {
 				tilt_horizontal =
 					libinput_event_tablet_tool_get_axis_value(
 					    tablet_event,
@@ -1977,8 +1958,7 @@ START_TEST(mouse_rotation)
 					      -1);
 		event = libinput_get_event(li);
 		tev = libinput_event_get_tablet_tool_event(event);
-		ck_assert(libinput_event_tablet_tool_axis_has_changed(tev,
-					 LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z));
+		ck_assert(libinput_event_tablet_tool_rotation_has_changed(tev));
 		val = libinput_event_tablet_tool_get_axis_value(tev,
 					 LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
 
@@ -2040,8 +2020,7 @@ START_TEST(mouse_wheel)
 
 		event = libinput_get_event(li);
 		tev = libinput_event_get_tablet_tool_event(event);
-		ck_assert(libinput_event_tablet_tool_axis_has_changed(tev,
-						LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL));
+		ck_assert(libinput_event_tablet_tool_wheel_has_changed(tev));
 		val = libinput_event_tablet_tool_get_axis_value(tev,
 						LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL);
 		ck_assert_int_eq(val, 0);
@@ -2071,8 +2050,7 @@ START_TEST(mouse_wheel)
 
 		event = libinput_get_event(li);
 		tev = libinput_event_get_tablet_tool_event(event);
-		ck_assert(!libinput_event_tablet_tool_axis_has_changed(tev,
-						LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL));
+		ck_assert(!libinput_event_tablet_tool_wheel_has_changed(tev));
 		val = libinput_event_tablet_tool_get_axis_value(tev,
 						LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL);
 		ck_assert_int_eq(val, 0);
@@ -2168,8 +2146,7 @@ START_TEST(airbrush_wheel)
 					      -1);
 		event = libinput_get_event(li);
 		tev = libinput_event_get_tablet_tool_event(event);
-		ck_assert(libinput_event_tablet_tool_axis_has_changed(tev,
-					 LIBINPUT_TABLET_TOOL_AXIS_SLIDER));
+		ck_assert(libinput_event_tablet_tool_slider_has_changed(tev));
 		val = libinput_event_tablet_tool_get_axis_value(tev,
 					 LIBINPUT_TABLET_TOOL_AXIS_SLIDER);
 
@@ -2259,8 +2236,7 @@ START_TEST(artpen_rotation)
 					      -1);
 		event = libinput_get_event(li);
 		tev = libinput_event_get_tablet_tool_event(event);
-		ck_assert(libinput_event_tablet_tool_axis_has_changed(tev,
-					 LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z));
+		ck_assert(libinput_event_tablet_tool_rotation_has_changed(tev));
 		val = libinput_event_tablet_tool_get_axis_value(tev,
 					 LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
 
diff --git a/tools/event-debug.c b/tools/event-debug.c
index aaa31b2..54ad1f2 100644
--- a/tools/event-debug.c
+++ b/tools/event-debug.c
@@ -332,16 +332,6 @@ print_pointer_axis_event(struct libinput_event *ev)
 	printf("vert %.2f%s horiz %.2f%s\n", v, have_vert, h, have_horiz);
 }
 
-static const char*
-tablet_axis_changed_sym(struct libinput_event_tablet_tool *t,
-			enum libinput_tablet_tool_axis axis)
-{
-	if (libinput_event_tablet_tool_axis_has_changed(t, axis))
-		return "*";
-	else
-		return "";
-}
-
 static void
 print_tablet_axes(struct libinput_event_tablet_tool *t)
 {
@@ -351,13 +341,16 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
 	double rotation, slider, wheel;
 	double delta;
 
+#define changed_sym(ev, ax) \
+	(libinput_event_tablet_tool_##ax##_has_changed(ev) ? "*" : "")
+
 	x = libinput_event_tablet_tool_get_axis_value(t, LIBINPUT_TABLET_TOOL_AXIS_X);
 	y = libinput_event_tablet_tool_get_axis_value(t, LIBINPUT_TABLET_TOOL_AXIS_Y);
 	dx = libinput_event_tablet_tool_get_axis_delta(t, LIBINPUT_TABLET_TOOL_AXIS_X);
 	dy = libinput_event_tablet_tool_get_axis_delta(t, LIBINPUT_TABLET_TOOL_AXIS_Y);
 	printf("\t%.2f%s/%.2f%s (%.2f/%.2f)",
-	       x, tablet_axis_changed_sym(t, LIBINPUT_TABLET_TOOL_AXIS_X),
-	       y, tablet_axis_changed_sym(t, LIBINPUT_TABLET_TOOL_AXIS_Y),
+	       x, changed_sym(t, x),
+	       y, changed_sym(t, y),
 	       dx, dy);
 
 	if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_X) ||
@@ -371,10 +364,8 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
 		dy = libinput_event_tablet_tool_get_axis_delta(t,
 					 LIBINPUT_TABLET_TOOL_AXIS_TILT_Y);
 		printf("\ttilt: %.2f%s/%.2f%s (%.2f/%.2f)",
-		       x, tablet_axis_changed_sym(t,
-					  LIBINPUT_TABLET_TOOL_AXIS_TILT_X),
-		       y, tablet_axis_changed_sym(t,
-					  LIBINPUT_TABLET_TOOL_AXIS_TILT_Y),
+		       x, changed_sym(t, tilt_x),
+		       y, changed_sym(t, tilt_y),
 		       dx, dy);
 	}
 
@@ -388,17 +379,13 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
 			delta = libinput_event_tablet_tool_get_axis_delta(t,
 					LIBINPUT_TABLET_TOOL_AXIS_DISTANCE);
 			printf("\tdistance: %.2f%s (%.2f)",
-			       dist,
-			       tablet_axis_changed_sym(t,
-					       LIBINPUT_TABLET_TOOL_AXIS_DISTANCE),
+			       dist, changed_sym(t, distance),
 			       delta);
 		} else {
 			delta = libinput_event_tablet_tool_get_axis_delta(t,
 					LIBINPUT_TABLET_TOOL_AXIS_PRESSURE);
 			printf("\tpressure: %.2f%s (%.2f)",
-			       pressure,
-			       tablet_axis_changed_sym(t,
-					       LIBINPUT_TABLET_TOOL_AXIS_PRESSURE),
+			       pressure, changed_sym(t, pressure),
 			       delta);
 		}
 	}
@@ -409,9 +396,7 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
 		delta = libinput_event_tablet_tool_get_axis_delta(t,
 					LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
 		printf("\trotation: %.2f%s (%.2f)",
-		       rotation,
-		       tablet_axis_changed_sym(t,
-				       LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z),
+		       rotation, changed_sym(t, rotation),
 		       delta);
 	}
 
@@ -421,9 +406,7 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
 		delta = libinput_event_tablet_tool_get_axis_delta(t,
 					LIBINPUT_TABLET_TOOL_AXIS_SLIDER);
 		printf("\tslider: %.2f%s (%.2f)",
-		       slider,
-		       tablet_axis_changed_sym(t,
-				       LIBINPUT_TABLET_TOOL_AXIS_SLIDER),
+		       slider, changed_sym(t, slider),
 		       delta);
 	}
 
@@ -433,9 +416,7 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
 		delta = libinput_event_tablet_tool_get_axis_delta_discrete(t,
 					LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL);
 		printf("\twheel: %.2f%s (%d)",
-		       wheel,
-		       tablet_axis_changed_sym(t,
-				       LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL),
+		       wheel, changed_sym(t, wheel),
 		       (int)delta);
 	}
 }
-- 
2.5.0



More information about the wayland-devel mailing list