<br><br><div class="gmail_quote">On Fri, Jun 1, 2012 at 1:30 AM, Pekka Paalanen <span dir="ltr"><<a href="mailto:ppaalanen@gmail.com" target="_blank">ppaalanen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Thu, 31 May 2012 14:02:48 -0600<br>
Scott Moreau <<a href="mailto:oreaus@gmail.com">oreaus@gmail.com</a>> wrote:<br>
<br>
> * Drop user input detection since cursor position may change when pasting text,<br>
> for example.<br>
> * Use fixed type in protocol.<br>
<br>
</div>Hi Scott,<br>
<br>
some inline comments I below.<br>
<div><div class="h5"><br>
> ---<br>
><br>
> Changed int to fixed in protocol/text-cursor-position.xml<br>
><br>
> clients/window.c | 15 +++++----------<br>
> clients/window.h | 2 +-<br>
> protocol/text-cursor-position.xml | 4 ++--<br>
> src/compositor.c | 11 ++++++-----<br>
> src/compositor.h | 6 ++++--<br>
> src/text-cursor-position.c | 2 +-<br>
> 6 files changed, 19 insertions(+), 21 deletions(-)<br>
><br>
> diff --git a/clients/window.c b/clients/window.c<br>
> index 3ef648e..74fc5c1 100644<br>
> --- a/clients/window.c<br>
> +++ b/clients/window.c<br>
> @@ -151,7 +151,6 @@ struct window {<br>
> int resize_needed;<br>
> int type;<br>
> int transparent;<br>
> - int send_cursor_position;<br>
> struct input *keyboard_device;<br>
> enum window_buffer_type buffer_type;<br>
><br>
> @@ -1826,9 +1825,6 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard,<br>
> if (!window || window->keyboard_device != input)<br>
> return;<br>
><br>
> - if (state)<br>
> - window->send_cursor_position = 1;<br>
> -<br>
> num_syms = xkb_key_get_syms(d->xkb.state, code, &syms);<br>
> xkb_state_update_key(d->xkb.state, code,<br>
> state ? XKB_KEY_DOWN : XKB_KEY_UP);<br>
> @@ -2616,18 +2612,18 @@ window_get_title(struct window *window)<br>
> }<br>
><br>
> void<br>
> -window_set_text_cursor_position(struct window *window, int32_t x, int32_t y)<br>
> +window_set_text_cursor_position(struct window *window, uint32_t x, uint32_t y)<br>
<br>
</div></div>Why the change in argument types?<br>
I think we have all integer coordinates always as signed, regardless of<br>
valid domain.<br></blockquote><div><br>Ok thanks for pointing this out.<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><div class="h5"><br>
> {<br>
> struct text_cursor_position *text_cursor_position =<br>
> window->display->text_cursor_position;<br>
><br>
> - if (!window->send_cursor_position || !text_cursor_position)<br>
> + if (!text_cursor_position)<br>
> return;<br>
><br>
> text_cursor_position_notify(text_cursor_position,<br>
> - window->surface, x, y);<br>
> -<br>
> - window->send_cursor_position = 0;<br>
> + window->surface,<br>
> + wl_fixed_from_int(x),<br>
> + wl_fixed_from_int(y));<br>
> }<br>
><br>
> void<br>
> @@ -2716,7 +2712,6 @@ window_create_internal(struct display *display, struct window *parent)<br>
> window->allocation.height = 0;<br>
> window->saved_allocation = window->allocation;<br>
> window->transparent = 1;<br>
> - window->send_cursor_position = 0;<br>
> window->type = TYPE_NONE;<br>
> window->input_region = NULL;<br>
> window->opaque_region = NULL;<br>
> diff --git a/clients/window.h b/clients/window.h<br>
> index a8537b3..09e4dc8 100644<br>
> --- a/clients/window.h<br>
> +++ b/clients/window.h<br>
> @@ -308,7 +308,7 @@ const char *<br>
> window_get_title(struct window *window);<br>
><br>
> void<br>
> -window_set_text_cursor_position(struct window *window, int32_t x, int32_t y);<br>
> +window_set_text_cursor_position(struct window *window, uint32_t x, uint32_t y);<br>
><br>
> int<br>
> widget_set_tooltip(struct widget *parent, char *entry, float x, float y);<br>
> diff --git a/protocol/text-cursor-position.xml b/protocol/text-cursor-position.xml<br>
> index dbeda72..0fbc54e 100644<br>
> --- a/protocol/text-cursor-position.xml<br>
> +++ b/protocol/text-cursor-position.xml<br>
> @@ -3,8 +3,8 @@<br>
> <interface name="text_cursor_position" version="1"><br>
> <request name="notify"><br>
> <arg name="surface" type="object" interface="wl_surface"/><br>
> - <arg name="x" type="uint"/><br>
> - <arg name="y" type="uint"/><br>
> + <arg name="x" type="fixed"/><br>
> + <arg name="y" type="fixed"/><br>
> </request><br>
> </interface><br>
><br>
> diff --git a/src/compositor.c b/src/compositor.c<br>
> index a36ccd5..fbfab6e 100644<br>
> --- a/src/compositor.c<br>
> +++ b/src/compositor.c<br>
> @@ -2446,14 +2446,15 @@ weston_output_destroy(struct weston_output *output)<br>
><br>
> WL_EXPORT void<br>
> weston_text_cursor_position_notify(struct weston_surface *surface,<br>
> - int32_t cur_pos_x,<br>
> - int32_t cur_pos_y)<br>
> + wl_fixed_t cur_pos_fx,<br>
> + wl_fixed_t cur_pos_fy)<br>
> {<br>
> struct weston_output *output;<br>
> - int32_t global_x, global_y;<br>
> + wl_fixed_t global_x, global_y;<br>
><br>
> - weston_surface_to_global(surface, cur_pos_x, cur_pos_y,<br>
> - &global_x, &global_y);<br>
> + weston_surface_to_global(surface, wl_fixed_to_int(cur_pos_fx),<br>
> + wl_fixed_to_int(cur_pos_fy),<br>
> + &global_x, &global_y);<br>
<br>
</div></div>That is wrong, because global_x is wl_fixed_t and<br>
weston_surface_to_global() expects an int32_t. Therefore the result<br>
will be off by a factor of 256. If this works for you, then there<br>
probably is another similar confusion between int and fixed elsewhere.<br></blockquote><div><br>Yes, I don't really understand all this wl_fixed_t stuff and it's somewhat annoying.<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
You should use weston_surface_to_global_fixed() instead, dropping the<br>
wl_fixed_to_int() calls, which throw away precision - the reason why<br>
wl_fixed_t exists in the first place.<br></blockquote><div><br>Ok thanks, I have to rework this patch anyway against latest commits.<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
This would have been cought by the compiler, if wl_fixed_t just was a<br>
type-safe type and not something that implicitly casts to any<br>
integer...<br></blockquote><div><br>Yes again, annoying.<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><div class="h5"><br>
><br>
> wl_list_for_each(output, &surface->compositor->output_list, link)<br>
> if (output->zoom.active &&<br>
> diff --git a/src/compositor.h b/src/compositor.h<br>
> index 09cd215..63ad3a6 100644<br>
> --- a/src/compositor.h<br>
> +++ b/src/compositor.h<br>
> @@ -567,9 +567,11 @@ void<br>
> weston_compositor_shutdown(struct weston_compositor *ec);<br>
> void<br>
> weston_output_update_zoom(struct weston_output *output,<br>
> - int x, int y, uint32_t type);<br>
> + wl_fixed_t x, wl_fixed_t y,<br>
> + uint32_t type);<br>
> void<br>
> -weston_text_cursor_position_notify(struct weston_surface *surface, int x, int y);<br>
> +weston_text_cursor_position_notify(struct weston_surface *surface,<br>
> + wl_fixed_t x, wl_fixed_t y);<br>
> void<br>
> weston_output_update_matrix(struct weston_output *output);<br>
> void<br>
> diff --git a/src/text-cursor-position.c b/src/text-cursor-position.c<br>
> index 6f46636..ef1085a 100644<br>
> --- a/src/text-cursor-position.c<br>
> +++ b/src/text-cursor-position.c<br>
> @@ -37,7 +37,7 @@ static void<br>
> text_cursor_position_notify(struct wl_client *client,<br>
> struct wl_resource *resource,<br>
> struct wl_resource *surface_resource,<br>
> - uint32_t x, uint32_t y)<br>
> + wl_fixed_t x, wl_fixed_t y)<br>
> {<br>
> weston_text_cursor_position_notify((struct weston_surface *) surface_resource, x, y);<br>
> }<br>
<br>
<br>
</div></div>Thanks,<br>
pq<br></blockquote><div><br><br><br>Thanks,<br><br>Scott <br></div></div><br>