[PATCH 17/17] shell: Change stacking order calculation for popup surfaces

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


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

Always put them as the top-most layer in the layer list of their parent.
This ensures that, for example, the popup menu produced by
right-clicking on a surface (which is not currently at the top of the
stacking order in the current workspace) is displayed at the top of the
stacking order.
---
 src/shell.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/src/shell.c b/src/shell.c
index 1af687a..6871bce 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -2094,11 +2094,36 @@ shell_surface_calculate_layer_link (struct shell_surface *shsurf)
 	struct workspace *ws;
 
 	switch (shsurf->type) {
-	case SHELL_SURFACE_POPUP:
+	case SHELL_SURFACE_POPUP: {
+		/* Popups should go at the front of the workspace of their
+		 * parent surface, rather than just in front of the parent. This
+		 * fixes the situation where there are two top-level windows:
+		 *  - Above
+		 *  - Below
+		 * and a pop-up menu is created for 'Below'. We want:
+		 *  - Popup
+		 *  - Above
+		 *  - Below
+		 * not:
+		 *  - Above
+		 *  - Popup
+		 *  - Below
+		 */
+		struct shell_surface *parent_shsurf;
+
+		parent_shsurf = get_shell_surface(shsurf->parent);
+		if (parent_shsurf != NULL)
+			return shell_surface_calculate_layer_link(parent_shsurf);
+
+		break;
+	}
+
 	case SHELL_SURFACE_TRANSIENT: {
 		/* Move the surface to its parent layer so that surfaces which
 		 * are transient for fullscreen surfaces don't get hidden by the
-		 * fullscreen surfaces. */
+		 * fullscreen surfaces. However, unlike popups, transient
+		 * surfaces are stacked in front of their parent but not in
+		 * front of other surfaces of the same type. */
 		struct weston_view *parent;
 
 		/* TODO: Handle a parent with multiple views */
-- 
1.8.3.1



More information about the wayland-devel mailing list