<br><br><div class="gmail_quote">On Fri, Jun 1, 2012 at 1:30 AM, Pekka Paalanen <span dir="ltr">&lt;<a href="mailto:ppaalanen@gmail.com" target="_blank">ppaalanen@gmail.com</a>&gt;</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 &lt;<a href="mailto:oreaus@gmail.com">oreaus@gmail.com</a>&gt; wrote:<br>
<br>
&gt; * Drop user input detection since cursor position may change when pasting text,<br>
&gt; for example.<br>
&gt; * Use fixed type in protocol.<br>
<br>
</div>Hi Scott,<br>
<br>
some inline comments I below.<br>
<div><div class="h5"><br>
&gt; ---<br>
&gt;<br>
&gt; Changed int to fixed in protocol/text-cursor-position.xml<br>
&gt;<br>
&gt;  clients/window.c                  |   15 +++++----------<br>
&gt;  clients/window.h                  |    2 +-<br>
&gt;  protocol/text-cursor-position.xml |    4 ++--<br>
&gt;  src/compositor.c                  |   11 ++++++-----<br>
&gt;  src/compositor.h                  |    6 ++++--<br>
&gt;  src/text-cursor-position.c        |    2 +-<br>
&gt;  6 files changed, 19 insertions(+), 21 deletions(-)<br>
&gt;<br>
&gt; diff --git a/clients/window.c b/clients/window.c<br>
&gt; index 3ef648e..74fc5c1 100644<br>
&gt; --- a/clients/window.c<br>
&gt; +++ b/clients/window.c<br>
&gt; @@ -151,7 +151,6 @@ struct window {<br>
&gt;       int resize_needed;<br>
&gt;       int type;<br>
&gt;       int transparent;<br>
&gt; -     int send_cursor_position;<br>
&gt;       struct input *keyboard_device;<br>
&gt;       enum window_buffer_type buffer_type;<br>
&gt;<br>
&gt; @@ -1826,9 +1825,6 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard,<br>
&gt;       if (!window || window-&gt;keyboard_device != input)<br>
&gt;               return;<br>
&gt;<br>
&gt; -     if (state)<br>
&gt; -             window-&gt;send_cursor_position = 1;<br>
&gt; -<br>
&gt;       num_syms = xkb_key_get_syms(d-&gt;xkb.state, code, &amp;syms);<br>
&gt;       xkb_state_update_key(d-&gt;xkb.state, code,<br>
&gt;                            state ? XKB_KEY_DOWN : XKB_KEY_UP);<br>
&gt; @@ -2616,18 +2612,18 @@ window_get_title(struct window *window)<br>
&gt;  }<br>
&gt;<br>
&gt;  void<br>
&gt; -window_set_text_cursor_position(struct window *window, int32_t x, int32_t y)<br>
&gt; +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>
&gt;  {<br>
&gt;       struct text_cursor_position *text_cursor_position =<br>
&gt;                                       window-&gt;display-&gt;text_cursor_position;<br>
&gt;<br>
&gt; -     if (!window-&gt;send_cursor_position || !text_cursor_position)<br>
&gt; +     if (!text_cursor_position)<br>
&gt;               return;<br>
&gt;<br>
&gt;       text_cursor_position_notify(text_cursor_position,<br>
&gt; -                                             window-&gt;surface, x, y);<br>
&gt; -<br>
&gt; -     window-&gt;send_cursor_position = 0;<br>
&gt; +                                             window-&gt;surface,<br>
&gt; +                                             wl_fixed_from_int(x),<br>
&gt; +                                             wl_fixed_from_int(y));<br>
&gt;  }<br>
&gt;<br>
&gt;  void<br>
&gt; @@ -2716,7 +2712,6 @@ window_create_internal(struct display *display, struct window *parent)<br>
&gt;       window-&gt;allocation.height = 0;<br>
&gt;       window-&gt;saved_allocation = window-&gt;allocation;<br>
&gt;       window-&gt;transparent = 1;<br>
&gt; -     window-&gt;send_cursor_position = 0;<br>
&gt;       window-&gt;type = TYPE_NONE;<br>
&gt;       window-&gt;input_region = NULL;<br>
&gt;       window-&gt;opaque_region = NULL;<br>
&gt; diff --git a/clients/window.h b/clients/window.h<br>
&gt; index a8537b3..09e4dc8 100644<br>
&gt; --- a/clients/window.h<br>
&gt; +++ b/clients/window.h<br>
&gt; @@ -308,7 +308,7 @@ const char *<br>
&gt;  window_get_title(struct window *window);<br>
&gt;<br>
&gt;  void<br>
&gt; -window_set_text_cursor_position(struct window *window, int32_t x, int32_t y);<br>
&gt; +window_set_text_cursor_position(struct window *window, uint32_t x, uint32_t y);<br>
&gt;<br>
&gt;  int<br>
&gt;  widget_set_tooltip(struct widget *parent, char *entry, float x, float y);<br>
&gt; diff --git a/protocol/text-cursor-position.xml b/protocol/text-cursor-position.xml<br>
&gt; index dbeda72..0fbc54e 100644<br>
&gt; --- a/protocol/text-cursor-position.xml<br>
&gt; +++ b/protocol/text-cursor-position.xml<br>
&gt; @@ -3,8 +3,8 @@<br>
&gt;    &lt;interface name=&quot;text_cursor_position&quot; version=&quot;1&quot;&gt;<br>
&gt;      &lt;request name=&quot;notify&quot;&gt;<br>
&gt;        &lt;arg name=&quot;surface&quot; type=&quot;object&quot; interface=&quot;wl_surface&quot;/&gt;<br>
&gt; -      &lt;arg name=&quot;x&quot; type=&quot;uint&quot;/&gt;<br>
&gt; -      &lt;arg name=&quot;y&quot; type=&quot;uint&quot;/&gt;<br>
&gt; +      &lt;arg name=&quot;x&quot; type=&quot;fixed&quot;/&gt;<br>
&gt; +      &lt;arg name=&quot;y&quot; type=&quot;fixed&quot;/&gt;<br>
&gt;      &lt;/request&gt;<br>
&gt;    &lt;/interface&gt;<br>
&gt;<br>
&gt; diff --git a/src/compositor.c b/src/compositor.c<br>
&gt; index a36ccd5..fbfab6e 100644<br>
&gt; --- a/src/compositor.c<br>
&gt; +++ b/src/compositor.c<br>
&gt; @@ -2446,14 +2446,15 @@ weston_output_destroy(struct weston_output *output)<br>
&gt;<br>
&gt;  WL_EXPORT void<br>
&gt;  weston_text_cursor_position_notify(struct weston_surface *surface,<br>
&gt; -                                             int32_t cur_pos_x,<br>
&gt; -                                             int32_t cur_pos_y)<br>
&gt; +                                             wl_fixed_t cur_pos_fx,<br>
&gt; +                                             wl_fixed_t cur_pos_fy)<br>
&gt;  {<br>
&gt;       struct weston_output *output;<br>
&gt; -     int32_t global_x, global_y;<br>
&gt; +     wl_fixed_t global_x, global_y;<br>
&gt;<br>
&gt; -     weston_surface_to_global(surface, cur_pos_x, cur_pos_y,<br>
&gt; -                                             &amp;global_x, &amp;global_y);<br>
&gt; +     weston_surface_to_global(surface, wl_fixed_to_int(cur_pos_fx),<br>
&gt; +                                       wl_fixed_to_int(cur_pos_fy),<br>
&gt; +                                       &amp;global_x, &amp;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&#39;t really understand all this wl_fixed_t stuff and it&#39;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>
&gt;<br>
&gt;       wl_list_for_each(output, &amp;surface-&gt;compositor-&gt;output_list, link)<br>
&gt;               if (output-&gt;zoom.active &amp;&amp;<br>
&gt; diff --git a/src/compositor.h b/src/compositor.h<br>
&gt; index 09cd215..63ad3a6 100644<br>
&gt; --- a/src/compositor.h<br>
&gt; +++ b/src/compositor.h<br>
&gt; @@ -567,9 +567,11 @@ void<br>
&gt;  weston_compositor_shutdown(struct weston_compositor *ec);<br>
&gt;  void<br>
&gt;  weston_output_update_zoom(struct weston_output *output,<br>
&gt; -                                             int x, int y, uint32_t type);<br>
&gt; +                                             wl_fixed_t x, wl_fixed_t y,<br>
&gt; +                                             uint32_t type);<br>
&gt;  void<br>
&gt; -weston_text_cursor_position_notify(struct weston_surface *surface, int x, int y);<br>
&gt; +weston_text_cursor_position_notify(struct weston_surface *surface,<br>
&gt; +                                             wl_fixed_t x, wl_fixed_t y);<br>
&gt;  void<br>
&gt;  weston_output_update_matrix(struct weston_output *output);<br>
&gt;  void<br>
&gt; diff --git a/src/text-cursor-position.c b/src/text-cursor-position.c<br>
&gt; index 6f46636..ef1085a 100644<br>
&gt; --- a/src/text-cursor-position.c<br>
&gt; +++ b/src/text-cursor-position.c<br>
&gt; @@ -37,7 +37,7 @@ static void<br>
&gt;  text_cursor_position_notify(struct wl_client *client,<br>
&gt;                           struct wl_resource *resource,<br>
&gt;                           struct wl_resource *surface_resource,<br>
&gt; -                         uint32_t x, uint32_t y)<br>
&gt; +                         wl_fixed_t x, wl_fixed_t y)<br>
&gt;  {<br>
&gt;       weston_text_cursor_position_notify((struct weston_surface *) surface_resource, x, y);<br>
&gt;  }<br>
<br>
<br>
</div></div>Thanks,<br>
pq<br></blockquote><div><br><br><br>Thanks,<br><br>Scott <br></div></div><br>