[weston PATCH v9 1/2] add the set_maximised implementation
Pekka Paalanen
ppaalanen at gmail.com
Thu Feb 9 04:09:21 PST 2012
On Thu, 9 Feb 2012 10:09:30 +0800
juan.j.zhao at linux.intel.com wrote:
> From: Juan Zhao <juan.j.zhao at linux.intel.com>
>
> ---
> src/shell.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 files changed, 88 insertions(+), 1 deletions(-)
>
> diff --git a/src/shell.c b/src/shell.c
> index 53b192c..229a027 100644
> --- a/src/shell.c
> +++ b/src/shell.c
> @@ -81,6 +81,7 @@ enum shell_surface_type {
> SHELL_SURFACE_TOPLEVEL,
> SHELL_SURFACE_TRANSIENT,
> SHELL_SURFACE_FULLSCREEN,
> + SHELL_SURFACE_MAXIMISED,
> SHELL_SURFACE_POPUP
> };
>
> @@ -351,6 +352,13 @@ reset_shell_surface_type(struct shell_surface *surface)
> surface->surface->geometry.dirty = 1;
> surface->surface->fullscreen_output = NULL;
> break;
> + case SHELL_SURFACE_MAXIMISED:
> + weston_surface_configure(surface->surface,
> + surface->saved_x,
> + surface->saved_y,
> + surface->surface->geometry.width,
> + surface->surface->geometry.height);
> + break;
> case SHELL_SURFACE_PANEL:
> case SHELL_SURFACE_BACKGROUND:
> wl_list_remove(&surface->link);
> @@ -419,10 +427,74 @@ get_default_output(struct weston_compositor *compositor)
> 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;
Missing spaces around equals.
> +
> + return (struct wl_shell *)container_of(shell, struct wl_shell, shell);
> +}
> +
> +static int
> +get_output_panel_height(struct wl_shell *wlshell,struct weston_output *output)
> +{
> + struct shell_surface *priv;
> + int panel_height = 0;
> +
> + if(!output)
Missing space: if (!output)
> + return 0;
> +
> + wl_list_for_each(priv, &wlshell->panels, link) {
> + if (priv->output == output) {
> + panel_height = priv->surface->geometry.height;
> + break;
> + }
> + }
> + return panel_height;
> +}
> +
> +static void
> +shell_surface_set_maximised(struct wl_client *client,
> + struct wl_resource *resource,
> + struct wl_resource *output_resource )
> +{
> + struct shell_surface *shsurf = resource->data;
> + struct weston_surface *es = shsurf->surface;
> + struct weston_output *output = output_resource?output_resource->data:NULL;
> + struct wl_shell *wlshell = NULL;
> + uint32_t edges = 0, panel_height = 0;
> +
> + /* get the default output, if the client set it as NULL
> + check whether the ouput is available */
> + es->output = output?output:get_default_output(es->compositor);
Maybe it'd be clearer to just write
if (output_resource)
shsurf->output = output_resource->data;
else
shsurf->output = get_default_output(es->compositor);
Note that I am using shell_surface::output, since we shouldn't change
weston_surface::output until the geometry is changed, too.
> + if(!es->output) {
> + fprintf(stderr, "Please provide correct output, \
> + or setting that output to NULL");
> + return;
> + }
The action under that condition is wrong. The condition really means
"the compositor has no outputs at all". I don't know what could be
done in that case.
Depending on how we interpret the protocol definition, not sending the
configure event is not an option. A client may be explicitly waiting
for the configure event as a reply to set_maximised. I guess in the
case of no outputs, it does not matter what you send, as long as you
send the configure event with some legal values.
> +
> + if (reset_shell_surface_type(shsurf))
> + return;
This is ok, because a failing reset_shell_surface_type() will send an
error to client.
> +
> + shsurf->saved_x = es->geometry.x;
> + shsurf->saved_y = es->geometry.y;
> +
> + wlshell = shell_surface_get_shell(shsurf);
> + panel_height = get_output_panel_height(wlshell, es->output);
> + edges = WL_SHELL_SURFACE_RESIZE_TOP|WL_SHELL_SURFACE_RESIZE_LEFT;
> + wl_resource_post_event(&shsurf->resource,
> + WL_SHELL_SURFACE_CONFIGURE,
> + weston_compositor_get_time(), edges,
> + es->output->current->width, es->output->current->height-panel_height);
Spaces missing abour minus.
> +
> + shsurf->type = SHELL_SURFACE_MAXIMISED;
> +}
> +
> static void
> shell_surface_set_fullscreen(struct wl_client *client,
> struct wl_resource *resource)
> -
> {
> struct shell_surface *shsurf = resource->data;
> struct weston_surface *es = shsurf->surface;
> @@ -572,6 +644,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
> };
>
> @@ -1292,6 +1365,7 @@ map(struct weston_shell *base,
> struct shell_surface *shsurf;
> enum shell_surface_type surface_type = SHELL_SURFACE_NONE;
> int do_configure;
> + int panel_height = 0;
>
> shsurf = get_shell_surface(surface);
> if (shsurf)
> @@ -1320,6 +1394,13 @@ map(struct weston_shell *base,
> case SHELL_SURFACE_FULLSCREEN:
> center_on_output(surface, surface->fullscreen_output);
> break;
> + case SHELL_SURFACE_MAXIMISED:
> + /*use surface configure to set the geometry*/
> + panel_height = get_output_panel_height(shell,surface->output);
> + weston_surface_configure(surface, surface->output->x,
> + surface->output->y + panel_height,
> + width, height);
> + break;
> case SHELL_SURFACE_LOCK:
> center_on_output(surface, get_default_output(compositor));
> break;
> @@ -1396,6 +1477,7 @@ map(struct weston_shell *base,
> case SHELL_SURFACE_TOPLEVEL:
> case SHELL_SURFACE_TRANSIENT:
> case SHELL_SURFACE_FULLSCREEN:
> + case SHELL_SURFACE_MAXIMISED:
> if (!shell->locked)
> activate(base, surface,
> (struct weston_input_device *)
> @@ -1434,6 +1516,11 @@ configure(struct weston_shell *base, struct weston_surface *surface,
> case SHELL_SURFACE_FULLSCREEN:
> center_on_output(surface, surface->fullscreen_output);
> break;
> + case SHELL_SURFACE_MAXIMISED:
> + /*setting x, y and using configure to change that geometry*/
> + x = surface->output->x;
> + y = surface->output->y+get_output_panel_height(shell,surface->output);
Spaces missing around plus and after comma.
> + break;
> default:
> break;
> }
Thanks,
pq
More information about the wayland-devel
mailing list