[PATCH libinput 11/16] filter: split out handling of the low-dpi accel method

Jonas Ådahl jadahl at gmail.com
Mon Aug 10 01:22:26 PDT 2015


On Wed, Aug 05, 2015 at 04:32:40PM +1000, Peter Hutterer wrote:
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

Reviewed-by: Jonas Ådahl <jadahl at gmail.com>

> ---
>  src/filter.c | 34 ++++++++++++++++++++++++++++++++--
>  1 file changed, 32 insertions(+), 2 deletions(-)
> 
> diff --git a/src/filter.c b/src/filter.c
> index 68f1786..16dedb4 100644
> --- a/src/filter.c
> +++ b/src/filter.c
> @@ -296,6 +296,27 @@ accelerator_filter(struct motion_filter *filter,
>  		(struct pointer_accelerator *) filter;
>  	double accel_value; /* unitless factor */
>  	struct normalized_coords accelerated;
> +
> +	accel_value = calculate_acceleration_factor(accel,
> +						    unaccelerated,
> +						    data,
> +						    time);
> +
> +	accelerated.x = accel_value * unaccelerated->x;
> +	accelerated.y = accel_value * unaccelerated->y;
> +
> +	return accelerated;
> +}
> +
> +static struct normalized_coords
> +accelerator_filter_low_dpi(struct motion_filter *filter,
> +			   const struct normalized_coords *unaccelerated,
> +			   void *data, uint64_t time)
> +{
> +	struct pointer_accelerator *accel =
> +		(struct pointer_accelerator *) filter;
> +	double accel_value; /* unitless factor */
> +	struct normalized_coords accelerated;
>  	struct normalized_coords unnormalized;
>  	double dpi_factor = accel->dpi_factor;
>  
> @@ -573,8 +594,6 @@ create_default_filter(int dpi)
>  	if (filter == NULL)
>  		return NULL;
>  
> -	filter->base.interface = &accelerator_interface;
> -
>  	filter->last_velocity = 0.0;
>  
>  	filter->trackers =
> @@ -599,11 +618,19 @@ create_pointer_accelerator_filter_linear(int dpi)
>  	if (!filter)
>  		return NULL;
>  
> +	filter->base.interface = &accelerator_interface;
>  	filter->profile = pointer_accel_profile_linear;
>  
>  	return &filter->base;
>  }
>  
> +struct motion_filter_interface accelerator_interface_low_dpi = {
> +	accelerator_filter_low_dpi,
> +	accelerator_restart,
> +	accelerator_destroy,
> +	accelerator_set_speed,
> +};
> +
>  struct motion_filter *
>  create_pointer_accelerator_filter_linear_low_dpi(int dpi)
>  {
> @@ -613,6 +640,7 @@ create_pointer_accelerator_filter_linear_low_dpi(int dpi)
>  	if (!filter)
>  		return NULL;
>  
> +	filter->base.interface = &accelerator_interface_low_dpi;
>  	filter->profile = pointer_accel_profile_linear_low_dpi;
>  
>  	return &filter->base;
> @@ -627,6 +655,7 @@ create_pointer_accelerator_filter_touchpad(int dpi)
>  	if (!filter)
>  		return NULL;
>  
> +	filter->base.interface = &accelerator_interface;
>  	filter->profile = touchpad_accel_profile_linear;
>  
>  	return &filter->base;
> @@ -641,6 +670,7 @@ create_pointer_accelerator_filter_lenovo_x230(int dpi)
>  	if (!filter)
>  		return NULL;
>  
> +	filter->base.interface = &accelerator_interface;
>  	filter->profile = touchpad_lenovo_x230_accel_profile;
>  
>  	return &filter->base;
> -- 
> 2.4.3
> 
> _______________________________________________
> 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