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.
This commit is contained in:
Giulio Camuffo
2014-07-09 22:12:56 +03:00
committed by Jason Ekstrand
parent cfff312204
commit 412e6a59eb
8 changed files with 127 additions and 92 deletions
+25 -8
View File
@@ -345,9 +345,10 @@ weston_view_create(struct weston_surface *surface)
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_unmap(struct weston_view *view)
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 @@ weston_view_destroy(struct weston_view *view)
}
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 @@ weston_compositor_build_view_list(struct weston_compositor *compositor)
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);
}
@@ -1912,10 +1912,27 @@ idle_repaint(void *data)
output->start_repaint_loop(output);
}
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);
}
+12 -2
View File
@@ -526,8 +526,13 @@ enum {
* to off */
};
struct weston_layer_entry {
struct wl_list link;
struct weston_layer *layer;
};
struct weston_layer {
struct wl_list view_list;
struct weston_layer_entry view_list;
struct wl_list link;
};
@@ -731,7 +736,7 @@ struct weston_view {
struct wl_signal destroy_signal;
struct wl_list link;
struct wl_list layer_link;
struct weston_layer_entry layer_link;
struct weston_plane *plane;
pixman_region32_t clip;
@@ -996,6 +1001,11 @@ notify_touch(struct weston_seat *seat, uint32_t time, int touch_id,
void
notify_touch_frame(struct weston_seat *seat);
void
weston_layer_entry_insert(struct weston_layer_entry *list,
struct weston_layer_entry *entry);
void
weston_layer_entry_remove(struct weston_layer_entry *entry);
void
weston_layer_init(struct weston_layer *layer, struct wl_list *below);
+3 -3
View File
@@ -180,7 +180,7 @@ drag_surface_configure(struct weston_drag *drag,
struct weston_surface *es,
int32_t sx, int32_t sy)
{
struct wl_list *list;
struct weston_layer_entry *list;
float fx, fy;
assert((pointer != NULL && touch == NULL) ||
@@ -193,8 +193,8 @@ drag_surface_configure(struct weston_drag *drag,
else
list = &es->compositor->cursor_layer.view_list;
wl_list_remove(&drag->icon->layer_link);
wl_list_insert(list, &drag->icon->layer_link);
weston_layer_entry_remove(&drag->icon->layer_link);
weston_layer_entry_insert(list, &drag->icon->layer_link);
weston_view_update_transform(drag->icon);
pixman_region32_clear(&es->pending.input);
}
+2 -2
View File
@@ -1555,8 +1555,8 @@ pointer_cursor_surface_configure(struct weston_surface *es,
empty_region(&es->input);
if (!weston_surface_is_mapped(es)) {
wl_list_insert(&es->compositor->cursor_layer.view_list,
&pointer->sprite->layer_link);
weston_layer_entry_insert(&es->compositor->cursor_layer.view_list,
&pointer->sprite->layer_link);
weston_view_update_transform(pointer->sprite);
}
}