From: Philip Withnall <philip.withn...@collabora.co.uk>

It’s tied too deeply into the shell’s window stacking and ordering code
to legitimately be split out into compositor.c. Inline it in the shell,
and refactor some code around it a little, tidying up the stacking
behaviour for fullscreen surfaces.
---
 src/compositor.c |  9 ---------
 src/compositor.h |  3 ---
 src/shell.c      | 31 ++++++++++++++++++++++---------
 3 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index cfcb273..042c0ef 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1432,15 +1432,6 @@ weston_surface_attach(struct weston_surface *surface,
 }
 
 WL_EXPORT void
-weston_view_restack(struct weston_view *view, struct wl_list *below)
-{
-       wl_list_remove(&view->layer_link);
-       wl_list_insert(below, &view->layer_link);
-       weston_view_damage_below(view);
-       weston_surface_damage(view->surface);
-}
-
-WL_EXPORT void
 weston_compositor_damage_all(struct weston_compositor *compositor)
 {
        struct weston_output *output;
diff --git a/src/compositor.h b/src/compositor.h
index 526f3d1..b6616a5 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -1123,9 +1123,6 @@ weston_view_configure(struct weston_view *view,
                      float x, float y, int width, int height);
 
 void
-weston_view_restack(struct weston_view *surface, struct wl_list *below);
-
-void
 weston_view_set_position(struct weston_view *view,
                         float x, float y);
 
diff --git a/src/shell.c b/src/shell.c
index 25e00d9..96bfea0 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -3693,7 +3693,12 @@ alt_tab_binding(struct weston_seat *seat, uint32_t time, 
uint32_t key,
 
                preview->view = v = weston_view_create(view->surface);
                v->output = view->output;
-               weston_view_restack(v, &ws->layer.view_list);
+
+               wl_list_remove(&v->layer_link);
+               wl_list_insert(&ws->layer.view_list, &v->layer_link);
+               weston_view_damage_below(v);
+               weston_surface_damage(v->surface);
+
                weston_view_configure(v, x, y, view->geometry.width, 
view->geometry.height);
 
                preview->listener.notify = alt_tab_handle_surface_destroy;
@@ -3885,6 +3890,9 @@ rotate_binding(struct weston_seat *seat, uint32_t time, 
uint32_t button,
        surface_rotate(surface, seat);
 }
 
+/* Move all fullscreen layers down to the current workspace in a non-reversible
+ * manner. This should be used when implementing shell-wide overlays, such as
+ * the alt-tab switcher, which need to de-promote fullscreen layers. */
 static void
 lower_fullscreen_layer(struct desktop_shell *shell)
 {
@@ -3894,8 +3902,12 @@ lower_fullscreen_layer(struct desktop_shell *shell)
        ws = get_current_workspace(shell);
        wl_list_for_each_reverse_safe(view, prev,
                                      &shell->fullscreen_layer.view_list,
-                                     layer_link)
-               weston_view_restack(view, &ws->layer.view_list);
+                                     layer_link) {
+               wl_list_remove(&view->layer_link);
+               wl_list_insert(&ws->layer.view_list, &view->layer_link);
+               weston_view_damage_below(view);
+               weston_surface_damage(view->surface);
+       }
 }
 
 static void
@@ -3903,7 +3915,6 @@ activate(struct desktop_shell *shell, struct 
weston_surface *es,
         struct weston_seat *seat)
 {
        struct weston_surface *main_surface;
-       struct weston_view *main_view;
        struct focus_state *state;
        struct workspace *ws;
        struct weston_surface *old_es;
@@ -3935,15 +3946,17 @@ activate(struct desktop_shell *shell, struct 
weston_surface *es,
        case SHELL_SURFACE_NONE:
        default:
                restore_all_output_modes(shell->compositor);
-               ws = get_current_workspace(shell);
-               main_view = get_default_view(main_surface);
-               if (main_view)
-                       weston_view_restack(main_view, &ws->layer.view_list);
                break;
        }
 
-       if (shell->focus_animation_type != ANIMATION_NONE)
+       if (shell->focus_animation_type != ANIMATION_NONE) {
+               ws = get_current_workspace(shell);
                animate_focus_change(shell, ws, get_default_view(old_es), 
get_default_view(es));
+       }
+
+       /* Update the surface’s layer. This brings it to the top of the stacking
+        * order as appropriate. */
+       shell_surface_update_layer(get_shell_surface(main_surface));
 }
 
 /* no-op func for checking black surface */
-- 
1.8.3.1

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to