<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>
<br>
</div></div>Shouldn't we only update position when the user actually presses a<br>
key? What if you're dumping a lot of data to the terminal?<br></blockquote><div><br>Yes, you are right. I know about this but never fixed it.<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><br>
> void<br>
> +window_set_text_cursor_position(struct window *window, int32_t x, int32_t y)<br>
> +{<br>
> + struct text_cursor_position *text_cursor_position = window->display->text_cursor_position;<br>
<br>
</div>Break the line after '='?<br></blockquote><div><br>Yes.<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><br>
> + text_cursor_position_notify(text_cursor_position, window->surface, x, y);<br>
> +}<br>
<br>
</div>Let's check for window->display->text_cursor_position == NULL so it<br>
will work even if the compositor doesn't have that extension.<br></blockquote><div><br>Ok.<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><br>
><br>
> WL_EXPORT void<br>
> +weston_text_cursor_position_notify(struct weston_surface *surface,<br>
> + int32_t x, int32_t y)<br>
> +{<br>
> + struct weston_output *output;<br>
> + int32_t surface_x, surface_y;<br>
> + int32_t cur_pos_x, cur_pos_y;<br>
> +<br>
> + weston_surface_to_global(surface, 0, 0, &surface_x, &surface_y);<br>
> +<br>
> + cur_pos_x = surface_x + x;<br>
> + cur_pos_y = surface_y + y;<br>
<br>
</div></div>This should just be<br>
<br>
weston_surface_to_global(surface, x, y, &surface_x, &surface_y);<br>
<br>
weston_surface_to_global() takes a coordinate in surface space (which<br>
x, y is) and translates that into global space.<br></blockquote><div><br>Please see v3 of this patch. v2 does not handle transformed surfaces correctly.<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><br>
> + wl_list_for_each(output, &surface->compositor->output_list, link)<br>
> + if (output->zoom.active &&<br>
> + pixman_region32_contains_point(&output->region,<br>
> + cur_pos_x, cur_pos_y, NULL))<br>
> + weston_output_update_zoom(output, cur_pos_x * 256, cur_pos_y * 256);<br>
<br>
</div>Use wl_fixed_from_int here. Alternatively, just make the protocol<br>
take wl_fixed_t for x and y (and change the client to send wl_fixed_t<br>
x and y), and then use weston_surface_to_global_fixed().<br></blockquote><div><br>Ah, I did not realize this function exists.<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><br>
> +}<br>
> +<br>
> +WL_EXPORT void<br>
> weston_output_update_zoom(struct weston_output *output, wl_fixed_t fx, wl_fixed_t fy)<br>
> {<br>
> float ratio;<br>
> @@ -2641,6 +2661,7 @@ weston_compositor_init(struct weston_compositor *ec, struct wl_display *display)<br>
> weston_layer_init(&ec->cursor_layer, &ec->fade_layer.link);<br>
><br>
> screenshooter_create(ec);<br>
> + text_cursor_position_notifier_create(ec);<br>
><br>
> ec->ping_handler = NULL;<br>
><br>
> diff --git a/src/compositor.h b/src/compositor.h<br>
> index 7af423d..59a97a7 100644<br>
> --- a/src/compositor.h<br>
> +++ b/src/compositor.h<br>
> @@ -554,6 +554,8 @@ weston_compositor_shutdown(struct weston_compositor *ec);<br>
> void<br>
> weston_output_update_zoom(struct weston_output *output, int x, int y);<br>
> void<br>
> +weston_text_cursor_position_notify(struct weston_surface *surface, int x, int y);<br>
> +void<br>
> weston_output_update_matrix(struct weston_output *output);<br>
> void<br>
> weston_output_move(struct weston_output *output, int x, int y);<br>
> @@ -589,6 +591,9 @@ tty_activate_vt(struct tty *tty, int vt);<br>
> void<br>
> screenshooter_create(struct weston_compositor *ec);<br>
><br>
> +void<br>
> +text_cursor_position_notifier_create(struct weston_compositor *ec);<br>
> +<br>
> struct weston_process;<br>
> typedef void (*weston_process_cleanup_func_t)(struct weston_process *process,<br>
> int status);<br>
> diff --git a/src/text-cursor-position.c b/src/text-cursor-position.c<br>
> new file mode 100644<br>
> index 0000000..2c07dca<br>
> --- /dev/null<br>
> +++ b/src/text-cursor-position.c<br>
> @@ -0,0 +1,86 @@<br>
> +/*<br>
> + * Copyright © 2012 Scott Moreau<br>
> + *<br>
> + * Permission to use, copy, modify, distribute, and sell this software and<br>
> + * its documentation for any purpose is hereby granted without fee, provided<br>
> + * that the above copyright notice appear in all copies and that both that<br>
> + * copyright notice and this permission notice appear in supporting<br>
> + * documentation, and that the name of the copyright holders not be used in<br>
> + * advertising or publicity pertaining to distribution of the software<br>
> + * without specific, written prior permission. The copyright holders make<br>
> + * no representations about the suitability of this software for any<br>
> + * purpose. It is provided "as is" without express or implied warranty.<br>
> + *<br>
> + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS<br>
> + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND<br>
> + * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY<br>
> + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER<br>
> + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF<br>
> + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN<br>
> + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.<br>
> + */<br>
> +<br>
> +#include <stdlib.h><br>
> +<br>
> +#include "compositor.h"<br>
> +#include "text-cursor-position-server-protocol.h"<br>
> +<br>
> +struct text_cursor_position {<br>
> + struct wl_object base;<br>
> + struct weston_compositor *ec;<br>
> + struct wl_global *global;<br>
> + struct wl_listener destroy_listener;<br>
> +};<br>
> +<br>
> +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>
> +{<br>
> + weston_text_cursor_position_notify((struct weston_surface *) surface_resource, x, y);<br>
> +}<br>
> +<br>
> +struct text_cursor_position_interface text_cursor_position_implementation = {<br>
> + text_cursor_position_notify<br>
> +};<br>
> +<br>
> +static void<br>
> +bind_text_cursor_position(struct wl_client *client,<br>
> + void *data, uint32_t version, uint32_t id)<br>
> +{<br>
> + wl_client_add_object(client, &text_cursor_position_interface,<br>
> + &text_cursor_position_implementation, id, data);<br>
> +}<br>
> +<br>
> +static void<br>
> +text_cursor_position_notifier_destroy(struct wl_listener *listener, void *data)<br>
> +{<br>
> + struct text_cursor_position *text_cursor_position =<br>
> + container_of(listener, struct text_cursor_position, destroy_listener);<br>
> +<br>
> + wl_display_remove_global(text_cursor_position->ec->wl_display, text_cursor_position->global);<br>
> + free(text_cursor_position);<br>
> +}<br>
> +<br>
> +void<br>
> +text_cursor_position_notifier_create(struct weston_compositor *ec)<br>
> +{<br>
> + struct text_cursor_position *text_cursor_position;<br>
> +<br>
> + text_cursor_position = malloc(sizeof *text_cursor_position);<br>
> + if (text_cursor_position == NULL)<br>
> + return;<br>
> +<br>
> + text_cursor_position->base.interface = &text_cursor_position_interface;<br>
> + text_cursor_position->base.implementation =<br>
> + (void(**)(void)) &text_cursor_position_implementation;<br>
> + text_cursor_position->ec = ec;<br>
> +<br>
> + text_cursor_position->global = wl_display_add_global(ec->wl_display,<br>
> + &text_cursor_position_interface,<br>
> + text_cursor_position, bind_text_cursor_position);<br>
> +<br>
> + text_cursor_position->destroy_listener.notify = text_cursor_position_notifier_destroy;<br>
> + wl_signal_add(&ec->destroy_signal, &text_cursor_position->destroy_listener);<br>
> +}<br><br></div></div></blockquote><div> </div><div>Please see v3 of this patch.<br><br><br>Scott <br></div></div><br>