[PATCH weston 1/2] desktop-shell: refactor maximized size calculation into its own function

Derek Foreman derekf at osg.samsung.com
Fri Oct 6 19:37:44 UTC 2017


We need to calculate maximized size to resolve a bug with unsetting
fullscreen, might as well share the code.

Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
---
 desktop-shell/shell.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 1f99efe3..9e73d4a3 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -2573,6 +2573,19 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
 	}
 }
 
+static void
+get_maximized_size(struct shell_surface *shsurf, int32_t *width, int32_t *height)
+{
+	struct desktop_shell *shell;
+	pixman_rectangle32_t area;
+
+	shell = shell_surface_get_shell(shsurf);
+	get_output_work_area(shell, shsurf->output, &area);
+
+	*width = area.width;
+	*height = area.height;
+}
+
 static void
 set_fullscreen(struct shell_surface *shsurf, bool fullscreen,
 	       struct weston_output *output)
@@ -2678,8 +2691,6 @@ set_maximized(struct shell_surface *shsurf, bool maximized)
 
 	if (maximized) {
 		struct weston_output *output;
-		struct desktop_shell *shell;
-		pixman_rectangle32_t area;
 
 		if (!weston_surface_is_mapped(surface))
 			output = get_focused_output(surface->compositor);
@@ -2688,11 +2699,7 @@ set_maximized(struct shell_surface *shsurf, bool maximized)
 
 		shell_surface_set_output(shsurf, output);
 
-		shell = shell_surface_get_shell(shsurf);
-		get_output_work_area(shell, shsurf->output, &area);
-
-		width = area.width;
-		height = area.height;
+		get_maximized_size(shsurf, &width, &height);
 	}
 	weston_desktop_surface_set_maximized(desktop_surface, maximized);
 	weston_desktop_surface_set_size(desktop_surface, width, height);
-- 
2.14.2



More information about the wayland-devel mailing list