[PATCH libinput 17/23] filter: drop the ntrackers argument from init_trackers

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


Reduces the duplication, everyone uses the same value anyway

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/filter-low-dpi.c       | 3 +--
 src/filter-private.h       | 3 +--
 src/filter-touchpad-x230.c | 7 +------
 src/filter-touchpad.c      | 7 +------
 src/filter.c               | 8 ++++----
 5 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/src/filter-low-dpi.c b/src/filter-low-dpi.c
index f22929ad..07c57f22 100644
--- a/src/filter-low-dpi.c
+++ b/src/filter-low-dpi.c
@@ -45,7 +45,6 @@
 #define DEFAULT_ACCELERATION 2.0		/* unitless factor */
 #define DEFAULT_INCLINE 1.1			/* unitless factor */
 
-#define NUM_POINTER_TRACKERS	16
 /**
  * Custom acceleration function for mice < 1000dpi.
  * At slow motion, a single device unit causes a one-pixel movement.
@@ -227,7 +226,7 @@ create_default_filter(int dpi)
 	filter = zalloc(sizeof *filter);
 	filter->last_velocity = 0.0;
 
-	init_trackers(&filter->trackers, NUM_POINTER_TRACKERS);
+	init_trackers(&filter->trackers);
 
 	filter->threshold = DEFAULT_THRESHOLD;
 	filter->accel = DEFAULT_ACCELERATION;
diff --git a/src/filter-private.h b/src/filter-private.h
index 554b7f64..7620a2cd 100644
--- a/src/filter-private.h
+++ b/src/filter-private.h
@@ -88,8 +88,7 @@ struct pointer_accelerator {
 	int dpi;
 };
 
-void init_trackers(struct pointer_trackers *trackers,
-		   size_t ntrackers);
+void init_trackers(struct pointer_trackers *trackers);
 void free_trackers(struct pointer_trackers *trackers);
 
 void
diff --git a/src/filter-touchpad-x230.c b/src/filter-touchpad-x230.c
index be58915e..b87d47ab 100644
--- a/src/filter-touchpad-x230.c
+++ b/src/filter-touchpad-x230.c
@@ -60,11 +60,6 @@
 #define X230_MAGIC_SLOWDOWN 0.4			/* unitless */
 #define X230_TP_MAGIC_LOW_RES_FACTOR 4.0	/* unitless */
 
-/*
- * Pointer acceleration filter constants
- */
-#define NUM_POINTER_TRACKERS	16
-
 struct pointer_accelerator_x230 {
 	struct motion_filter base;
 
@@ -345,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, NUM_POINTER_TRACKERS);
+	init_trackers(&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 9217137c..0723c311 100644
--- a/src/filter-touchpad.c
+++ b/src/filter-touchpad.c
@@ -48,11 +48,6 @@
 #define TOUCHPAD_ACCELERATION 9.0		/* unitless factor */
 #define TOUCHPAD_INCLINE 0.011			/* unitless factor */
 
-/*
- * Pointer acceleration filter constants
- */
-#define NUM_POINTER_TRACKERS	16
-
 /**
  * Calculate the acceleration factor for the given delta with the timestamp.
  *
@@ -292,7 +287,7 @@ create_pointer_accelerator_filter_touchpad(int dpi,
 	filter = zalloc(sizeof *filter);
 	filter->last_velocity = 0.0;
 
-	init_trackers(&filter->trackers, NUM_POINTER_TRACKERS);
+	init_trackers(&filter->trackers);
 
 	filter->threshold = TOUCHPAD_DEFAULT_THRESHOLD;
 	filter->accel = TOUCHPAD_ACCELERATION;
diff --git a/src/filter.c b/src/filter.c
index 82d0ccce..d7709838 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -102,12 +102,12 @@ filter_get_type(struct motion_filter *filter)
  */
 
 #define MOTION_TIMEOUT		ms2us(1000)
-#define NUM_POINTER_TRACKERS	16
 
 void
-init_trackers(struct pointer_trackers *trackers,
-	      size_t ntrackers)
+init_trackers(struct pointer_trackers *trackers)
 {
+	const int ntrackers = 16;
+
 	trackers->trackers = zalloc(ntrackers *
 				    sizeof(*trackers->trackers));
 	trackers->ntrackers = ntrackers;
@@ -566,7 +566,7 @@ create_default_filter(int dpi)
 	filter = zalloc(sizeof *filter);
 	filter->last_velocity = 0.0;
 
-	init_trackers(&filter->trackers, NUM_POINTER_TRACKERS);
+	init_trackers(&filter->trackers);
 
 	filter->threshold = DEFAULT_THRESHOLD;
 	filter->accel = DEFAULT_ACCELERATION;
-- 
2.14.3



More information about the wayland-devel mailing list