[PATCH 05/16] xdg-shell: Implementing maximized and fullscreen states.

Rafael Antognolli rafael.antognolli at intel.com
Wed Nov 27 09:50:21 PST 2013


---
 src/shell.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 82 insertions(+), 5 deletions(-)

diff --git a/src/shell.c b/src/shell.c
index f775899..6cbb4bd 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -2999,6 +2999,83 @@ xdg_surface_resize(struct wl_client *client, struct wl_resource *resource,
 	common_surface_resize(resource, seat_resource, serial, edges);
 }
 
+static void
+xdg_surface_set_output(struct wl_client *client,
+		       struct wl_resource *resource,
+		       struct wl_resource *output_resource)
+{
+	struct shell_surface *shsurf = wl_resource_get_user_data(resource);
+	struct weston_output *output;
+
+	if (output_resource)
+		output = wl_resource_get_user_data(output_resource);
+	else
+		output = NULL;
+
+	if (!weston_surface_is_mapped(shsurf->surface))
+		shsurf->output = output;
+}
+
+static void
+xdg_surface_set_fullscreen(struct wl_client *client,
+			   struct wl_resource *resource)
+{
+	struct shell_surface *shsurf = wl_resource_get_user_data(resource);
+
+	if (shsurf->type != SHELL_SURFACE_TOPLEVEL)
+		return;
+
+	if (!shsurf->next.fullscreen) {
+		shsurf->next.fullscreen = true;
+		shsurf->state_changed = true;
+		set_fullscreen(shsurf,
+			       WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
+			       0, shsurf->output);
+	}
+}
+
+static void
+xdg_surface_unset_fullscreen(struct wl_client *client,
+			     struct wl_resource *resource)
+{
+	struct shell_surface *shsurf = wl_resource_get_user_data(resource);
+
+	if (shsurf->type != SHELL_SURFACE_TOPLEVEL)
+		return;
+
+	shsurf->next.fullscreen = false;
+	shsurf->state_changed = true;
+}
+
+static void
+xdg_surface_set_maximized(struct wl_client *client,
+			  struct wl_resource *resource)
+{
+	struct shell_surface *shsurf = wl_resource_get_user_data(resource);
+
+	if (shsurf->type != SHELL_SURFACE_TOPLEVEL)
+		return;
+
+	if (!shsurf->next.maximized) {
+		shsurf->next.maximized = true;
+		shsurf->state_changed = true;
+		set_maximized(shsurf, shsurf->output);
+	}
+}
+
+static void
+xdg_surface_unset_maximized(struct wl_client *client,
+			    struct wl_resource *resource)
+{
+	struct shell_surface *shsurf = wl_resource_get_user_data(resource);
+
+	if (shsurf->type != SHELL_SURFACE_TOPLEVEL)
+		return;
+
+	shsurf->next.maximized = false;
+	shsurf->state_changed = true;
+}
+
 static const struct xdg_surface_interface xdg_surface_implementation = {
 	xdg_surface_destroy,
 	NULL, // set_transient_for
@@ -3007,11 +3084,11 @@ static const struct xdg_surface_interface xdg_surface_implementation = {
 	xdg_surface_pong,
 	xdg_surface_move,
 	xdg_surface_resize,
-	NULL, // set_output
-	NULL, // set_fullscreen
-	NULL, // unset_fullscreen
-	NULL, // set_maximized
-	NULL, // unset_maximized
+	xdg_surface_set_output,
+	xdg_surface_set_fullscreen,
+	xdg_surface_unset_fullscreen,
+	xdg_surface_set_maximized,
+	xdg_surface_unset_maximized,
 	NULL // set_minimized
 };
 
-- 
1.8.3.1



More information about the wayland-devel mailing list