[PATCH libinput 11/11] touchpad: Add support for swipe gestures

Peter Hutterer peter.hutterer at who-t.net
Sun Feb 22 19:25:00 PST 2015


On Wed, Feb 18, 2015 at 01:26:54PM +0100, Hans de Goede wrote:
> Add support for swipe gestures.
> 
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>

unless noted otherwise, series 
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

Cheers,
   Peter

> ---
>  src/evdev-mt-touchpad-gestures.c | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 
> diff --git a/src/evdev-mt-touchpad-gestures.c b/src/evdev-mt-touchpad-gestures.c
> index e429efe..faf5824 100644
> --- a/src/evdev-mt-touchpad-gestures.c
> +++ b/src/evdev-mt-touchpad-gestures.c
> @@ -25,6 +25,7 @@
>  #include <assert.h>
>  #include <math.h>
>  #include <stdbool.h>
> +#include <stdio.h>
>  #include <limits.h>
>  
>  #include "evdev-mt-touchpad.h"
> @@ -70,6 +71,13 @@ tp_gesture_start(struct tp_dispatch *tp, uint64_t time)
>  	case 2:
>  		/* NOP */
>  		break;
> +	case 3:
> +	case 4:
> +		gesture_notify_swipe(&tp->device->base, time,
> +				     LIBINPUT_EVENT_GESTURE_SWIPE_START,
> +				     tp->gesture.finger_mode,
> +				     0, 0, 0, 0);
> +		break;
>  	}
>  	tp->gesture.started = true;
>  }
> @@ -112,6 +120,23 @@ tp_gesture_post_twofinger_scroll(struct tp_dispatch *tp, uint64_t time)
>  			  dx, dy);
>  }
>  
> +static void
> +tp_gesture_post_swipe(struct tp_dispatch *tp, uint64_t time)
> +{
> +	double dx, dy, dx_unaccel, dy_unaccel;
> +
> +	tp_get_touches_delta(tp, &dx, &dy, true);
> +	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) {
> +		tp_gesture_start(tp, time);
> +		gesture_notify_swipe(&tp->device->base, time,
> +				     LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE,
> +				     tp->gesture.finger_mode,
> +				     dx, dy, dx_unaccel, dy_unaccel);
> +	}
> +}
> +
>  void
>  tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time)
>  {
> @@ -136,6 +161,10 @@ tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time)
>  	case 2:
>  		tp_gesture_post_twofinger_scroll(tp, time);
>  		break;
> +	case 3:
> +	case 4:
> +		tp_gesture_post_swipe(tp, time);
> +		break;
>  	}
>  }
>  
> @@ -157,6 +186,13 @@ tp_gesture_stop(struct tp_dispatch *tp, uint64_t time)
>  	case 2:
>  		tp_gesture_stop_twofinger_scroll(tp, time);
>  		break;
> +	case 3:
> +	case 4:
> +		gesture_notify_swipe(&tp->device->base, time,
> +				     LIBINPUT_EVENT_GESTURE_SWIPE_END,
> +				     tp->gesture.finger_mode,
> +				     0, 0, 0, 0);
> +		break;
>  	}
>  	tp->gesture.started = false;
>  }
> -- 
> 2.1.0
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
> 


More information about the wayland-devel mailing list