[PATCH libinput 1/2] Rename delta_coords to device_float_coords

Hans de Goede hdegoede at redhat.com
Thu Mar 26 01:57:26 PDT 2015


What we really need is not a specific delta type, but a type which can hold
non discrete device coordinates, this is e.g. also needed for the center
coordinates of gestures. So rename delta_coords to device_float_coords to
properly reflect what we really need.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 src/evdev-mt-touchpad.c | 18 +++++++++---------
 src/evdev-mt-touchpad.h |  6 +++---
 src/libinput-private.h  | 16 ++++++++--------
 3 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index afc9178..b598695 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -244,20 +244,20 @@ tp_estimate_delta(int x0, int x1, int x2, int x3)
 struct normalized_coords
 tp_get_delta(struct tp_touch *t)
 {
-	struct delta_coords delta;
+	struct device_float_coords delta;
 	const struct normalized_coords zero = { 0.0, 0.0 };
 
 	if (t->history.count < TOUCHPAD_MIN_SAMPLES)
 		return zero;
 
-	delta.dx = tp_estimate_delta(tp_motion_history_offset(t, 0)->x,
-				     tp_motion_history_offset(t, 1)->x,
-				     tp_motion_history_offset(t, 2)->x,
-				     tp_motion_history_offset(t, 3)->x);
-	delta.dy = tp_estimate_delta(tp_motion_history_offset(t, 0)->y,
-				     tp_motion_history_offset(t, 1)->y,
-				     tp_motion_history_offset(t, 2)->y,
-				     tp_motion_history_offset(t, 3)->y);
+	delta.x = tp_estimate_delta(tp_motion_history_offset(t, 0)->x,
+				    tp_motion_history_offset(t, 1)->x,
+				    tp_motion_history_offset(t, 2)->x,
+				    tp_motion_history_offset(t, 3)->x);
+	delta.y = tp_estimate_delta(tp_motion_history_offset(t, 0)->y,
+				    tp_motion_history_offset(t, 1)->y,
+				    tp_motion_history_offset(t, 2)->y,
+				    tp_motion_history_offset(t, 3)->y);
 
 	return tp_normalize_delta(t->tp, delta);
 }
diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
index 5d52723..19a262e 100644
--- a/src/evdev-mt-touchpad.h
+++ b/src/evdev-mt-touchpad.h
@@ -275,12 +275,12 @@ struct tp_dispatch {
 	for (unsigned int _i = 0; _i < (_tp)->ntouches && (_t = &(_tp)->touches[_i]); _i++)
 
 static inline struct normalized_coords
-tp_normalize_delta(struct tp_dispatch *tp, struct delta_coords delta)
+tp_normalize_delta(struct tp_dispatch *tp, struct device_float_coords delta)
 {
 	struct normalized_coords normalized;
 
-	normalized.x = delta.dx * tp->accel.x_scale_coeff;
-	normalized.y = delta.dy * tp->accel.y_scale_coeff;
+	normalized.x = delta.x * tp->accel.x_scale_coeff;
+	normalized.y = delta.y * tp->accel.y_scale_coeff;
 
 	return normalized;
 }
diff --git a/src/libinput-private.h b/src/libinput-private.h
index 722505c..1da7db9 100644
--- a/src/libinput-private.h
+++ b/src/libinput-private.h
@@ -39,11 +39,11 @@ struct device_coords {
 };
 
 /*
- * A delta between 2 device coordinates,
- * may be non-discrete because of averaging.
+ * A coordinate pair in device coordinates, capable of holding non discrete
+ * values, this is necessary e.g. when device coordinates get averaged.
  */
-struct delta_coords {
-	double dx, dy;
+struct device_float_coords {
+	double x, y;
 };
 
 /* A dpi-normalized coordinate pair */
@@ -363,13 +363,13 @@ libinput_now(struct libinput *libinput)
 	return ts.tv_sec * 1000ULL + ts.tv_nsec / 1000000;
 }
 
-static inline struct delta_coords
+static inline struct device_float_coords
 device_delta(struct device_coords a, struct device_coords b)
 {
-	struct delta_coords delta;
+	struct device_float_coords delta;
 
-	delta.dx = a.x - b.x;
-	delta.dy = a.y - b.y;
+	delta.x = a.x - b.x;
+	delta.y = a.y - b.y;
 
 	return delta;
 }
-- 
2.3.3



More information about the wayland-devel mailing list