[PATCH 09/17] shell: Factor out code to set a shsurf’s parent

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


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

This is in preparation for unifying how surface layering works. It
introduces the small functional change that fullscreen, maximized and
top-level surfaces now explicitly have no parent surface. Only popup and
transient surfaces have a non-NULL parent.
---
 src/shell.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/src/shell.c b/src/shell.c
index 9d6a7c2..3ff395d 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -2038,6 +2038,13 @@ get_output_panel_height(struct desktop_shell *shell,
 }
 
 static void
+shell_surface_set_parent(struct shell_surface *shsurf,
+                         struct weston_surface *parent)
+{
+	shsurf->parent = parent;
+}
+
+static void
 shell_surface_set_output(struct shell_surface *shsurf,
                          struct weston_output *output)
 {
@@ -2056,6 +2063,8 @@ shell_surface_set_output(struct shell_surface *shsurf,
 static void
 set_toplevel(struct shell_surface *shsurf)
 {
+	shell_surface_set_parent(shsurf, NULL);
+
 	shsurf->next_type = SHELL_SURFACE_TOPLEVEL;
 }
 
@@ -2072,11 +2081,14 @@ static void
 set_transient(struct shell_surface *shsurf,
 	      struct weston_surface *parent, int x, int y, uint32_t flags)
 {
-	/* assign to parents output */
-	shsurf->parent = parent;
+	assert(parent != NULL);
+
 	shsurf->transient.x = x;
 	shsurf->transient.y = y;
 	shsurf->transient.flags = flags;
+
+	shell_surface_set_parent(shsurf, parent);
+
 	shsurf->next_type = SHELL_SURFACE_TRANSIENT;
 }
 
@@ -2104,6 +2116,9 @@ set_fullscreen(struct shell_surface *shsurf,
 	shsurf->fullscreen_output = shsurf->output;
 	shsurf->fullscreen.type = method;
 	shsurf->fullscreen.framerate = framerate;
+
+	shell_surface_set_parent(shsurf, NULL);
+
 	shsurf->next_type = SHELL_SURFACE_FULLSCREEN;
 
 	shsurf->client->send_configure(shsurf->surface, 0,
@@ -2172,12 +2187,15 @@ set_popup(struct shell_surface *shsurf,
           int32_t x,
           int32_t y)
 {
+	assert(parent != NULL);
+
 	shsurf->type = SHELL_SURFACE_POPUP;
-	shsurf->parent = parent;
 	shsurf->popup.shseat = get_shell_seat(seat);
 	shsurf->popup.serial = serial;
 	shsurf->popup.x = x;
 	shsurf->popup.y = y;
+
+	shell_surface_set_parent(shsurf, parent);
 }
 
 static void
@@ -2213,6 +2231,8 @@ set_maximized(struct shell_surface *shsurf,
 	                               shsurf->output->width,
 	                               shsurf->output->height - panel_height);
 
+	shell_surface_set_parent(shsurf, NULL);
+
 	shsurf->next_type = SHELL_SURFACE_MAXIMIZED;
 }
 
@@ -2508,6 +2528,9 @@ set_xwayland(struct shell_surface *shsurf, int x, int y, uint32_t flags)
 	shsurf->transient.x = x;
 	shsurf->transient.y = y;
 	shsurf->transient.flags = flags;
+
+	shell_surface_set_parent(shsurf, NULL);
+
 	shsurf->next_type = SHELL_SURFACE_XWAYLAND;
 }
 
-- 
1.8.3.1



More information about the wayland-devel mailing list