[1/3] touchpad: Add a tp_post_pointer_motion helper function

Submitted by Hans de Goede on Dec. 9, 2014, 11:47 a.m.

Details

Message ID 1418125631-27932-1-git-send-email-hdegoede@redhat.com
State Not Applicable
Headers show

Not browsing as part of any series.

Commit Message

Hans de Goede Dec. 9, 2014, 11:47 a.m.
Split out the pointer-motion handling into a helper function.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 src/evdev-mt-touchpad.c | 46 ++++++++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 20 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 5938080..7d2e21a 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -591,32 +591,13 @@  tp_post_process_state(struct tp_dispatch *tp, uint64_t time)
 	tp->queued = TOUCHPAD_EVENT_NONE;
 }
 
-
 static void
-tp_post_events(struct tp_dispatch *tp, uint64_t time)
+tp_post_pointer_motion(struct tp_dispatch *tp, uint64_t time)
 {
 	struct tp_touch *t = tp_current_touch(tp);
 	double dx, dy;
-	int filter_motion = 0;
 	double dx_unaccel, dy_unaccel;
 
-	/* Only post (top) button events while suspended */
-	if (tp->device->suspended) {
-		tp_post_button_events(tp, time);
-		return;
-	}
-
-	filter_motion |= tp_tap_handle_state(tp, time);
-	filter_motion |= tp_post_button_events(tp, time);
-
-	if (filter_motion || tp->sendevents.trackpoint_active) {
-		tp_stop_scroll_events(tp, time);
-		return;
-	}
-
-	if (tp_post_scroll_events(tp, time) != 0)
-		return;
-
 	if (!t->is_pointer) {
 		tp_for_each_touch(tp, t) {
 			if (t->is_pointer)
@@ -639,6 +620,31 @@  tp_post_events(struct tp_dispatch *tp, uint64_t time)
 }
 
 static void
+tp_post_events(struct tp_dispatch *tp, uint64_t time)
+{
+	int filter_motion = 0;
+
+	/* Only post (top) button events while suspended */
+	if (tp->device->suspended) {
+		tp_post_button_events(tp, time);
+		return;
+	}
+
+	filter_motion |= tp_tap_handle_state(tp, time);
+	filter_motion |= tp_post_button_events(tp, time);
+
+	if (filter_motion || tp->sendevents.trackpoint_active) {
+		tp_stop_scroll_events(tp, time);
+		return;
+	}
+
+	if (tp_post_scroll_events(tp, time) != 0)
+		return;
+
+	tp_post_pointer_motion(tp, time);
+}
+
+static void
 tp_handle_state(struct tp_dispatch *tp,
 		uint64_t time)
 {

Comments

On Tue, Dec 09, 2014 at 12:47:09PM +0100, Hans de Goede wrote:
> Split out the pointer-motion handling into a helper function.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>

Cheers,
   Peter

> ---
>  src/evdev-mt-touchpad.c | 46 ++++++++++++++++++++++++++--------------------
>  1 file changed, 26 insertions(+), 20 deletions(-)
> 
> diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
> index 5938080..7d2e21a 100644
> --- a/src/evdev-mt-touchpad.c
> +++ b/src/evdev-mt-touchpad.c
> @@ -591,32 +591,13 @@ tp_post_process_state(struct tp_dispatch *tp, uint64_t time)
>  	tp->queued = TOUCHPAD_EVENT_NONE;
>  }
>  
> -
>  static void
> -tp_post_events(struct tp_dispatch *tp, uint64_t time)
> +tp_post_pointer_motion(struct tp_dispatch *tp, uint64_t time)
>  {
>  	struct tp_touch *t = tp_current_touch(tp);
>  	double dx, dy;
> -	int filter_motion = 0;
>  	double dx_unaccel, dy_unaccel;
>  
> -	/* Only post (top) button events while suspended */
> -	if (tp->device->suspended) {
> -		tp_post_button_events(tp, time);
> -		return;
> -	}
> -
> -	filter_motion |= tp_tap_handle_state(tp, time);
> -	filter_motion |= tp_post_button_events(tp, time);
> -
> -	if (filter_motion || tp->sendevents.trackpoint_active) {
> -		tp_stop_scroll_events(tp, time);
> -		return;
> -	}
> -
> -	if (tp_post_scroll_events(tp, time) != 0)
> -		return;
> -
>  	if (!t->is_pointer) {
>  		tp_for_each_touch(tp, t) {
>  			if (t->is_pointer)
> @@ -639,6 +620,31 @@ tp_post_events(struct tp_dispatch *tp, uint64_t time)
>  }
>  
>  static void
> +tp_post_events(struct tp_dispatch *tp, uint64_t time)
> +{
> +	int filter_motion = 0;
> +
> +	/* Only post (top) button events while suspended */
> +	if (tp->device->suspended) {
> +		tp_post_button_events(tp, time);
> +		return;
> +	}
> +
> +	filter_motion |= tp_tap_handle_state(tp, time);
> +	filter_motion |= tp_post_button_events(tp, time);
> +
> +	if (filter_motion || tp->sendevents.trackpoint_active) {
> +		tp_stop_scroll_events(tp, time);
> +		return;
> +	}
> +
> +	if (tp_post_scroll_events(tp, time) != 0)
> +		return;
> +
> +	tp_post_pointer_motion(tp, time);
> +}
> +
> +static void
>  tp_handle_state(struct tp_dispatch *tp,
>  		uint64_t time)
>  {
> -- 
> 2.1.0