[PATCH 11/17] shell: Factor out code to set the layer for a shsurf
Philip Withnall
philip at tecnocode.co.uk
Mon Nov 25 10:01:40 PST 2013
From: Philip Withnall <philip.withnall at collabora.co.uk>
This will be used more extensively in the next few commits, where shsurf
layering is handled more explicitly when changing the type of a surface.
This commit introduces the minor functional change that map() will now
always add the new surface to a layer list, as
shell_surface_calculate_layer_link() always returns a non-NULL link
element. This affects fullscreen and ‘none’ surfaces (which are now added
to the fullscreen and current workspace’s layer list, respectively).
---
src/shell.c | 78 ++++++++++++++++++++++++++++++++++++++++---------------------
1 file changed, 52 insertions(+), 26 deletions(-)
diff --git a/src/shell.c b/src/shell.c
index c503d4b..084d02c 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -2037,6 +2037,49 @@ get_output_panel_height(struct desktop_shell *shell,
return panel_height;
}
+/* The surface will be inserted into the list immediately after the link
+ * returned by this function (i.e. will be stacked immediately above the
+ * returned link). */
+static struct wl_list *
+shell_surface_calculate_layer_link (struct shell_surface *shsurf)
+{
+ struct workspace *ws;
+
+ switch (shsurf->type) {
+ case SHELL_SURFACE_POPUP:
+ 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. */
+ struct weston_view *parent;
+
+ /* TODO: Handle a parent with multiple views */
+ parent = get_default_view(shsurf->parent);
+ if (parent)
+ return parent->layer_link.prev;
+
+ break;
+ }
+
+ case SHELL_SURFACE_FULLSCREEN:
+ return &shsurf->shell->fullscreen_layer.view_list;
+
+ case SHELL_SURFACE_XWAYLAND:
+ case SHELL_SURFACE_TOPLEVEL:
+ case SHELL_SURFACE_MAXIMIZED:
+ case SHELL_SURFACE_NONE:
+ default:
+ /* Go to the fallback, below. */
+ break;
+ }
+
+ /* Move the surface to a normal workspace layer so that surfaces
+ * which were previously fullscreen or transient are no longer
+ * rendered on top. */
+ ws = get_current_workspace(shsurf->shell);
+ return &ws->layer.view_list;
+}
+
static void
shell_surface_set_parent(struct shell_surface *shsurf,
struct weston_surface *parent)
@@ -4308,11 +4351,10 @@ map(struct desktop_shell *shell, struct shell_surface *shsurf,
int32_t width, int32_t height, int32_t sx, int32_t sy)
{
struct weston_compositor *compositor = shell->compositor;
- struct weston_view *parent;
struct weston_seat *seat;
- struct workspace *ws;
int panel_height = 0;
int32_t surf_x, surf_y;
+ struct wl_list *new_layer_link;
shsurf->view->geometry.width = width;
shsurf->view->geometry.height = height;
@@ -4350,30 +4392,14 @@ 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);
- }
- break;
- case SHELL_SURFACE_FULLSCREEN:
- case SHELL_SURFACE_NONE:
- break;
- case SHELL_SURFACE_XWAYLAND:
- case SHELL_SURFACE_TOPLEVEL:
- case SHELL_SURFACE_MAXIMIZED:
- default:
- ws = get_current_workspace(shell);
- wl_list_remove(&shsurf->view->layer_link);
- wl_list_insert(&ws->layer.view_list, &shsurf->view->layer_link);
- break;
- }
+ /* Surface stacking order, see also activate().
+ *
+ * If any child surfaces exist and are mapped, ensure they’re in the
+ * same layer as this surface. */
+ new_layer_link = shell_surface_calculate_layer_link(shsurf);
+ wl_list_remove(&shsurf->view->layer_link);
+ wl_list_insert(new_layer_link,
+ &shsurf->view->layer_link);
if (shsurf->type != SHELL_SURFACE_NONE) {
weston_view_update_transform(shsurf->view);
--
1.8.3.1
More information about the wayland-devel
mailing list