[PATCH weston 1/5] compositor: When clipping pointer motions, don't loose precision

Daniel Stone daniel at fooishbar.org
Wed May 9 16:00:46 PDT 2012


Hi,

On 9 May 2012 22:31, Jonas Ådahl <jadahl at gmail.com> wrote:
> @@ -1563,18 +1563,20 @@ clip_pointer_motion(struct weston_compositor *ec,
>                    wl_fixed_t *fx, wl_fixed_t *fy)
>  {
>        struct weston_output *output;
> -       int32_t x, y;
> +       wl_fixed_t x, y;
>        int x_valid = 0, y_valid = 0;
>        int min_x = INT_MAX, min_y = INT_MAX, max_x = INT_MIN, max_y = INT_MIN;
>
> -       x = wl_fixed_to_int(*fx);
> -       y = wl_fixed_to_int(*fy);
> +       x = *fx;
> +       y = *fy;

You could easily ditch the intermediate variable here.

> @@ -1590,20 +1592,20 @@ clip_pointer_motion(struct weston_compositor *ec,
>        }
>
>        if (!x_valid) {
> -               if (x < min_x)
> -                       x = min_x;
> -               else if (x >= max_x)
> -                       x = max_x;
> +               if (x < wl_fixed_from_int(min_x))
> +                       x = wl_fixed_from_int(min_x);
> +               else if (x >= wl_fixed_from_int(max_x))
> +                       x = wl_fixed_from_int(max_x);

This should never be possible, as the range of a wl_fixed_t is a fair
bit less than that of an int, so this check can be dropped.  (And, now
it's come up, I think we might need some better range checking when we
create wl_fixed_ts earlier in the input chain ...)

Other than that:
Reviewed-by: Daniel Stone <daniel at fooishbar.org>

Cheers,
Daniel


More information about the wayland-devel mailing list