[PATCH libinput 19/23] filter: namespace the various trackers_* functions

Peter Hutterer peter.hutterer at who-t.net
Thu Apr 12 06:34:45 UTC 2018


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/filter-low-dpi.c       | 10 +++++-----
 src/filter-mouse.c         | 10 +++++-----
 src/filter-private.h       | 12 ++++++------
 src/filter-touchpad-x230.c | 14 +++++++-------
 src/filter-touchpad.c      | 10 +++++-----
 src/filter.c               | 30 +++++++++++++++---------------
 6 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/src/filter-low-dpi.c b/src/filter-low-dpi.c
index 07c57f22..e239b81a 100644
--- a/src/filter-low-dpi.c
+++ b/src/filter-low-dpi.c
@@ -97,8 +97,8 @@ calculate_acceleration_factor(struct pointer_accelerator *accel,
 	double velocity; /* units/us in device-native dpi*/
 	double accel_factor;
 
-	feed_trackers(&accel->trackers, unaccelerated, time);
-	velocity = calculate_velocity(&accel->trackers, time);
+	trackers_feed(&accel->trackers, unaccelerated, time);
+	velocity = trackers_velocity(&accel->trackers, time);
 	accel_factor = calculate_acceleration_simpsons(&accel->base,
 						       accel->profile,
 						       data,
@@ -168,7 +168,7 @@ accelerator_restart(struct motion_filter *filter,
 	struct pointer_accelerator *accel =
 		(struct pointer_accelerator *) filter;
 
-	reset_trackers(&accel->trackers, time);
+	trackers_reset(&accel->trackers, time);
 }
 
 static void
@@ -177,7 +177,7 @@ accelerator_destroy(struct motion_filter *filter)
 	struct pointer_accelerator *accel =
 		(struct pointer_accelerator *) filter;
 
-	free_trackers(&accel->trackers);
+	trackers_free(&accel->trackers);
 	free(accel);
 }
 
@@ -226,7 +226,7 @@ create_default_filter(int dpi)
 	filter = zalloc(sizeof *filter);
 	filter->last_velocity = 0.0;
 
-	init_trackers(&filter->trackers);
+	trackers_init(&filter->trackers);
 
 	filter->threshold = DEFAULT_THRESHOLD;
 	filter->accel = DEFAULT_ACCELERATION;
diff --git a/src/filter-mouse.c b/src/filter-mouse.c
index 94794c17..1a050368 100644
--- a/src/filter-mouse.c
+++ b/src/filter-mouse.c
@@ -64,8 +64,8 @@ calculate_acceleration_factor(struct pointer_accelerator *accel,
 	double velocity; /* units/us in device-native dpi*/
 	double accel_factor;
 
-	feed_trackers(&accel->trackers, unaccelerated, time);
-	velocity = calculate_velocity(&accel->trackers, time);
+	trackers_feed(&accel->trackers, unaccelerated, time);
+	velocity = trackers_velocity(&accel->trackers, time);
 	accel_factor = calculate_acceleration_simpsons(&accel->base,
 						       accel->profile,
 						       data,
@@ -166,7 +166,7 @@ accelerator_restart(struct motion_filter *filter,
 	struct pointer_accelerator *accel =
 		(struct pointer_accelerator *) filter;
 
-	reset_trackers(&accel->trackers, time);
+	trackers_reset(&accel->trackers, time);
 }
 
 static void
@@ -175,7 +175,7 @@ accelerator_destroy(struct motion_filter *filter)
 	struct pointer_accelerator *accel =
 		(struct pointer_accelerator *) filter;
 
-	free_trackers(&accel->trackers);
+	trackers_free(&accel->trackers);
 	free(accel);
 }
 
@@ -300,7 +300,7 @@ create_default_filter(int dpi)
 	filter = zalloc(sizeof *filter);
 	filter->last_velocity = 0.0;
 
-	init_trackers(&filter->trackers);
+	trackers_init(&filter->trackers);
 
 	filter->threshold = DEFAULT_THRESHOLD;
 	filter->accel = DEFAULT_ACCELERATION;
diff --git a/src/filter-private.h b/src/filter-private.h
index 7620a2cd..7fa1378c 100644
--- a/src/filter-private.h
+++ b/src/filter-private.h
@@ -88,22 +88,22 @@ struct pointer_accelerator {
 	int dpi;
 };
 
-void init_trackers(struct pointer_trackers *trackers);
-void free_trackers(struct pointer_trackers *trackers);
+void trackers_init(struct pointer_trackers *trackers);
+void trackers_free(struct pointer_trackers *trackers);
 
 void
-reset_trackers(struct pointer_trackers *trackers,
+trackers_reset(struct pointer_trackers *trackers,
 	       uint64_t time);
 void
-feed_trackers(struct pointer_trackers *trackers,
+trackers_feed(struct pointer_trackers *trackers,
 	      const struct device_float_coords *delta,
 	      uint64_t time);
 
 struct pointer_tracker *
-tracker_by_offset(struct pointer_trackers *trackers, unsigned int offset);
+trackers_by_offset(struct pointer_trackers *trackers, unsigned int offset);
 
 double
-calculate_velocity(struct pointer_trackers *trackers, uint64_t time);
+trackers_velocity(struct pointer_trackers *trackers, uint64_t time);
 
 double
 calculate_acceleration_simpsons(struct motion_filter *filter,
diff --git a/src/filter-touchpad-x230.c b/src/filter-touchpad-x230.c
index b87d47ab..10bdc1bb 100644
--- a/src/filter-touchpad-x230.c
+++ b/src/filter-touchpad-x230.c
@@ -148,8 +148,8 @@ calculate_acceleration_factor(struct pointer_accelerator_x230 *accel,
 	double velocity; /* units/us in device-native dpi*/
 	double accel_factor;
 
-	feed_trackers(&accel->trackers, unaccelerated, time);
-	velocity = calculate_velocity(&accel->trackers, time);
+	trackers_feed(&accel->trackers, unaccelerated, time);
+	velocity = trackers_velocity(&accel->trackers, time);
 	accel_factor = calculate_acceleration(accel,
 					      data,
 					      velocity,
@@ -184,8 +184,8 @@ accelerator_filter_x230(struct motion_filter *filter,
 	delta_normalized.x = unaccelerated.x;
 	delta_normalized.y = unaccelerated.y;
 
-	feed_trackers(&accel->trackers, &delta_normalized, time);
-	velocity = calculate_velocity(&accel->trackers, time);
+	trackers_feed(&accel->trackers, &delta_normalized, time);
+	velocity = trackers_velocity(&accel->trackers, time);
 	accel_factor = calculate_acceleration(accel,
 					      data,
 					      velocity,
@@ -228,14 +228,14 @@ accelerator_restart_x230(struct motion_filter *filter,
 	struct pointer_tracker *tracker;
 
 	for (offset = 1; offset < accel->trackers.ntrackers; offset++) {
-		tracker = tracker_by_offset(&accel->trackers, offset);
+		tracker = trackers_by_offset(&accel->trackers, offset);
 		tracker->time = 0;
 		tracker->dir = 0;
 		tracker->delta.x = 0;
 		tracker->delta.y = 0;
 	}
 
-	tracker = tracker_by_offset(&accel->trackers, 0);
+	tracker = trackers_by_offset(&accel->trackers, 0);
 	tracker->time = time;
 	tracker->dir = UNDEFINED_DIRECTION;
 }
@@ -340,7 +340,7 @@ create_pointer_accelerator_filter_lenovo_x230(int dpi)
 	filter->profile = touchpad_lenovo_x230_accel_profile;
 	filter->last_velocity = 0.0;
 
-	init_trackers(&filter->trackers);
+	trackers_init(&filter->trackers);
 
 	filter->threshold = X230_THRESHOLD;
 	filter->accel = X230_ACCELERATION; /* unitless factor */
diff --git a/src/filter-touchpad.c b/src/filter-touchpad.c
index 0723c311..146bac86 100644
--- a/src/filter-touchpad.c
+++ b/src/filter-touchpad.c
@@ -67,8 +67,8 @@ calculate_acceleration_factor(struct pointer_accelerator *accel,
 	double velocity; /* units/us in device-native dpi*/
 	double accel_factor;
 
-	feed_trackers(&accel->trackers, unaccelerated, time);
-	velocity = calculate_velocity(&accel->trackers, time);
+	trackers_feed(&accel->trackers, unaccelerated, time);
+	velocity = trackers_velocity(&accel->trackers, time);
 	accel_factor = calculate_acceleration_simpsons(&accel->base,
 						       accel->profile,
 						       data,
@@ -176,7 +176,7 @@ touchpad_accelerator_restart(struct motion_filter *filter,
 	struct pointer_accelerator *accel =
 		(struct pointer_accelerator *) filter;
 
-	reset_trackers(&accel->trackers, time);
+	trackers_reset(&accel->trackers, time);
 }
 
 static void
@@ -185,7 +185,7 @@ touchpad_accelerator_destroy(struct motion_filter *filter)
 	struct pointer_accelerator *accel =
 		(struct pointer_accelerator *) filter;
 
-	free_trackers(&accel->trackers);
+	trackers_free(&accel->trackers);
 	free(accel);
 }
 
@@ -287,7 +287,7 @@ create_pointer_accelerator_filter_touchpad(int dpi,
 	filter = zalloc(sizeof *filter);
 	filter->last_velocity = 0.0;
 
-	init_trackers(&filter->trackers);
+	trackers_init(&filter->trackers);
 
 	filter->threshold = TOUCHPAD_DEFAULT_THRESHOLD;
 	filter->accel = TOUCHPAD_ACCELERATION;
diff --git a/src/filter.c b/src/filter.c
index 48a9e8cc..dd66da70 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -91,7 +91,7 @@ filter_get_type(struct motion_filter *filter)
 }
 
 void
-init_trackers(struct pointer_trackers *trackers)
+trackers_init(struct pointer_trackers *trackers)
 {
 	const int ntrackers = 16;
 
@@ -103,34 +103,34 @@ init_trackers(struct pointer_trackers *trackers)
 }
 
 void
-free_trackers(struct pointer_trackers *trackers)
+trackers_free(struct pointer_trackers *trackers)
 {
 	free(trackers->trackers);
 	free(trackers->smoothener);
 }
 
 void
-reset_trackers(struct pointer_trackers *trackers,
+trackers_reset(struct pointer_trackers *trackers,
 	       uint64_t time)
 {
 	unsigned int offset;
 	struct pointer_tracker *tracker;
 
 	for (offset = 1; offset < trackers->ntrackers; offset++) {
-		tracker = tracker_by_offset(trackers, offset);
+		tracker = trackers_by_offset(trackers, offset);
 		tracker->time = 0;
 		tracker->dir = 0;
 		tracker->delta.x = 0;
 		tracker->delta.y = 0;
 	}
 
-	tracker = tracker_by_offset(trackers, 0);
+	tracker = trackers_by_offset(trackers, 0);
 	tracker->time = time;
 	tracker->dir = UNDEFINED_DIRECTION;
 }
 
 void
-feed_trackers(struct pointer_trackers *trackers,
+trackers_feed(struct pointer_trackers *trackers,
 	      const struct device_float_coords *delta,
 	      uint64_t time)
 {
@@ -154,7 +154,7 @@ feed_trackers(struct pointer_trackers *trackers,
 }
 
 struct pointer_tracker *
-tracker_by_offset(struct pointer_trackers *trackers, unsigned int offset)
+trackers_by_offset(struct pointer_trackers *trackers, unsigned int offset)
 {
 	unsigned int index =
 		(trackers->cur_tracker + trackers->ntrackers - offset)
@@ -163,7 +163,7 @@ tracker_by_offset(struct pointer_trackers *trackers, unsigned int offset)
 }
 
 static double
-calculate_tracker_velocity(struct pointer_tracker *tracker,
+calculate_trackers_velocity(struct pointer_tracker *tracker,
 			   uint64_t time,
 			   struct pointer_delta_smoothener *smoothener)
 {
@@ -177,7 +177,7 @@ calculate_tracker_velocity(struct pointer_tracker *tracker,
 }
 
 static double
-calculate_velocity_after_timeout(struct pointer_tracker *tracker,
+trackers_velocity_after_timeout(struct pointer_tracker *tracker,
 				 struct pointer_delta_smoothener *smoothener)
 {
 	/* First movement after timeout needs special handling.
@@ -191,7 +191,7 @@ calculate_velocity_after_timeout(struct pointer_tracker *tracker,
 	 * for really slow movements but provides much more useful initial
 	 * movement in normal use-cases (pause, move, pause, move)
 	 */
-	return calculate_tracker_velocity(tracker,
+	return calculate_trackers_velocity(tracker,
 					  tracker->time + MOTION_TIMEOUT,
 					  smoothener);
 }
@@ -204,7 +204,7 @@ calculate_velocity_after_timeout(struct pointer_tracker *tracker,
  * change between events.
  */
 double
-calculate_velocity(struct pointer_trackers *trackers, uint64_t time)
+trackers_velocity(struct pointer_trackers *trackers, uint64_t time)
 {
 	const int MAX_VELOCITY_DIFF = v_ms2us(1); /* units/us */
 	struct pointer_tracker *tracker;
@@ -214,12 +214,12 @@ calculate_velocity(struct pointer_trackers *trackers, uint64_t time)
 	double velocity_diff;
 	unsigned int offset;
 
-	unsigned int dir = tracker_by_offset(trackers, 0)->dir;
+	unsigned int dir = trackers_by_offset(trackers, 0)->dir;
 
 	/* Find least recent vector within a timelimit, maximum velocity diff
 	 * and direction threshold. */
 	for (offset = 1; offset < trackers->ntrackers; offset++) {
-		tracker = tracker_by_offset(trackers, offset);
+		tracker = trackers_by_offset(trackers, offset);
 
 		/* Bug: time running backwards */
 		if (tracker->time > time)
@@ -228,13 +228,13 @@ calculate_velocity(struct pointer_trackers *trackers, uint64_t time)
 		/* Stop if too far away in time */
 		if (time - tracker->time > MOTION_TIMEOUT) {
 			if (offset == 1)
-				result = calculate_velocity_after_timeout(
+				result = trackers_velocity_after_timeout(
 							  tracker,
 							  trackers->smoothener);
 			break;
 		}
 
-		velocity = calculate_tracker_velocity(tracker,
+		velocity = calculate_trackers_velocity(tracker,
 						      time,
 						      trackers->smoothener);
 
-- 
2.14.3



More information about the wayland-devel mailing list