[PATCH weston] Use wl_fixed_to_int() in weston_output_update_zoom().

Ander Conselvan de Oliveira conselvan2 at gmail.com
Wed May 16 07:10:28 PDT 2012


On 05/16/2012 04:37 PM, Scott Moreau wrote:
>
>     On 05/16/2012 02:18 AM, Scott Moreau wrote:
>
>         This way, we don't have to use wl_fixed_to_int() for
>         each call to weston_output_update_zoom(). The instance
>         in notify_motion() was missed, which broke zoom.
>         ---
>           src/compositor.c |    3 +++
>           src/shell.c      |    4 +---
>           2 files changed, 4 insertions(+), 3 deletions(-)
>
>         diff --git a/src/compositor.c b/src/compositor.c
>         index 788b1de..e5d89b5 100644
>         --- a/src/compositor.c
>         +++ b/src/compositor.c
>         @@ -2363,6 +2363,9 @@ weston_output_update_zoom(struct
>         weston_output *output, int x, int y)
>
>
>     You should also change the function prototype to make it clear it
>     takes wl_fixed_t.
>
>
> I thought the same initially but it actually takes int and converts
> internally to wl_fixed_t.. and stores them as int. There's no
> documentation on this so it's not clear on what the correct solution.

Well, wl_fixed_t is just a 32 bit integer (it is just a typedef). 
There's no implicit conversion and the compiler won't warn you if you 
use the value in fixed point notation as an int. If your patch is 
applied, both calls to weston_output_update_zoom() passes coordinates in 
fixed point notation. The conversion from fixed point to integer happens 
inside the function.

The prototype should make it clear it takes coordinates in fixed point 
notation otherwise someone might try to pass integer coordinates and end 
up with bogus values.


Cheers,
Ander


More information about the wayland-devel mailing list