[PATCH libinput 3/5] filter: pass the DPI to the acceleration filter

Peter Hutterer peter.hutterer at who-t.net
Thu Jun 25 21:08:11 PDT 2015


Currently unused, but store the ratio of DPI:default DPI for later use.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev.c            | 3 ++-
 src/evdev.h            | 3 ---
 src/filter.c           | 7 ++++++-
 src/filter.h           | 3 ++-
 src/libinput-util.h    | 3 +++
 tools/ptraccel-debug.c | 3 ++-
 6 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index 9602587..62e6b83 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1410,7 +1410,8 @@ int
 evdev_device_init_pointer_acceleration(struct evdev_device *device,
 				       accel_profile_func_t profile)
 {
-	device->pointer.filter = create_pointer_accelerator_filter(profile);
+	device->pointer.filter = create_pointer_accelerator_filter(profile,
+								   device->dpi);
 	if (!device->pointer.filter)
 		return -1;
 
diff --git a/src/evdev.h b/src/evdev.h
index 0485894..4e77344 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -36,9 +36,6 @@
 #include "timer.h"
 #include "filter.h"
 
-/* The HW DPI rate we normalize to before calculating pointer acceleration */
-#define DEFAULT_MOUSE_DPI 1000
-
 /*
  * The constant (linear) acceleration factor we use to normalize trackpoint
  * deltas before calculating pointer acceleration.
diff --git a/src/filter.c b/src/filter.c
index b37ca76..b1fd67f 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -111,6 +111,8 @@ struct pointer_accelerator {
 	double threshold;	/* units/ms */
 	double accel;		/* unitless factor */
 	double incline;		/* incline of the function */
+
+	double dpi_factor;
 };
 
 static void
@@ -346,7 +348,8 @@ struct motion_filter_interface accelerator_interface = {
 };
 
 struct motion_filter *
-create_pointer_accelerator_filter(accel_profile_func_t profile)
+create_pointer_accelerator_filter(accel_profile_func_t profile,
+				  int dpi)
 {
 	struct pointer_accelerator *filter;
 
@@ -369,6 +372,8 @@ create_pointer_accelerator_filter(accel_profile_func_t profile)
 	filter->accel = DEFAULT_ACCELERATION;
 	filter->incline = DEFAULT_INCLINE;
 
+	filter->dpi = dpi;
+
 	return &filter->base;
 }
 
diff --git a/src/filter.h b/src/filter.h
index de94997..64a8b50 100644
--- a/src/filter.h
+++ b/src/filter.h
@@ -58,7 +58,8 @@ typedef double (*accel_profile_func_t)(struct motion_filter *filter,
 				       uint64_t time);
 
 struct motion_filter *
-create_pointer_accelerator_filter(accel_profile_func_t filter);
+create_pointer_accelerator_filter(accel_profile_func_t filter,
+				  int dpi);
 
 /*
  * Pointer acceleration profiles.
diff --git a/src/libinput-util.h b/src/libinput-util.h
index 0c56b76..00c93fe 100644
--- a/src/libinput-util.h
+++ b/src/libinput-util.h
@@ -37,6 +37,9 @@
 #define VENDOR_ID_APPLE 0x5ac
 #define VENDOR_ID_WACOM 0x56a
 
+/* The HW DPI rate we normalize to before calculating pointer acceleration */
+#define DEFAULT_MOUSE_DPI 1000
+
 void
 set_logging_enabled(int enabled);
 
diff --git a/tools/ptraccel-debug.c b/tools/ptraccel-debug.c
index c774e3b..0cfe2b7 100644
--- a/tools/ptraccel-debug.c
+++ b/tools/ptraccel-debug.c
@@ -199,7 +199,8 @@ main(int argc, char **argv)
 		OPT_SPEED,
 	};
 
-	filter = create_pointer_accelerator_filter(pointer_accel_profile_linear);
+	filter = create_pointer_accelerator_filter(pointer_accel_profile_linear,
+						   1000);
 	assert(filter != NULL);
 
 	while (1) {
-- 
2.4.3



More information about the wayland-devel mailing list