[PATCH libinput 08/11] touchpad: Move gesture handling code to evdev-mt-touchpad-gestures.c

Hans de Goede hdegoede at redhat.com
Wed Feb 18 04:26:51 PST 2015


Just moving some code around, no functional changes.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 src/evdev-mt-touchpad-gestures.c | 94 +++++++++++++++++++++++++++++++++++++++-
 src/evdev-mt-touchpad.c          | 92 ---------------------------------------
 src/evdev-mt-touchpad.h          |  9 ----
 3 files changed, 93 insertions(+), 102 deletions(-)

diff --git a/src/evdev-mt-touchpad-gestures.c b/src/evdev-mt-touchpad-gestures.c
index 28ac74b..250974f 100644
--- a/src/evdev-mt-touchpad-gestures.c
+++ b/src/evdev-mt-touchpad-gestures.c
@@ -31,7 +31,53 @@
 
 #define DEFAULT_GESTURE_SWITCH_TIMEOUT 100 /* ms */
 
-void
+static void
+tp_get_average_touches_delta(struct tp_dispatch *tp, double *dx, double *dy)
+{
+	struct tp_touch *t;
+	int nchanged = 0;
+	double tmpx, tmpy;
+
+	*dx = 0.0;
+	*dy = 0.0;
+
+	tp_for_each_touch(tp, t) {
+		if (tp_touch_active(tp, t) && t->dirty) {
+			nchanged++;
+			tp_get_delta(t, &tmpx, &tmpy);
+
+			*dx += tmpx;
+			*dy += tmpy;
+		}
+	}
+
+	if (nchanged == 0)
+		return;
+
+	*dx /= nchanged;
+	*dy /= nchanged;
+}
+
+static void
+tp_get_combined_touches_delta(struct tp_dispatch *tp, double *dx, double *dy)
+{
+	struct tp_touch *t;
+	double tdx, tdy;
+	unsigned int i;
+
+	for (i = 0; i < tp->real_touches; i++) {
+		t = &tp->touches[i];
+
+		if (!tp_touch_active(tp, t) || !t->dirty)
+			continue;
+
+		tp_get_delta(t, &tdx, &tdy);
+		*dx += tdx;
+		*dy += tdy;
+	}
+}
+
+static void
 tp_gesture_start(struct tp_dispatch *tp, uint64_t time)
 {
 	if (tp->gesture.started)
@@ -45,6 +91,44 @@ tp_gesture_start(struct tp_dispatch *tp, uint64_t time)
 	tp->gesture.started = true;
 }
 
+static void
+tp_gesture_post_pointer_motion(struct tp_dispatch *tp, uint64_t time)
+{
+	double dx = 0.0, dy = 0.0;
+	double dx_unaccel, dy_unaccel;
+
+	/* When a clickpad is clicked, combine motion of all active touches */
+	if (tp->buttons.is_clickpad && tp->buttons.state)
+		tp_get_combined_touches_delta(tp, &dx, &dy);
+	else
+		tp_get_average_touches_delta(tp, &dx, &dy);
+
+	tp_filter_motion(tp, &dx, &dy, &dx_unaccel, &dy_unaccel, time);
+
+	if (dx != 0.0 || dy != 0.0 || dx_unaccel != 0.0 || dy_unaccel != 0.0) {
+		pointer_notify_motion(&tp->device->base, time,
+				      dx, dy, dx_unaccel, dy_unaccel);
+	}
+}
+
+static void
+tp_gesture_post_twofinger_scroll(struct tp_dispatch *tp, uint64_t time)
+{
+	double dx = 0, dy =0;
+
+	tp_get_average_touches_delta(tp, &dx, &dy);
+	tp_filter_motion(tp, &dx, &dy, NULL, NULL, time);
+
+	if (dx == 0.0 && dy == 0.0)
+		return;
+
+	tp_gesture_start(tp, time);
+	evdev_post_scroll(tp->device,
+			  time,
+			  LIBINPUT_POINTER_AXIS_SOURCE_FINGER,
+			  dx, dy);
+}
+
 void
 tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time)
 {
@@ -73,6 +157,14 @@ tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time)
 }
 
 void
+tp_gesture_stop_twofinger_scroll(struct tp_dispatch *tp, uint64_t time)
+{
+	evdev_stop_scroll(tp->device,
+			  time,
+			  LIBINPUT_POINTER_AXIS_SOURCE_FINGER);
+}
+
+void
 tp_gesture_stop(struct tp_dispatch *tp, uint64_t time)
 {
 	if (!tp->gesture.started)
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 947678a..6bcbfcd 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -494,59 +494,6 @@ tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
 }
 
 static void
-tp_get_average_touches_delta(struct tp_dispatch *tp, double *dx, double *dy)
-{
-	struct tp_touch *t;
-	int nchanged = 0;
-	double tmpx, tmpy;
-
-	*dx = 0.0;
-	*dy = 0.0;
-
-	tp_for_each_touch(tp, t) {
-		if (tp_touch_active(tp, t) && t->dirty) {
-			nchanged++;
-			tp_get_delta(t, &tmpx, &tmpy);
-
-			*dx += tmpx;
-			*dy += tmpy;
-		}
-	}
-
-	if (nchanged == 0)
-		return;
-
-	*dx /= nchanged;
-	*dy /= nchanged;
-}
-
-void
-tp_gesture_post_twofinger_scroll(struct tp_dispatch *tp, uint64_t time)
-{
-	double dx = 0, dy =0;
-
-	tp_get_average_touches_delta(tp, &dx, &dy);
-	tp_filter_motion(tp, &dx, &dy, NULL, NULL, time);
-
-	if (dx == 0.0 && dy == 0.0)
-		return;	
-
-	tp_gesture_start(tp, time);
-	evdev_post_scroll(tp->device,
-			  time,
-			  LIBINPUT_POINTER_AXIS_SOURCE_FINGER,
-			  dx, dy);
-}
-
-void
-tp_gesture_stop_twofinger_scroll(struct tp_dispatch *tp, uint64_t time)
-{
-	evdev_stop_scroll(tp->device,
-			  time,
-			  LIBINPUT_POINTER_AXIS_SOURCE_FINGER);
-}
-
-static void
 tp_unhover_touches(struct tp_dispatch *tp, uint64_t time)
 {
 	struct tp_touch *t;
@@ -680,45 +627,6 @@ tp_post_process_state(struct tp_dispatch *tp, uint64_t time)
 }
 
 static void
-tp_get_combined_touches_delta(struct tp_dispatch *tp, double *dx, double *dy)
-{
-	struct tp_touch *t;
-	double tdx, tdy;
-	unsigned int i;
-
-	for (i = 0; i < tp->real_touches; i++) {
-		t = tp_get_touch(tp, i);
-
-		if (!tp_touch_active(tp, t) || !t->dirty)
-			continue;
-
-		tp_get_delta(t, &tdx, &tdy);
-		*dx += tdx;
-		*dy += tdy;
-	}
-}
-
-void
-tp_gesture_post_pointer_motion(struct tp_dispatch *tp, uint64_t time)
-{
-	double dx = 0.0, dy = 0.0;
-	double dx_unaccel, dy_unaccel;
-
-	/* When a clickpad is clicked, combine motion of all active touches */
-	if (tp->buttons.is_clickpad && tp->buttons.state)
-		tp_get_combined_touches_delta(tp, &dx, &dy);
-	else
-		tp_get_average_touches_delta(tp, &dx, &dy);
-
-	tp_filter_motion(tp, &dx, &dy, &dx_unaccel, &dy_unaccel, time);
-
-	if (dx != 0.0 || dy != 0.0 || dx_unaccel != 0.0 || dy_unaccel != 0.0) {
-		pointer_notify_motion(&tp->device->base, time,
-				      dx, dy, dx_unaccel, dy_unaccel);
-	}
-}
-
-static void
 tp_post_events(struct tp_dispatch *tp, uint64_t time)
 {
 	int filter_motion = 0;
diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
index 4d8e875..e626286 100644
--- a/src/evdev-mt-touchpad.h
+++ b/src/evdev-mt-touchpad.h
@@ -375,9 +375,6 @@ void
 tp_remove_gesture(struct tp_dispatch *tp);
 
 void
-tp_gesture_start(struct tp_dispatch *tp, uint64_t time);
-
-void
 tp_gesture_stop(struct tp_dispatch *tp, uint64_t time);
 
 void
@@ -387,12 +384,6 @@ void
 tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time);
 
 void
-tp_gesture_post_twofinger_scroll(struct tp_dispatch *tp, uint64_t time);
-
-void
 tp_gesture_stop_twofinger_scroll(struct tp_dispatch *tp, uint64_t time);
 
-void
-tp_gesture_post_pointer_motion(struct tp_dispatch *tp, uint64_t time);
-
 #endif
-- 
2.1.0



More information about the wayland-devel mailing list