[weston PATCH v6 1/2] add implementation for set_maximised

Pekka Paalanen ppaalanen at gmail.com
Fri Feb 3 01:08:59 PST 2012


On Fri,  3 Feb 2012 16:16:17 +0800
juan.j.zhao at linux.intel.com wrote:

> From: Juan Zhao <juan.j.zhao at linux.intel.com>
> 
> ---
>  src/shell.c |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 53 insertions(+), 0 deletions(-)
> 
> diff --git a/src/shell.c b/src/shell.c
> index d15c8e2..48f1ceb 100644
> --- a/src/shell.c
> +++ b/src/shell.c
> @@ -417,6 +417,58 @@ get_default_output(struct weston_compositor *compositor)
>  	return container_of(compositor->output_list.next,
>  			    struct weston_output, link);
>  }
> +static struct wl_shell *
> +shell_surface_get_shell(struct shell_surface *shsurf)
> +{
> +	struct weston_surface *es = shsurf->surface;
> +	struct weston_shell *shell=es->compositor->shell;
> +
> +	return (struct wl_shell *)container_of(shell, struct wl_shell, shell);
> +}
> +
> +static void
> +shell_surface_set_maximised(struct wl_client *client,
> +			    struct wl_resource *resource)

Ah, I forgot in the reply to the protocol bits. Krh said something
about wanting the output as a parameter here, explicitly set by the
client. There was some scheme about letting clients know which output
currently has their surfaces...

> +{
> +	struct shell_surface *shsurf = resource->data;
> +	struct weston_surface *es = shsurf->surface;
> +	struct weston_output *output = NULL;
> +	struct wl_shell *wlshell = NULL;
> +	uint32_t edges = 0, panel_height = 0;
> +	struct shell_surface *priv;
> +
> +	if (reset_shell_surface_type(shsurf))
> +		return;
> +
> +	/* FIXME: set maximised on first output */
> +	/* FIXME: Handle output going away */
> +	output = get_default_output(es->compositor);
> +	es->output = output;
> +
> +	shsurf->saved_x = es->geometry.x;
> +	shsurf->saved_y = es->geometry.y;
> +
> +	wlshell = shell_surface_get_shell(shsurf);
> +	wl_list_for_each(priv, &wlshell->panels, link) {
> +		if (priv->output == es->output) {
> +			panel_height = priv->surface->geometry.height;
> +			break;
> +		}
> +	}
> +
> +	es->geometry.x = 0;
> +	es->geometry.y = panel_height;

If you change anything in geometry, you must set geometry.dirty = 1.

But, I don't think we can change it here directly. This change will
affect the very next redraw, which might be before the client has
reacted to the configure event, and we end up rendering intermediate
state (position set, but old buffer).

Maybe all you need to do here is to send the event and set a flag in
struct shell_surface, and then carry out the actual procedure during
shell->map() and shell->configure() time.

Hmm, the window type could be all the flag we need...

> +	edges = WL_SHELL_SURFACE_RESIZE_TOP|WL_SHELL_SURFACE_RESIZE_LEFT;
> +
> +	fprintf(stderr, "configure: width=%d, height=%d",
> +		output->current->width,
> +		output->current->height-panel_height);

Should drop this printf, we see the same info in the protocol dump
anyway.

> +	wl_resource_post_event(&shsurf->resource,
> +			       WL_SHELL_SURFACE_CONFIGURE,
> +			       weston_compositor_get_time(), edges,
> +			       output->current->width, output->current->height-panel_height);
> +	weston_surface_damage(es);
> +}
>  
>  static void
>  shell_surface_set_fullscreen(struct wl_client *client,
> @@ -557,6 +609,7 @@ static const struct wl_shell_surface_interface shell_surface_implementation = {
>  	shell_surface_set_toplevel,
>  	shell_surface_set_transient,
>  	shell_surface_set_fullscreen,
> +	shell_surface_set_maximised,
>  	shell_surface_set_popup
>  };
>  

Thanks,
pq


More information about the wayland-devel mailing list