[PATCH 06/16] xdg-shell: Implement set_transient_for request.

Rafael Antognolli rafael.antognolli at intel.com
Wed Nov 27 09:50:22 PST 2013


The implementation just sets a parent/child relationship between the
xdg_surface and its parent, passed as argument of this request. Stacking
might be affected (that's up to the compositor).

This implementation does not affect the code that handles the previous
transient surface type. It should still work as expected, but it's not
possible to set that surface type to a xdg_surface.
---
 src/shell.c | 50 +++++++++++++++++++++++++++++---------------------
 1 file changed, 29 insertions(+), 21 deletions(-)

diff --git a/src/shell.c b/src/shell.c
index 6cbb4bd..98fb0fe 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -2955,6 +2955,18 @@ xdg_surface_destroy(struct wl_client *client,
 }
 
 static void
+xdg_surface_set_transient_for(struct wl_client *client,
+			      struct wl_resource *resource,
+			      struct wl_resource *parent_resource)
+{
+	struct shell_surface *shsurf = wl_resource_get_user_data(resource);
+	struct weston_surface *parent =
+		wl_resource_get_user_data(parent_resource);
+
+	shsurf->parent = parent;
+}
+
+static void
 xdg_surface_pong(struct wl_client *client,
 		 struct wl_resource *resource,
 		 uint32_t serial)
@@ -3078,7 +3090,7 @@ xdg_surface_unset_maximized(struct wl_client *client,
 
 static const struct xdg_surface_interface xdg_surface_implementation = {
 	xdg_surface_destroy,
-	NULL, // set_transient_for
+	xdg_surface_set_transient_for,
 	xdg_surface_set_title,
 	xdg_surface_set_app_id,
 	xdg_surface_pong,
@@ -4567,27 +4579,23 @@ map(struct desktop_shell *shell, struct shell_surface *shsurf,
 	}
 
 	/* surface stacking order, see also activate() */
-	switch (shsurf->type) {
-	case SHELL_SURFACE_POPUP:
-	case SHELL_SURFACE_TRANSIENT:
-		/* TODO: Handle a parent with multiple views */
-		parent = get_default_view(shsurf->parent);
-		if (parent) {
-			wl_list_remove(&shsurf->view->layer_link);
-			wl_list_insert(parent->layer_link.prev,
-				       &shsurf->view->layer_link);
+	if (shsurf->type != SHELL_SURFACE_NONE) {
+		if (shsurf->parent) {
+			/* TODO: Handle a parent with multiple views */
+			parent = get_default_view(shsurf->parent);
+			if (parent) {
+				wl_list_remove(&shsurf->view->layer_link);
+				wl_list_insert(parent->layer_link.prev,
+					       &shsurf->view->layer_link);
+			}
+		} else {
+			if (!shsurf->cur.fullscreen) {
+				ws = get_current_workspace(shell);
+				wl_list_remove(&shsurf->view->layer_link);
+				wl_list_insert(&ws->layer.view_list,
+					       &shsurf->view->layer_link);
+			}
 		}
-		break;
-	case SHELL_SURFACE_NONE:
-		break;
-	case SHELL_SURFACE_XWAYLAND:
-	default:
-		if (shsurf->cur.fullscreen)
-			break;
-		ws = get_current_workspace(shell);
-		wl_list_remove(&shsurf->view->layer_link);
-		wl_list_insert(&ws->layer.view_list, &shsurf->view->layer_link);
-		break;
 	}
 
 	if (shsurf->type != SHELL_SURFACE_NONE) {
-- 
1.8.3.1



More information about the wayland-devel mailing list