Rename delta_coords to device_float_coords
authorHans de Goede <hdegoede@redhat.com>
Wed, 25 Mar 2015 10:01:04 +0000 (11:01 +0100)
committerHans de Goede <hdegoede@redhat.com>
Fri, 27 Mar 2015 13:44:18 +0000 (14:44 +0100)
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@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
src/evdev-mt-touchpad.c
src/evdev-mt-touchpad.h
src/libinput-private.h

index afc9178..b598695 100644 (file)
@@ -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);
 }
index 5d52723..19a262e 100644 (file)
@@ -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;
 }
index 722505c..1da7db9 100644 (file)
@@ -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;
 }