[PATCH 12/17] shell: Update a shsurf’s layer when its surface type changes
Philip Withnall
philip at tecnocode.co.uk
Mon Nov 25 10:01:41 PST 2013
From: Philip Withnall <philip.withnall at collabora.co.uk>
---
src/shell.c | 47 ++++++++++++++++++++++++++++-------------------
1 file changed, 28 insertions(+), 19 deletions(-)
diff --git a/src/shell.c b/src/shell.c
index 084d02c..25e00d9 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -2080,6 +2080,25 @@ shell_surface_calculate_layer_link (struct shell_surface *shsurf)
return &ws->layer.view_list;
}
+/* Update the surface’s layer. Mark both the old and new views as having dirty
+ * geometry to ensure the changes are redrawn. */
+static void
+shell_surface_update_layer(struct shell_surface *shsurf)
+{
+ struct wl_list *new_layer_link;
+
+ new_layer_link = shell_surface_calculate_layer_link(shsurf);
+
+ if (new_layer_link == &shsurf->view->layer_link)
+ return;
+
+ weston_view_geometry_dirty(shsurf->view);
+ wl_list_remove(&shsurf->view->layer_link);
+ wl_list_insert(new_layer_link, &shsurf->view->layer_link);
+ weston_view_geometry_dirty(shsurf->view);
+ weston_surface_damage(shsurf->surface);
+}
+
static void
shell_surface_set_parent(struct shell_surface *shsurf,
struct weston_surface *parent)
@@ -2172,8 +2191,6 @@ set_fullscreen(struct shell_surface *shsurf,
static void
unset_fullscreen(struct shell_surface *shsurf)
{
- struct workspace *ws;
-
/* Unset the fullscreen output, driver configuration and transforms. */
if (shsurf->fullscreen.type == WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER &&
shell_surface_is_top_fullscreen(shsurf)) {
@@ -2199,9 +2216,7 @@ unset_fullscreen(struct shell_surface *shsurf)
shsurf->saved_rotation_valid = false;
}
- ws = get_current_workspace(shsurf->shell);
- wl_list_remove(&shsurf->view->layer_link);
- wl_list_insert(&ws->layer.view_list, &shsurf->view->layer_link);
+ /* Layer is updated in set_surface_type(). */
}
static void
@@ -2283,8 +2298,6 @@ set_maximized(struct shell_surface *shsurf,
static void
unset_maximized(struct shell_surface *shsurf)
{
- struct workspace *ws;
-
/* undo all maximized things here */
shsurf->output = get_default_output(shsurf->surface->compositor);
weston_view_set_position(shsurf->view,
@@ -2297,9 +2310,7 @@ unset_maximized(struct shell_surface *shsurf)
shsurf->saved_rotation_valid = false;
}
- ws = get_current_workspace(shsurf->shell);
- wl_list_remove(&shsurf->view->layer_link);
- wl_list_insert(&ws->layer.view_list, &shsurf->view->layer_link);
+ /* Layer is updated in set_surface_type(). */
}
static void
@@ -2318,6 +2329,8 @@ shell_surface_set_maximized(struct wl_client *client,
set_maximized(shsurf, output);
}
+/* This is only ever called from set_surface_type(), so there’s no need to
+ * update layer_links here, since they’ll be updated when we return. */
static int
reset_surface_type(struct shell_surface *surface)
{
@@ -2386,6 +2399,9 @@ set_surface_type(struct shell_surface *shsurf)
default:
break;
}
+
+ /* Update the surface’s layer. */
+ shell_surface_update_layer(shsurf);
}
static struct desktop_shell *
@@ -4354,7 +4370,6 @@ map(struct desktop_shell *shell, struct shell_surface *shsurf,
struct weston_seat *seat;
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;
@@ -4392,14 +4407,8 @@ map(struct desktop_shell *shell, struct shell_surface *shsurf,
;
}
- /* 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);
+ /* Surface stacking order, see also activate(). */
+ shell_surface_update_layer(shsurf);
if (shsurf->type != SHELL_SURFACE_NONE) {
weston_view_update_transform(shsurf->view);
--
1.8.3.1
More information about the wayland-devel
mailing list