[PATCH 2/2] shell.c: restore maximized and fullscreen window on destroyed output

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


When maximized or fullscreen window is on destroyed output, compositor
can't change these windows to normal window without notify client,
otherwise maximize or F11 buttion lose its effect after output unplug.

Instead we keep these window as maximized or fullscreen, just change
it's size to target output.

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

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 9ecd15a..c5d722a 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -2307,7 +2307,8 @@ set_fullscreen(struct shell_surface *shsurf,
 	shsurf->type = SHELL_SURFACE_TOPLEVEL;
 
 	/* Save shsurf's gemometry and size.*/
-	set_full_output(shsurf);
+	if (!shsurf->saved_size_valid)
+		set_full_output(shsurf);
 
 	shsurf->client->send_configure(shsurf->surface, 0,
 				       shsurf->output->width,
@@ -2430,7 +2431,8 @@ set_maximized(struct shell_surface *shsurf,
 	shsurf->type = SHELL_SURFACE_TOPLEVEL;
 
 	/* Save shsurf's geometry and size.*/
-	set_full_output(shsurf);
+	if (!shsurf->saved_size_valid)
+		set_full_output(shsurf);
 
 	shell = shell_surface_get_shell(shsurf);
 	panel_height = get_output_panel_height(shell, shsurf->output);
@@ -5529,6 +5531,8 @@ shell_reposition_view_on_output_destroy(struct weston_view *view)
 
 		x = first_output->x + first_output->width / 4;
 		y = first_output->y + first_output->height / 4;
+
+		output = first_output;
 	}
 
 	weston_view_set_position(view, x, y);
@@ -5537,9 +5541,23 @@ shell_reposition_view_on_output_destroy(struct weston_view *view)
 
 	if (shsurf) {
 		shsurf->saved_position_valid = false;
-		shsurf->next_state.maximized = false;
-		shsurf->next_state.fullscreen = false;
-		shsurf->state_changed = true;
+
+		/* Resize maxmized window to target output. */
+		if (shsurf->state.maximized)
+			set_maximized(shsurf, output);
+
+		/* Resize fullscreen window to target output. */
+		if (shsurf->state.fullscreen) {
+			weston_surface_destroy(shsurf->fullscreen.black_view->surface);
+			shsurf->fullscreen.black_view = NULL;
+
+			set_fullscreen(shsurf,
+				       shsurf->fullscreen.type,
+				       shsurf->fullscreen.framerate,
+				       output);
+		}
+
+		shsurf->state_changed = false;
 	}
 }
 
-- 
1.8.3.2



More information about the wayland-devel mailing list