nested: Move the frame callback list to the surface
Previously the frame callback list was tracked as part of the global
compositor state. This patch moves the list to be part of the surface
state like it is in Weston. The frame callback now iterates the list
of surfaces to flush all of the callbacks. This change will be useful
when the example is converted to use subsurfaces so that it can have a
separate frame callback for the subsurface and flush the list for an
individual client surface rather than flushing globally.
diff --git a/clients/nested.c b/clients/nested.c
index b2f5949..6ac5248 100644
--- a/clients/nested.c
+++ b/clients/nested.c
@@ -58,7 +58,6 @@
struct program *texture_program;
struct wl_list surface_list;
- struct wl_list frame_callback_list;
};
struct nested_region {
@@ -87,6 +86,8 @@
struct wl_list link;
cairo_surface_t *cairo_surface;
+ struct wl_list frame_callback_list;
+
struct {
/* wl_surface.attach */
int newly_attached;
@@ -191,23 +192,33 @@
}
static void
-frame_callback(void *data, struct wl_callback *callback, uint32_t time)
+flush_surface_frame_callback_list(struct nested_surface *surface,
+ uint32_t time)
{
- struct nested *nested = data;
struct nested_frame_callback *nc, *next;
- if (callback)
- wl_callback_destroy(callback);
-
- wl_list_for_each_safe(nc, next, &nested->frame_callback_list, link) {
+ wl_list_for_each_safe(nc, next, &surface->frame_callback_list, link) {
wl_callback_send_done(nc->resource, time);
wl_resource_destroy(nc->resource);
}
- wl_list_init(&nested->frame_callback_list);
+ wl_list_init(&surface->frame_callback_list);
/* FIXME: toytoolkit need a pre-block handler where we can
* call this. */
- wl_display_flush_clients(nested->child_display);
+ wl_display_flush_clients(surface->nested->child_display);
+}
+
+static void
+frame_callback(void *data, struct wl_callback *callback, uint32_t time)
+{
+ struct nested *nested = data;
+ struct nested_surface *surface;
+
+ wl_list_for_each(surface, &nested->surface_list, link)
+ flush_surface_frame_callback_list(surface, time);
+
+ if (callback)
+ wl_callback_destroy(callback);
}
static const struct wl_callback_listener frame_listener = {
@@ -369,6 +380,10 @@
struct nested_frame_callback *cb, *next;
wl_list_for_each_safe(cb, next,
+ &surface->frame_callback_list, link)
+ wl_resource_destroy(cb->resource);
+
+ wl_list_for_each_safe(cb, next,
&surface->pending.frame_callback_list, link)
wl_resource_destroy(cb->resource);
@@ -558,7 +573,7 @@
empty_region(&surface->pending.damage);
/* wl_surface.frame */
- wl_list_insert_list(&nested->frame_callback_list,
+ wl_list_insert_list(&surface->frame_callback_list,
&surface->pending.frame_callback_list);
wl_list_init(&surface->pending.frame_callback_list);
@@ -608,6 +623,8 @@
surface->nested = nested;
+ wl_list_init(&surface->frame_callback_list);
+
wl_list_init(&surface->pending.frame_callback_list);
surface->pending.buffer_destroy_listener.notify =
surface_handle_pending_buffer_destroy;
@@ -724,7 +741,6 @@
int fd, ret;
wl_list_init(&nested->surface_list);
- wl_list_init(&nested->frame_callback_list);
nested->child_display = wl_display_create();
loop = wl_display_get_event_loop(nested->child_display);
fd = wl_event_loop_get_fd(loop);