[PATCH 08/16] xdg-shell: Add surface size to configure.

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


Also emit configure on unset_maximized and unset_fullscreen.
---
 src/shell.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/src/shell.c b/src/shell.c
index 0daa136..7040acc 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -267,7 +267,9 @@ struct shell_surface {
 	enum shell_surface_type type, next_type;
 	char *title, *class;
 	int32_t saved_x, saved_y;
+	int32_t saved_width, saved_height;
 	bool saved_position_valid;
+	bool saved_size_valid;
 	bool saved_rotation_valid;
 	int unresponsive, grabbed;
 
@@ -2119,6 +2121,9 @@ set_full_output(struct shell_surface *shsurf)
 {
 	shsurf->saved_x = shsurf->view->geometry.x;
 	shsurf->saved_y = shsurf->view->geometry.y;
+	shsurf->saved_width = shsurf->surface->width;
+	shsurf->saved_height = shsurf->surface->height;
+	shsurf->saved_size_valid = true;
 	shsurf->saved_position_valid = true;
 
 	if (!wl_list_empty(&shsurf->rotation.transform.link)) {
@@ -2893,6 +2898,7 @@ create_common_surface(void *shell, struct weston_surface *surface,
 	shsurf->shell = (struct desktop_shell *) shell;
 	shsurf->unresponsive = 0;
 	shsurf->saved_position_valid = false;
+	shsurf->saved_size_valid = false;
 	shsurf->saved_rotation_valid = false;
 	shsurf->surface = surface;
 	shsurf->fullscreen.type = WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT;
@@ -3090,12 +3096,28 @@ xdg_surface_unset_fullscreen(struct wl_client *client,
 			     struct wl_resource *resource)
 {
 	struct shell_surface *shsurf = wl_resource_get_user_data(resource);
+	int32_t width, height;
 
 	if (shsurf->type != SHELL_SURFACE_TOPLEVEL)
 		return;
 
+	if (!shsurf->next.fullscreen)
+		return;
+
 	shsurf->next.fullscreen = false;
 	shsurf->state_changed = true;
+
+	if (shsurf->saved_size_valid) {
+		width = shsurf->saved_width;
+		height = shsurf->saved_height;
+		shsurf->saved_size_valid = false;
+	} else {
+		width = shsurf->surface->width;
+		height = shsurf->surface->height;
+	}
+
+	shsurf->client->send_configure(shsurf->surface, 0, width, height);
+	shsurf->next_type = shsurf->type;
 }
 
 static void
@@ -3119,12 +3141,28 @@ xdg_surface_unset_maximized(struct wl_client *client,
 			    struct wl_resource *resource)
 {
 	struct shell_surface *shsurf = wl_resource_get_user_data(resource);
+	int32_t width, height;
 
 	if (shsurf->type != SHELL_SURFACE_TOPLEVEL)
 		return;
 
+	if (!shsurf->next.maximized)
+		return;
+
 	shsurf->next.maximized = false;
 	shsurf->state_changed = true;
+
+	if (shsurf->saved_size_valid) {
+		width = shsurf->saved_width;
+		height = shsurf->saved_height;
+		shsurf->saved_size_valid = false;
+	} else {
+		width = shsurf->surface->width;
+		height = shsurf->surface->height;
+	}
+
+	shsurf->client->send_configure(shsurf->surface, 0, width, height);
+	shsurf->next_type = shsurf->type;
 }
 
 static const struct xdg_surface_interface xdg_surface_implementation = {
-- 
1.8.3.1



More information about the wayland-devel mailing list