compositor: keep track of the weston_layer a weston_view is in
This introduces a new struct, weston_layer_entry, which is now used
in place of wl_list to keep the link for the layer list in weston_view
and the head of the list in weston_layer.
weston_layer_entry also has a weston_layer*, which points to the layer
the view is in or, in the case the entry it's the head of the list, to
the layer itself.
diff --git a/src/compositor.c b/src/compositor.c
index 17fce8d..1d8d00e 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -345,9 +345,10 @@
wl_signal_init(&view->destroy_signal);
wl_list_init(&view->link);
- wl_list_init(&view->layer_link);
+ wl_list_init(&view->layer_link.link);
view->plane = NULL;
+ view->layer_link.layer = NULL;
pixman_region32_init(&view->clip);
@@ -1366,8 +1367,7 @@
weston_view_damage_below(view);
view->output = NULL;
view->plane = NULL;
- wl_list_remove(&view->layer_link);
- wl_list_init(&view->layer_link);
+ weston_layer_entry_remove(&view->layer_link);
wl_list_remove(&view->link);
wl_list_init(&view->link);
view->output_mask = 0;
@@ -1422,7 +1422,7 @@
}
wl_list_remove(&view->link);
- wl_list_remove(&view->layer_link);
+ weston_layer_entry_remove(&view->layer_link);
pixman_region32_fini(&view->clip);
pixman_region32_fini(&view->transform.boundingbox);
@@ -1783,18 +1783,18 @@
struct weston_layer *layer;
wl_list_for_each(layer, &compositor->layer_list, link)
- wl_list_for_each(view, &layer->view_list, layer_link)
+ wl_list_for_each(view, &layer->view_list.link, layer_link.link)
surface_stash_subsurface_views(view->surface);
wl_list_init(&compositor->view_list);
wl_list_for_each(layer, &compositor->layer_list, link) {
- wl_list_for_each(view, &layer->view_list, layer_link) {
+ wl_list_for_each(view, &layer->view_list.link, layer_link.link) {
view_list_add(compositor, view);
}
}
wl_list_for_each(layer, &compositor->layer_list, link)
- wl_list_for_each(view, &layer->view_list, layer_link)
+ wl_list_for_each(view, &layer->view_list.link, layer_link.link)
surface_free_unused_subsurface_views(view->surface);
}
@@ -1913,9 +1913,26 @@
}
WL_EXPORT void
+weston_layer_entry_insert(struct weston_layer_entry *list,
+ struct weston_layer_entry *entry)
+{
+ wl_list_insert(&list->link, &entry->link);
+ entry->layer = list->layer;
+}
+
+WL_EXPORT void
+weston_layer_entry_remove(struct weston_layer_entry *entry)
+{
+ wl_list_remove(&entry->link);
+ wl_list_init(&entry->link);
+ entry->layer = NULL;
+}
+
+WL_EXPORT void
weston_layer_init(struct weston_layer *layer, struct wl_list *below)
{
- wl_list_init(&layer->view_list);
+ wl_list_init(&layer->view_list.link);
+ layer->view_list.layer = layer;
if (below != NULL)
wl_list_insert(below, &layer->link);
}