[PATCH 1/2] shell.c: Restore maximized and fullscreen window in xdg_shell correctly

Xiong Zhang xiong.y.zhang at intel.com
Wed Feb 12 23:54:44 PST 2014


Problem: When I open a weston_terminal and maximize it, I can't restore
it to original size.

In xdg_shell implementation, shell depend on shsurf->saved_width
and shsurf->saved_height to restore maximized and fullscreen window
to original size.

But it's too late to save these values in surface->configure(), at
this point surface->width and surface->height have been changed to
maximized and fullscreen buffer size in weston_surface_commit().

This patch change calling set_full_output from set_surface_type to
set_maximized() and set_fullscreen().

Signed-off-by: Xiong Zhang <xiong.y.zhang at intel.com>
---
 desktop-shell/shell.c | 54 +++++++++++++++++++++++++++------------------------
 1 file changed, 29 insertions(+), 25 deletions(-)

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index a73e8e0..9ecd15a 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -2273,6 +2273,24 @@ shell_surface_set_transient(struct wl_client *client,
 }
 
 static void
+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)) {
+		wl_list_remove(&shsurf->rotation.transform.link);
+		wl_list_init(&shsurf->rotation.transform.link);
+		weston_view_geometry_dirty(shsurf->view);
+		shsurf->saved_rotation_valid = true;
+	}
+}
+
+static void
 set_fullscreen(struct shell_surface *shsurf,
 	       uint32_t method,
 	       uint32_t framerate,
@@ -2288,6 +2306,9 @@ set_fullscreen(struct shell_surface *shsurf,
 	shsurf->state_changed = true;
 	shsurf->type = SHELL_SURFACE_TOPLEVEL;
 
+	/* Save shsurf's gemometry and size.*/
+	set_full_output(shsurf);
+
 	shsurf->client->send_configure(shsurf->surface, 0,
 				       shsurf->output->width,
 				       shsurf->output->height);
@@ -2404,6 +2425,13 @@ set_maximized(struct shell_surface *shsurf,
 
 	shell_surface_set_output(shsurf, output);
 
+	shsurf->next_state.maximized = true;
+	shsurf->state_changed = true;
+	shsurf->type = SHELL_SURFACE_TOPLEVEL;
+
+	/* Save shsurf's geometry and size.*/
+	set_full_output(shsurf);
+
 	shell = shell_surface_get_shell(shsurf);
 	panel_height = get_output_panel_height(shell, shsurf->output);
 	edges = WL_SHELL_SURFACE_RESIZE_TOP | WL_SHELL_SURFACE_RESIZE_LEFT;
@@ -2411,10 +2439,6 @@ set_maximized(struct shell_surface *shsurf,
 	shsurf->client->send_configure(shsurf->surface, edges,
 	                               shsurf->output->width,
 	                               shsurf->output->height - panel_height);
-
-	shsurf->next_state.maximized = true;
-	shsurf->state_changed = true;
-	shsurf->type = SHELL_SURFACE_TOPLEVEL;
 }
 
 static void
@@ -2471,24 +2495,6 @@ reset_surface_type(struct shell_surface *surface)
 }
 
 static void
-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)) {
-		wl_list_remove(&shsurf->rotation.transform.link);
-		wl_list_init(&shsurf->rotation.transform.link);
-		weston_view_geometry_dirty(shsurf->view);
-		shsurf->saved_rotation_valid = true;
-	}
-}
-
-static void
 set_surface_type(struct shell_surface *shsurf)
 {
 	struct weston_surface *pes = shsurf->parent;
@@ -2501,9 +2507,7 @@ set_surface_type(struct shell_surface *shsurf)
 
 	switch (shsurf->type) {
 	case SHELL_SURFACE_TOPLEVEL:
-		if (shsurf->state.maximized || shsurf->state.fullscreen) {
-			set_full_output(shsurf);
-		} else if (shsurf->state.relative && pev) {
+		if (shsurf->state.relative && pev) {
 			weston_view_set_position(shsurf->view,
 						 pev->geometry.x + shsurf->transient.x,
 						 pev->geometry.y + shsurf->transient.y);
-- 
1.8.3.2



More information about the wayland-devel mailing list