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

juan.j.zhao at linux.intel.com juan.j.zhao at linux.intel.com
Fri Feb 3 00:16:17 PST 2012


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)
+{
+	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;
+	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);
+	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
 };
 
-- 
1.7.5.4



More information about the wayland-devel mailing list