[PATCH 06/17] shell: Factor out common code to set a shsurf’s output

Philip Withnall philip at tecnocode.co.uk
Mon Nov 25 10:01:35 PST 2013


From: Philip Withnall <philip.withnall at collabora.co.uk>

---
 src/shell.c | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/src/shell.c b/src/shell.c
index 17a64ae..15895e2 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -2031,6 +2031,22 @@ get_output_panel_height(struct desktop_shell *shell,
 }
 
 static void
+shell_surface_set_output(struct shell_surface *shsurf,
+                         struct weston_output *output)
+{
+	struct weston_surface *es = shsurf->surface;
+
+	/* get the default output, if the client set it as NULL
+	   check whether the ouput is available */
+	if (output)
+		shsurf->output = output;
+	else if (es->output)
+		shsurf->output = es->output;
+	else
+		shsurf->output = get_default_output(es->compositor);
+}
+
+static void
 set_toplevel(struct shell_surface *shsurf)
 {
 	shsurf->next_type = SHELL_SURFACE_TOPLEVEL;
@@ -2076,14 +2092,7 @@ set_fullscreen(struct shell_surface *shsurf,
 	       uint32_t framerate,
 	       struct weston_output *output)
 {
-	struct weston_surface *es = shsurf->surface;
-
-	if (output)
-		shsurf->output = output;
-	else if (es->output)
-		shsurf->output = es->output;
-	else
-		shsurf->output = get_default_output(es->compositor);
+	shell_surface_set_output(shsurf, output);
 
 	shsurf->fullscreen_output = shsurf->output;
 	shsurf->fullscreen.type = method;
@@ -2181,16 +2190,8 @@ set_maximized(struct shell_surface *shsurf,
 {
 	struct desktop_shell *shell;
 	uint32_t edges = 0, panel_height = 0;
-	struct weston_surface *es = shsurf->surface;
 
-	/* get the default output, if the client set it as NULL
-	   check whether the ouput is available */
-	if (output)
-		shsurf->output = output;
-	else if (es->output)
-		shsurf->output = es->output;
-	else
-		shsurf->output = get_default_output(es->compositor);
+	shell_surface_set_output(shsurf, output);
 
 	shell = shell_surface_get_shell(shsurf);
 	panel_height = get_output_panel_height(shell, shsurf->output);
-- 
1.8.3.1



More information about the wayland-devel mailing list