<div dir="ltr"><div>I'm not sure what I think about this patch.  I really don't like recreating wl_list and calling it wl_layer_entry just to keep track of the layer pointer.  However, I can't really think of a better solution off-hand.  I'll think on it more and get back to you on Monday.<br>
</div>--Jason Ekstrand<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jul 9, 2014 at 12:12 PM, Giulio Camuffo <span dir="ltr"><<a href="mailto:giuliocamuffo@gmail.com" target="_blank">giuliocamuffo@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This introduces a new struct, weston_layer_entry, which is now used<br>
in place of wl_list to keep the link for the layer list in weston_view<br>
and the head of the list in weston_layer.<br>
weston_layer_entry also has a weston_layer*, which points to the layer<br>
the view is in or, in the case the entry it's the head of the list, to<br>
the layer itself.<br>
---<br>
 desktop-shell/exposay.c     |   4 +-<br>
 desktop-shell/input-panel.c |   7 ++-<br>
 desktop-shell/shell.c       | 145 +++++++++++++++++++++++---------------------<br>
 src/compositor.c            |  33 +++++++---<br>
 src/compositor.h            |  14 ++++-<br>
 src/data-device.c           |   6 +-<br>
 src/input.c                 |   4 +-<br>
 tests/weston-test.c         |   6 +-<br>
 8 files changed, 127 insertions(+), 92 deletions(-)<br>
<br>
diff --git a/desktop-shell/exposay.c b/desktop-shell/exposay.c<br>
index 104b9d9..4b65cbd 100644<br>
--- a/desktop-shell/exposay.c<br>
+++ b/desktop-shell/exposay.c<br>
@@ -219,7 +219,7 @@ exposay_layout(struct desktop_shell *shell, struct shell_output *shell_output)<br>
        int last_row_removed = 0;<br>
<br>
        eoutput->num_surfaces = 0;<br>
-       wl_list_for_each(view, &workspace->layer.view_list, layer_link) {<br>
+       wl_list_for_each(view, &workspace->layer.view_list.link, layer_link.link) {<br>
                if (!get_shell_surface(view->surface))<br>
                        continue;<br>
                if (view->output != output)<br>
@@ -272,7 +272,7 @@ exposay_layout(struct desktop_shell *shell, struct shell_output *shell_output)<br>
                eoutput->surface_size = output->height / 2;<br>
<br>
        i = 0;<br>
-       wl_list_for_each(view, &workspace->layer.view_list, layer_link) {<br>
+       wl_list_for_each(view, &workspace->layer.view_list.link, layer_link.link) {<br>
                int pad;<br>
<br>
                pad = eoutput->surface_size + eoutput->padding_inner;<br>
diff --git a/desktop-shell/input-panel.c b/desktop-shell/input-panel.c<br>
index 7623f6c..47bd73c 100644<br>
--- a/desktop-shell/input-panel.c<br>
+++ b/desktop-shell/input-panel.c<br>
@@ -75,8 +75,8 @@ show_input_panel_surface(struct input_panel_surface *ipsurf)<br>
                weston_view_set_position(ipsurf->view, x, y);<br>
        }<br>
<br>
-       wl_list_insert(&shell->input_panel_layer.view_list,<br>
-                      &ipsurf->view->layer_link);<br>
+       weston_layer_entry_insert(&shell->input_panel_layer.view_list,<br>
+                                 &ipsurf->view->layer_link);<br>
        weston_view_geometry_dirty(ipsurf->view);<br>
        weston_view_update_transform(ipsurf->view);<br>
        weston_surface_damage(ipsurf->surface);<br>
@@ -135,7 +135,8 @@ hide_input_panels(struct wl_listener *listener, void *data)<br>
                wl_list_remove(&shell->input_panel_layer.link);<br>
<br>
        wl_list_for_each_safe(view, next,<br>
-                             &shell->input_panel_layer.view_list, layer_link)<br>
+                             &shell->input_panel_layer.view_list.link,<br>
+                             layer_link.link)<br>
                weston_view_unmap(view);<br>
 }<br>
<br>
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c<br>
index f22cef8..6f6e25c 100644<br>
--- a/desktop-shell/shell.c<br>
+++ b/desktop-shell/shell.c<br>
@@ -279,12 +279,12 @@ shell_surface_is_top_fullscreen(struct shell_surface *shsurf)<br>
<br>
        shell = shell_surface_get_shell(shsurf);<br>
<br>
-       if (wl_list_empty(&shell->fullscreen_layer.view_list))<br>
+       if (wl_list_empty(&shell->fullscreen_layer.view_list.link))<br>
                return false;<br>
<br>
-       top_fs_ev = container_of(shell->fullscreen_layer.view_list.next,<br>
+       top_fs_ev = container_of(shell->fullscreen_layer.view_list.link.next,<br>
                                 struct weston_view,<br>
-                                layer_link);<br>
+                                layer_link.link);<br>
        return (shsurf == get_shell_surface(top_fs_ev->surface));<br>
 }<br>
<br>
@@ -361,7 +361,7 @@ get_output_panel_height(struct desktop_shell *shell,<br>
        if (!output)<br>
                return 0;<br>
<br>
-       wl_list_for_each(view, &shell->panel_layer.view_list, layer_link) {<br>
+       wl_list_for_each(view, &shell->panel_layer.view_list.link, layer_link.link) {<br>
                if (view->surface->output == output) {<br>
                        panel_height = view->surface->height;<br>
                        break;<br>
@@ -675,7 +675,8 @@ focus_state_surface_destroy(struct wl_listener *listener, void *data)<br>
        main_surface = weston_surface_get_main_surface(state->keyboard_focus);<br>
<br>
        next = NULL;<br>
-       wl_list_for_each(view, &state->ws->layer.view_list, layer_link) {<br>
+       wl_list_for_each(view,<br>
+                        &state->ws->layer.view_list.link, layer_link.link) {<br>
                if (view->surface == main_surface)<br>
                        continue;<br>
                if (is_focus_view(view))<br>
@@ -854,8 +855,8 @@ animate_focus_change(struct desktop_shell *shell, struct workspace *ws,<br>
<br>
                focus_surface_created = true;<br>
        } else {<br>
-               wl_list_remove(&ws->fsurf_front->view->layer_link);<br>
-               wl_list_remove(&ws->fsurf_back->view->layer_link);<br>
+               weston_layer_entry_remove(&ws->fsurf_front->view->layer_link);<br>
+               weston_layer_entry_remove(&ws->fsurf_back->view->layer_link);<br>
        }<br>
<br>
        if (ws->focus_animation) {<br>
@@ -864,11 +865,11 @@ animate_focus_change(struct desktop_shell *shell, struct workspace *ws,<br>
        }<br>
<br>
        if (to)<br>
-               wl_list_insert(&to->layer_link,<br>
-                              &ws->fsurf_front->view->layer_link);<br>
+               weston_layer_entry_insert(&to->layer_link,<br>
+                                         &ws->fsurf_front->view->layer_link);<br>
        else if (from)<br>
-               wl_list_insert(&ws->layer.view_list,<br>
-                              &ws->fsurf_front->view->layer_link);<br>
+               weston_layer_entry_insert(&ws->layer.view_list,<br>
+                                         &ws->fsurf_front->view->layer_link);<br>
<br>
        if (focus_surface_created) {<br>
                ws->focus_animation = weston_fade_run(<br>
@@ -876,15 +877,15 @@ animate_focus_change(struct desktop_shell *shell, struct workspace *ws,<br>
                        ws->fsurf_front->view->alpha, 0.4, 300,<br>
                        focus_animation_done, ws);<br>
        } else if (from) {<br>
-               wl_list_insert(&from->layer_link,<br>
-                              &ws->fsurf_back->view->layer_link);<br>
+               weston_layer_entry_insert(&from->layer_link,<br>
+                                         &ws->fsurf_back->view->layer_link);<br>
                ws->focus_animation = weston_stable_fade_run(<br>
                        ws->fsurf_front->view, 0.0,<br>
                        ws->fsurf_back->view, 0.4,<br>
                        focus_animation_done, ws);<br>
        } else if (to) {<br>
-               wl_list_insert(&ws->layer.view_list,<br>
-                              &ws->fsurf_back->view->layer_link);<br>
+               weston_layer_entry_insert(&ws->layer.view_list,<br>
+                                         &ws->fsurf_back->view->layer_link);<br>
                ws->focus_animation = weston_stable_fade_run(<br>
                        ws->fsurf_front->view, 0.0,<br>
                        ws->fsurf_back->view, 0.4,<br>
@@ -944,7 +945,7 @@ workspace_create(void)<br>
 static int<br>
 workspace_is_empty(struct workspace *ws)<br>
 {<br>
-       return wl_list_empty(&ws->layer.view_list);<br>
+       return wl_list_empty(&ws->layer.view_list.link);<br>
 }<br>
<br>
 static struct workspace *<br>
@@ -1009,7 +1010,7 @@ workspace_translate_out(struct workspace *ws, double fraction)<br>
        unsigned int height;<br>
        double d;<br>
<br>
-       wl_list_for_each(view, &ws->layer.view_list, layer_link) {<br>
+       wl_list_for_each(view, &ws->layer.view_list.link, layer_link.link) {<br>
                height = get_output_height(view->surface->output);<br>
                d = height * fraction;<br>
<br>
@@ -1024,7 +1025,7 @@ workspace_translate_in(struct workspace *ws, double fraction)<br>
        unsigned int height;<br>
        double d;<br>
<br>
-       wl_list_for_each(view, &ws->layer.view_list, layer_link) {<br>
+       wl_list_for_each(view, &ws->layer.view_list.link, layer_link.link) {<br>
                height = get_output_height(view->surface->output);<br>
<br>
                if (fraction > 0)<br>
@@ -1069,7 +1070,7 @@ workspace_deactivate_transforms(struct workspace *ws)<br>
        struct weston_view *view;<br>
        struct weston_transform *transform;<br>
<br>
-       wl_list_for_each(view, &ws->layer.view_list, layer_link) {<br>
+       wl_list_for_each(view, &ws->layer.view_list.link, layer_link.link) {<br>
                if (is_focus_view(view)) {<br>
                        struct focus_surface *fsurf = get_focus_surface(view->surface);<br>
                        transform = &fsurf->workspace_transform;<br>
@@ -1099,7 +1100,7 @@ finish_workspace_change_animation(struct desktop_shell *shell,<br>
         * visible after the workspace animation ends but before its layer<br>
         * is hidden. In that case, we need to damage below those views so<br>
         * that the screen is properly repainted. */<br>
-       wl_list_for_each(view, &from->layer.view_list, layer_link)<br>
+       wl_list_for_each(view, &from->layer.view_list.link, layer_link.link)<br>
                weston_view_damage_below(view);<br>
<br>
        wl_list_remove(&shell->workspaces.animation.link);<br>
@@ -1218,7 +1219,7 @@ change_workspace(struct desktop_shell *shell, unsigned int index)<br>
                return;<br>
<br>
        /* Don't change workspace when there is any fullscreen surfaces. */<br>
-       if (!wl_list_empty(&shell->fullscreen_layer.view_list))<br>
+       if (!wl_list_empty(&shell->fullscreen_layer.view_list.link))<br>
                return;<br>
<br>
        from = get_current_workspace(shell);<br>
@@ -1262,7 +1263,7 @@ change_workspace(struct desktop_shell *shell, unsigned int index)<br>
 static bool<br>
 workspace_has_only(struct workspace *ws, struct weston_surface *surface)<br>
 {<br>
-       struct wl_list *list = &ws->layer.view_list;<br>
+       struct wl_list *list = &ws->layer.view_list.link;<br>
        struct wl_list *e;<br>
<br>
        if (wl_list_empty(list))<br>
@@ -1273,7 +1274,7 @@ workspace_has_only(struct workspace *ws, struct weston_surface *surface)<br>
        if (e->next != list)<br>
                return false;<br>
<br>
-       return container_of(e, struct weston_view, layer_link)->surface == surface;<br>
+       return container_of(e, struct weston_view, layer_link.link)->surface == surface;<br>
 }<br>
<br>
 static void<br>
@@ -1302,8 +1303,8 @@ move_surface_to_workspace(struct desktop_shell *shell,<br>
        from = get_current_workspace(shell);<br>
        to = get_workspace(shell, workspace);<br>
<br>
-       wl_list_remove(&view->layer_link);<br>
-       wl_list_insert(&to->layer.view_list, &view->layer_link);<br>
+       weston_layer_entry_remove(&view->layer_link);<br>
+       weston_layer_entry_insert(&to->layer.view_list, &view->layer_link);<br>
<br>
        shell_surface_update_child_surface_layers(shsurf);<br>
<br>
@@ -1342,8 +1343,8 @@ take_surface_to_workspace_by_seat(struct desktop_shell *shell,<br>
        from = get_current_workspace(shell);<br>
        to = get_workspace(shell, index);<br>
<br>
-       wl_list_remove(&view->layer_link);<br>
-       wl_list_insert(&to->layer.view_list, &view->layer_link);<br>
+       weston_layer_entry_remove(&view->layer_link);<br>
+       weston_layer_entry_insert(&to->layer.view_list, &view->layer_link);<br>
<br>
        shsurf = get_shell_surface(surface);<br>
        if (shsurf != NULL)<br>
@@ -2177,7 +2178,7 @@ restore_all_output_modes(struct weston_compositor *compositor)<br>
 /* The surface will be inserted into the list immediately after the link<br>
  * returned by this function (i.e. will be stacked immediately above the<br>
  * returned link). */<br>
-static struct wl_list *<br>
+static struct weston_layer_entry *<br>
 shell_surface_calculate_layer_link (struct shell_surface *shsurf)<br>
 {<br>
        struct workspace *ws;<br>
@@ -2203,7 +2204,8 @@ shell_surface_calculate_layer_link (struct shell_surface *shsurf)<br>
                        /* TODO: Handle a parent with multiple views */<br>
                        parent = get_default_view(shsurf->parent);<br>
                        if (parent)<br>
-                               return parent->layer_link.prev;<br>
+                               return container_of(parent->layer_link.link.prev,<br>
+                                                   struct weston_layer_entry, link);<br>
                }<br>
<br>
                /* Move the surface to a normal workspace layer so that surfaces<br>
@@ -2220,16 +2222,19 @@ static void<br>
 shell_surface_update_child_surface_layers (struct shell_surface *shsurf)<br>
 {<br>
        struct shell_surface *child;<br>
+       struct weston_layer_entry *prev;<br>
<br>
        /* Move the child layers to the same workspace as shsurf. They will be<br>
         * stacked above shsurf. */<br>
        wl_list_for_each_reverse(child, &shsurf->children_list, children_link) {<br>
-               if (shsurf->view->layer_link.prev != &child->view->layer_link) {<br>
+               if (shsurf->view->layer_link.link.prev != &child->view->layer_link.link) {<br>
                        weston_view_damage_below(child->view);<br>
                        weston_view_geometry_dirty(child->view);<br>
-                       wl_list_remove(&child->view->layer_link);<br>
-                       wl_list_insert(shsurf->view->layer_link.prev,<br>
-                                      &child->view->layer_link);<br>
+                       prev = container_of(shsurf->view->layer_link.link.prev,<br>
+                                           struct weston_layer_entry, link);<br>
+                       weston_layer_entry_remove(&child->view->layer_link);<br>
+                       weston_layer_entry_insert(prev,<br>
+                                                 &child->view->layer_link);<br>
                        weston_view_geometry_dirty(child->view);<br>
                        weston_surface_damage(child->surface);<br>
<br>
@@ -2250,7 +2255,7 @@ shell_surface_update_child_surface_layers (struct shell_surface *shsurf)<br>
 static void<br>
 shell_surface_update_layer(struct shell_surface *shsurf)<br>
 {<br>
-       struct wl_list *new_layer_link;<br>
+       struct weston_layer_entry *new_layer_link;<br>
<br>
        new_layer_link = shell_surface_calculate_layer_link(shsurf);<br>
<br>
@@ -2260,8 +2265,8 @@ shell_surface_update_layer(struct shell_surface *shsurf)<br>
                return;<br>
<br>
        weston_view_geometry_dirty(shsurf->view);<br>
-       wl_list_remove(&shsurf->view->layer_link);<br>
-       wl_list_insert(new_layer_link, &shsurf->view->layer_link);<br>
+       weston_layer_entry_remove(&shsurf->view->layer_link);<br>
+       weston_layer_entry_insert(new_layer_link, &shsurf->view->layer_link);<br>
        weston_view_geometry_dirty(shsurf->view);<br>
        weston_surface_damage(shsurf->surface);<br>
<br>
@@ -2523,10 +2528,10 @@ set_minimized(struct weston_surface *surface, uint32_t is_true)<br>
        shsurf = get_shell_surface(surface);<br>
        current_ws = get_current_workspace(shsurf->shell);<br>
<br>
-       wl_list_remove(&view->layer_link);<br>
+       weston_layer_entry_remove(&view->layer_link);<br>
         /* hide or show, depending on the state */<br>
        if (is_true) {<br>
-               wl_list_insert(&shsurf->shell->minimized_layer.view_list, &view->layer_link);<br>
+               weston_layer_entry_insert(&shsurf->shell->minimized_layer.view_list, &view->layer_link);<br>
<br>
                drop_focus_state(shsurf->shell, current_ws, view->surface);<br>
                wl_list_for_each(seat, &shsurf->shell->compositor->seat_list, link) {<br>
@@ -2538,7 +2543,7 @@ set_minimized(struct weston_surface *surface, uint32_t is_true)<br>
                }<br>
        }<br>
        else {<br>
-               wl_list_insert(&current_ws->layer.view_list, &view->layer_link);<br>
+               weston_layer_entry_insert(&current_ws->layer.view_list, &view->layer_link);<br>
<br>
                wl_list_for_each(seat, &shsurf->shell->compositor->seat_list, link) {<br>
                        if (!seat->keyboard)<br>
@@ -2704,9 +2709,9 @@ shell_ensure_fullscreen_black_view(struct shell_surface *shsurf)<br>
                                             output->height);<br>
<br>
        weston_view_geometry_dirty(shsurf->fullscreen.black_view);<br>
-       wl_list_remove(&shsurf->fullscreen.black_view->layer_link);<br>
-       wl_list_insert(&shsurf->view->layer_link,<br>
-                      &shsurf->fullscreen.black_view->layer_link);<br>
+       weston_layer_entry_remove(&shsurf->fullscreen.black_view->layer_link);<br>
+       weston_layer_entry_insert(&shsurf->view->layer_link,<br>
+                                 &shsurf->fullscreen.black_view->layer_link);<br>
        weston_view_geometry_dirty(shsurf->fullscreen.black_view);<br>
        weston_surface_damage(shsurf->surface);<br>
<br>
@@ -2728,8 +2733,8 @@ shell_configure_fullscreen(struct shell_surface *shsurf)<br>
                restore_output_mode(output);<br>
<br>
        /* Reverse the effect of lower_fullscreen_layer() */<br>
-       wl_list_remove(&shsurf->view->layer_link);<br>
-       wl_list_insert(&shsurf->shell->fullscreen_layer.view_list, &shsurf->view->layer_link);<br>
+       weston_layer_entry_remove(&shsurf->view->layer_link);<br>
+       weston_layer_entry_insert(&shsurf->shell->fullscreen_layer.view_list, &shsurf->view->layer_link);<br>
<br>
        shell_ensure_fullscreen_black_view(shsurf);<br>
<br>
@@ -3888,7 +3893,7 @@ configure_static_view(struct weston_view *ev, struct weston_layer *layer)<br>
 {<br>
        struct weston_view *v, *next;<br>
<br>
-       wl_list_for_each_safe(v, next, &layer->view_list, layer_link) {<br>
+       wl_list_for_each_safe(v, next, &layer->view_list.link, layer_link.link) {<br>
                if (v->output == ev->output && v != ev) {<br>
                        weston_view_unmap(v);<br>
                        v->surface->configure = NULL;<br>
@@ -3897,8 +3902,8 @@ configure_static_view(struct weston_view *ev, struct weston_layer *layer)<br>
<br>
        weston_view_set_position(ev, ev->output->x, ev->output->y);<br>
<br>
-       if (wl_list_empty(&ev->layer_link)) {<br>
-               wl_list_insert(&layer->view_list, &ev->layer_link);<br>
+       if (wl_list_empty(&ev->layer_link.link)) {<br>
+               weston_layer_entry_insert(&layer->view_list, &ev->layer_link);<br>
                weston_compositor_schedule_repaint(ev->surface->compositor);<br>
        }<br>
 }<br>
@@ -4003,8 +4008,8 @@ lock_surface_configure(struct weston_surface *surface, int32_t sx, int32_t sy)<br>
        center_on_output(view, get_default_output(shell->compositor));<br>
<br>
        if (!weston_surface_is_mapped(surface)) {<br>
-               wl_list_insert(&shell->lock_layer.view_list,<br>
-                              &view->layer_link);<br>
+               weston_layer_entry_insert(&shell->lock_layer.view_list,<br>
+                                         &view->layer_link);<br>
                weston_view_update_transform(view);<br>
                shell_fade(shell, FADE_IN);<br>
        }<br>
@@ -4534,8 +4539,8 @@ lower_fullscreen_layer(struct desktop_shell *shell)<br>
<br>
        ws = get_current_workspace(shell);<br>
        wl_list_for_each_reverse_safe(view, prev,<br>
-                                     &shell->fullscreen_layer.view_list,<br>
-                                     layer_link) {<br>
+                                     &shell->fullscreen_layer.view_list.link,<br>
+                                     layer_link.link) {<br>
                struct shell_surface *shsurf = get_shell_surface(view->surface);<br>
<br>
                if (!shsurf)<br>
@@ -4545,15 +4550,15 @@ lower_fullscreen_layer(struct desktop_shell *shell)<br>
                 * in the fullscreen layer. */<br>
                if (shsurf->state.fullscreen) {<br>
                        /* Hide the black view */<br>
-                       wl_list_remove(&shsurf->fullscreen.black_view->layer_link);<br>
-                       wl_list_init(&shsurf->fullscreen.black_view->layer_link);<br>
+                       weston_layer_entry_remove(&shsurf->fullscreen.black_view->layer_link);<br>
+                       wl_list_init(&shsurf->fullscreen.black_view->layer_link.link);<br>
                        weston_view_damage_below(shsurf->fullscreen.black_view);<br>
<br>
                }<br>
<br>
                /* Lower the view to the workspace layer */<br>
-               wl_list_remove(&view->layer_link);<br>
-               wl_list_insert(&ws->layer.view_list, &view->layer_link);<br>
+               weston_layer_entry_remove(&view->layer_link);<br>
+               weston_layer_entry_insert(&ws->layer.view_list, &view->layer_link);<br>
                weston_view_damage_below(view);<br>
                weston_surface_damage(view->surface);<br>
<br>
@@ -4772,8 +4777,8 @@ shell_fade_create_surface(struct desktop_shell *shell)<br>
        weston_surface_set_size(surface, 8192, 8192);<br>
        weston_view_set_position(view, 0, 0);<br>
        weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1.0);<br>
-       wl_list_insert(&compositor->fade_layer.view_list,<br>
-                      &view->layer_link);<br>
+       weston_layer_entry_insert(&compositor->fade_layer.view_list,<br>
+                                 &view->layer_link);<br>
        pixman_region32_init(&surface->input);<br>
<br>
        return view;<br>
@@ -5343,6 +5348,7 @@ screensaver_configure(struct weston_surface *surface, int32_t sx, int32_t sy)<br>
 {<br>
        struct desktop_shell *shell = surface->configure_private;<br>
        struct weston_view *view;<br>
+       struct weston_layer_entry *prev;<br>
<br>
        if (surface->width == 0)<br>
                return;<br>
@@ -5354,9 +5360,10 @@ screensaver_configure(struct weston_surface *surface, int32_t sx, int32_t sy)<br>
        view = container_of(surface->views.next, struct weston_view, surface_link);<br>
        center_on_output(view, surface->output);<br>
<br>
-       if (wl_list_empty(&view->layer_link)) {<br>
-               wl_list_insert(shell->lock_layer.view_list.prev,<br>
-                              &view->layer_link);<br>
+       if (wl_list_empty(&view->layer_link.link)) {<br>
+               prev = container_of(shell->lock_layer.view_list.link.prev,<br>
+                                   struct weston_layer_entry, link);<br>
+               weston_layer_entry_insert(prev, &view->layer_link);<br>
                weston_view_update_transform(view);<br>
                wl_event_source_timer_update(shell->screensaver.timer,<br>
                                             shell->screensaver.duration);<br>
@@ -5439,14 +5446,14 @@ switcher_next(struct switcher *switcher)<br>
         /* temporary re-display minimized surfaces */<br>
        struct weston_view *tmp;<br>
        struct weston_view **minimized;<br>
-       wl_list_for_each_safe(view, tmp, &switcher->shell->minimized_layer.view_list, layer_link) {<br>
-               wl_list_remove(&view->layer_link);<br>
-               wl_list_insert(&ws->layer.view_list, &view->layer_link);<br>
+       wl_list_for_each_safe(view, tmp, &switcher->shell->minimized_layer.view_list.link, layer_link.link) {<br>
+               weston_layer_entry_remove(&view->layer_link);<br>
+               weston_layer_entry_insert(&ws->layer.view_list, &view->layer_link);<br>
                minimized = wl_array_add(&switcher->minimized_array, sizeof *minimized);<br>
                *minimized = view;<br>
        }<br>
<br>
-       wl_list_for_each(view, &ws->layer.view_list, layer_link) {<br>
+       wl_list_for_each(view, &ws->layer.view_list.link, layer_link.link) {<br>
                shsurf = get_shell_surface(view->surface);<br>
                if (shsurf &&<br>
                    shsurf->type == SHELL_SURFACE_TOPLEVEL &&<br>
@@ -5502,7 +5509,7 @@ switcher_destroy(struct switcher *switcher)<br>
        struct weston_keyboard *keyboard = switcher->grab.keyboard;<br>
        struct workspace *ws = get_current_workspace(switcher->shell);<br>
<br>
-       wl_list_for_each(view, &ws->layer.view_list, layer_link) {<br>
+       wl_list_for_each(view, &ws->layer.view_list.link, layer_link.link) {<br>
                if (is_focus_view(view))<br>
                        continue;<br>
<br>
@@ -5523,8 +5530,8 @@ switcher_destroy(struct switcher *switcher)<br>
        wl_array_for_each(minimized, &switcher->minimized_array) {<br>
                /* with the exception of the current selected */<br>
                if ((*minimized)->surface != switcher->current) {<br>
-                       wl_list_remove(&(*minimized)->layer_link);<br>
-                       wl_list_insert(&switcher->shell->minimized_layer.view_list, &(*minimized)->layer_link);<br>
+                       weston_layer_entry_remove(&(*minimized)->layer_link);<br>
+                       weston_layer_entry_insert(&switcher->shell->minimized_layer.view_list, &(*minimized)->layer_link);<br>
                        weston_view_damage_below(*minimized);<br>
                }<br>
        }<br>
@@ -5928,7 +5935,7 @@ shell_output_destroy_move_layer(struct desktop_shell *shell,<br>
        struct weston_output *output = data;<br>
        struct weston_view *view;<br>
<br>
-       wl_list_for_each(view, &layer->view_list, layer_link) {<br>
+       wl_list_for_each(view, &layer->view_list.link, layer_link.link) {<br>
                if (view->output != output)<br>
                        continue;<br>
<br>
@@ -5987,7 +5994,7 @@ handle_output_move_layer(struct desktop_shell *shell,<br>
        struct weston_view *view;<br>
        float x, y;<br>
<br>
-       wl_list_for_each(view, &layer->view_list, layer_link) {<br>
+       wl_list_for_each(view, &layer->view_list.link, layer_link.link) {<br>
                if (view->output != output)<br>
                        continue;<br>
<br>
diff --git a/src/compositor.c b/src/compositor.c<br>
index 17fce8d..1d8d00e 100644<br>
--- a/src/compositor.c<br>
+++ b/src/compositor.c<br>
@@ -345,9 +345,10 @@ weston_view_create(struct weston_surface *surface)<br>
<br>
        wl_signal_init(&view->destroy_signal);<br>
        wl_list_init(&view->link);<br>
-       wl_list_init(&view->layer_link);<br>
+       wl_list_init(&view->layer_link.link);<br>
<br>
        view->plane = NULL;<br>
+       view->layer_link.layer = NULL;<br>
<br>
        pixman_region32_init(&view->clip);<br>
<br>
@@ -1366,8 +1367,7 @@ weston_view_unmap(struct weston_view *view)<br>
        weston_view_damage_below(view);<br>
        view->output = NULL;<br>
        view->plane = NULL;<br>
-       wl_list_remove(&view->layer_link);<br>
-       wl_list_init(&view->layer_link);<br>
+       weston_layer_entry_remove(&view->layer_link);<br>
        wl_list_remove(&view->link);<br>
        wl_list_init(&view->link);<br>
        view->output_mask = 0;<br>
@@ -1422,7 +1422,7 @@ weston_view_destroy(struct weston_view *view)<br>
        }<br>
<br>
        wl_list_remove(&view->link);<br>
-       wl_list_remove(&view->layer_link);<br>
+       weston_layer_entry_remove(&view->layer_link);<br>
<br>
        pixman_region32_fini(&view->clip);<br>
        pixman_region32_fini(&view->transform.boundingbox);<br>
@@ -1783,18 +1783,18 @@ weston_compositor_build_view_list(struct weston_compositor *compositor)<br>
        struct weston_layer *layer;<br>
<br>
        wl_list_for_each(layer, &compositor->layer_list, link)<br>
-               wl_list_for_each(view, &layer->view_list, layer_link)<br>
+               wl_list_for_each(view, &layer->view_list.link, layer_link.link)<br>
                        surface_stash_subsurface_views(view->surface);<br>
<br>
        wl_list_init(&compositor->view_list);<br>
        wl_list_for_each(layer, &compositor->layer_list, link) {<br>
-               wl_list_for_each(view, &layer->view_list, layer_link) {<br>
+               wl_list_for_each(view, &layer->view_list.link, layer_link.link) {<br>
                        view_list_add(compositor, view);<br>
                }<br>
        }<br>
<br>
        wl_list_for_each(layer, &compositor->layer_list, link)<br>
-               wl_list_for_each(view, &layer->view_list, layer_link)<br>
+               wl_list_for_each(view, &layer->view_list.link, layer_link.link)<br>
                        surface_free_unused_subsurface_views(view->surface);<br>
 }<br>
<br>
@@ -1913,9 +1913,26 @@ idle_repaint(void *data)<br>
 }<br>
<br>
 WL_EXPORT void<br>
+weston_layer_entry_insert(struct weston_layer_entry *list,<br>
+                         struct weston_layer_entry *entry)<br>
+{<br>
+       wl_list_insert(&list->link, &entry->link);<br>
+       entry->layer = list->layer;<br>
+}<br>
+<br>
+WL_EXPORT void<br>
+weston_layer_entry_remove(struct weston_layer_entry *entry)<br>
+{<br>
+       wl_list_remove(&entry->link);<br>
+       wl_list_init(&entry->link);<br>
+       entry->layer = NULL;<br>
+}<br>
+<br>
+WL_EXPORT void<br>
 weston_layer_init(struct weston_layer *layer, struct wl_list *below)<br>
 {<br>
-       wl_list_init(&layer->view_list);<br>
+       wl_list_init(&layer->view_list.link);<br>
+       layer->view_list.layer = layer;<br>
        if (below != NULL)<br>
                wl_list_insert(below, &layer->link);<br>
 }<br>
diff --git a/src/compositor.h b/src/compositor.h<br>
index bef5e1d..78a59cb 100644<br>
--- a/src/compositor.h<br>
+++ b/src/compositor.h<br>
@@ -526,8 +526,13 @@ enum {<br>
                                          * to off */<br>
 };<br>
<br>
+struct weston_layer_entry {<br>
+       struct wl_list link;<br>
+       struct weston_layer *layer;<br>
+};<br>
+<br>
 struct weston_layer {<br>
-       struct wl_list view_list;<br>
+       struct weston_layer_entry view_list;<br>
        struct wl_list link;<br>
 };<br>
<br>
@@ -731,7 +736,7 @@ struct weston_view {<br>
        struct wl_signal destroy_signal;<br>
<br>
        struct wl_list link;<br>
-       struct wl_list layer_link;<br>
+       struct weston_layer_entry layer_link;<br>
        struct weston_plane *plane;<br>
<br>
        pixman_region32_t clip;<br>
@@ -997,6 +1002,11 @@ void<br>
 notify_touch_frame(struct weston_seat *seat);<br>
<br>
 void<br>
+weston_layer_entry_insert(struct weston_layer_entry *list,<br>
+                         struct weston_layer_entry *entry);<br>
+void<br>
+weston_layer_entry_remove(struct weston_layer_entry *entry);<br>
+void<br>
 weston_layer_init(struct weston_layer *layer, struct wl_list *below);<br>
<br>
 void<br>
diff --git a/src/data-device.c b/src/data-device.c<br>
index a069b3c..75fc60c 100644<br>
--- a/src/data-device.c<br>
+++ b/src/data-device.c<br>
@@ -180,7 +180,7 @@ drag_surface_configure(struct weston_drag *drag,<br>
                       struct weston_surface *es,<br>
                       int32_t sx, int32_t sy)<br>
 {<br>
-       struct wl_list *list;<br>
+       struct weston_layer_entry *list;<br>
        float fx, fy;<br>
<br>
        assert((pointer != NULL && touch == NULL) ||<br>
@@ -193,8 +193,8 @@ drag_surface_configure(struct weston_drag *drag,<br>
                else<br>
                        list = &es->compositor->cursor_layer.view_list;<br>
<br>
-               wl_list_remove(&drag->icon->layer_link);<br>
-               wl_list_insert(list, &drag->icon->layer_link);<br>
+               weston_layer_entry_remove(&drag->icon->layer_link);<br>
+               weston_layer_entry_insert(list, &drag->icon->layer_link);<br>
                weston_view_update_transform(drag->icon);<br>
                pixman_region32_clear(&es->pending.input);<br>
        }<br>
diff --git a/src/input.c b/src/input.c<br>
index 2c799f4..4aa8ca7 100644<br>
--- a/src/input.c<br>
+++ b/src/input.c<br>
@@ -1555,8 +1555,8 @@ pointer_cursor_surface_configure(struct weston_surface *es,<br>
        empty_region(&es->input);<br>
<br>
        if (!weston_surface_is_mapped(es)) {<br>
-               wl_list_insert(&es->compositor->cursor_layer.view_list,<br>
-                              &pointer->sprite->layer_link);<br>
+               weston_layer_entry_insert(&es->compositor->cursor_layer.view_list,<br>
+                                         &pointer->sprite->layer_link);<br>
                weston_view_update_transform(pointer->sprite);<br>
        }<br>
 }<br>
diff --git a/tests/weston-test.c b/tests/weston-test.c<br>
index 35ccaa4..ca2f219 100644<br>
--- a/tests/weston-test.c<br>
+++ b/tests/weston-test.c<br>
@@ -93,9 +93,9 @@ test_surface_configure(struct weston_surface *surface, int32_t sx, int32_t sy)<br>
        struct weston_test_surface *test_surface = surface->configure_private;<br>
        struct weston_test *test = test_surface->test;<br>
<br>
-       if (wl_list_empty(&test_surface->view->layer_link))<br>
-               wl_list_insert(&test->layer.view_list,<br>
-                              &test_surface->view->layer_link);<br>
+       if (wl_list_empty(&test_surface->view->layer_link.link))<br>
+               weston_layer_entry_insert(&test->layer.view_list,<br>
+                                         &test_surface->view->layer_link);<br>
<br>
        weston_view_set_position(test_surface->view,<br>
                                 test_surface->x, test_surface->y);<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.0.0<br>
<br>
_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</font></span></blockquote></div><br></div>