[PATCH weston v1 08/17] add toytoolkit_client_create

Pekka Paalanen ppaalanen at gmail.com
Fri Dec 12 06:56:17 PST 2014


On Fri,  5 Dec 2014 14:36:41 +0100
Marek Chalupa <mchqwerty at gmail.com> wrote:

> ---
>  tests/weston-test-client-helper.c | 345 ++++++++++++++++++++++++++++++++++++--
>  tests/weston-test-client-helper.h |   3 +
>  2 files changed, 333 insertions(+), 15 deletions(-)
> 
> diff --git a/tests/weston-test-client-helper.c b/tests/weston-test-client-helper.c
> index f4c04eb..ea54c9e 100644
> --- a/tests/weston-test-client-helper.c
> +++ b/tests/weston-test-client-helper.c

> @@ -704,3 +729,293 @@ client_create(int x, int y, int width, int height)
>  
>  	return client;
>  }
> +
> +/*
> + * --- toytoolkit definitions -----------------------------------------
> + */
> +
> +static void
> +toytoolkit_key_handler(struct window *window, struct input *input,
> +		       uint32_t time, uint32_t key, uint32_t unicode,
> +		       enum wl_keyboard_key_state state, void *data)
> +{
> +	struct client *client = data;
> +
> +	store_keyboard_key(client->input->keyboard, key, state);
> +
> +	/* XXX modifiers? */
> +}
> +
> +static void
> +toytoolkit_keyboard_focus_handler(struct window *window,
> +				  struct input *input, void *data)
> +{
> +	struct client *client = data;
> +	struct widget *widget;
> +	struct wl_surface *wl_surface;
> +
> +	if (input) {
> +		widget = input_get_focus_widget(input);
> +		if (!widget)
> +			return;
> +
> +		wl_surface = widget_get_wl_surface(widget);
> +		store_keyboard_enter(client->input->keyboard, wl_surface);
> +	} else {
> +		store_keyboard_leave(client->input->keyboard,
> +				     /* XXX hmm, is this right? */
> +				     window_get_wl_surface(window));

Hmm, that depends whether toytoolkit allows input on sub-surfaces. I
have a vague recollection I left that out, because I didn't bother
adding proper focus handling. This was before xdg-shell though. Looking
at weston-subsurfaces demo, it ensures the input regions of the
sub-surfaces are empty.


> +	}
> +}

...

> +static void
> +toytoolkit_redraw_handler(struct widget *widget, void *data)
> +{
> +	struct client *client = data;
> +	struct rectangle rect;
> +
> +	widget_get_allocation(widget, &rect);
> +	client->surface->width = rect.width;
> +	client->surface->height = rect.height;
> +
> +	/* we must add a decoration size to get the size of
> +	 * server allocated area */
> +	window_get_decoration_size(client->toytoolkit->window,
> +				   &rect.width, &rect.height);
> +	client->surface->width += rect.width;
> +	client->surface->height += rect.height;

How about window_get_allocation() instead?

> +}

Didn't notice anything else to complain about, but also didn't really
carefully read all the code. :-)


Thanks,
pq


More information about the wayland-devel mailing list