From 94fcdde0e25ffb737734e9a696814308bcb23576 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Mon, 14 Mar 2011 12:03:13 +0100 Subject: [PATCH] Extent frame event to be surface dependent --- protocol/wayland.xml | 1 + wayland/wayland-client.c | 8 ++++++-- wayland/wayland-client.h | 4 +++- wayland/wayland-server.c | 11 +++++++++-- wayland/wayland-server.h | 3 ++- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/protocol/wayland.xml b/protocol/wayland.xml index 88c5a32..486cc0c 100644 --- a/protocol/wayland.xml +++ b/protocol/wayland.xml @@ -18,6 +18,7 @@ animations. The notification will only be posted for one frame unless requested again. --> + diff --git a/wayland/wayland-client.c b/wayland/wayland-client.c index ad35c30..85bae76 100644 --- a/wayland/wayland-client.c +++ b/wayland/wayland-client.c @@ -61,6 +61,7 @@ struct wl_frame_handler { wl_display_frame_func_t func; uint32_t key; void *data; + struct wl_surface *surface; struct wl_list link; }; @@ -303,7 +304,8 @@ display_handle_key(void *data, if (!wl_list_empty(&display->frame_list) && frame_handler->key == key) { wl_list_remove(&frame_handler->link); - frame_handler->func(frame_handler->data, time); + frame_handler->func(frame_handler->surface, + frame_handler->data, time); free(frame_handler); return; } @@ -435,6 +437,7 @@ wl_display_sync_callback(struct wl_display *display, WL_EXPORT int wl_display_frame_callback(struct wl_display *display, + struct wl_surface *surface, wl_display_frame_func_t func, void *data) { struct wl_frame_handler *handler; @@ -446,9 +449,10 @@ wl_display_frame_callback(struct wl_display *display, handler->func = func; handler->key = display->key++; handler->data = data; + handler->surface = surface; wl_list_insert(display->frame_list.prev, &handler->link); - wl_display_frame(display, handler->key); + wl_display_frame(display, handler->surface, handler->key); return 0; } diff --git a/wayland/wayland-client.h b/wayland/wayland-client.h index d207b07..1064a3a 100644 --- a/wayland/wayland-client.h +++ b/wayland/wayland-client.h @@ -35,7 +35,8 @@ extern "C" { typedef int (*wl_display_update_func_t)(uint32_t mask, void *data); typedef void (*wl_display_sync_func_t)(void *data); -typedef void (*wl_display_frame_func_t)(void *data, uint32_t time); +typedef void (*wl_display_frame_func_t)(struct wl_surface *surface, + void *data, uint32_t time); struct wl_display *wl_display_connect(const char *name); void wl_display_destroy(struct wl_display *display); @@ -46,6 +47,7 @@ void wl_display_iterate(struct wl_display *display, uint32_t mask); int wl_display_sync_callback(struct wl_display *display, wl_display_sync_func_t func, void *data); int wl_display_frame_callback(struct wl_display *display, + struct wl_surface *surface, wl_display_frame_func_t func, void *data); struct wl_global_listener; diff --git a/wayland/wayland-server.c b/wayland/wayland-server.c index dece0d1..49fa97d 100644 --- a/wayland/wayland-server.c +++ b/wayland/wayland-server.c @@ -71,6 +71,7 @@ struct wl_frame_listener { struct wl_resource resource; struct wl_client *client; uint32_t key; + struct wl_surface *surface; struct wl_list link; }; @@ -480,7 +481,9 @@ destroy_frame_listener(struct wl_resource *resource, struct wl_client *client) static void display_frame(struct wl_client *client, - struct wl_display *display, uint32_t key) + struct wl_display *display, + struct wl_surface *surface, + uint32_t key) { struct wl_frame_listener *listener; @@ -496,6 +499,7 @@ display_frame(struct wl_client *client, listener->resource.object.id = 0; listener->client = client; listener->key = key; + listener->surface = surface; wl_list_insert(client->resource_list.prev, &listener->resource.link); wl_list_insert(display->frame_list.prev, &listener->link); } @@ -593,11 +597,14 @@ wl_display_add_global(struct wl_display *display, } WL_EXPORT void -wl_display_post_frame(struct wl_display *display, uint32_t time) +wl_display_post_frame(struct wl_display *display, struct wl_surface *surface, + uint32_t time) { struct wl_frame_listener *listener, *next; wl_list_for_each_safe(listener, next, &display->frame_list, link) { + if (listener->surface != surface) + continue; wl_client_post_event(listener->client, &display->object, WL_DISPLAY_KEY, listener->key, time); wl_resource_destroy(&listener->resource, listener->client); diff --git a/wayland/wayland-server.h b/wayland/wayland-server.h index f74cbae..f75064b 100644 --- a/wayland/wayland-server.h +++ b/wayland/wayland-server.h @@ -214,7 +214,8 @@ wl_display_set_compositor(struct wl_display *display, const struct wl_compositor_interface *implementation); void -wl_display_post_frame(struct wl_display *display, uint32_t msecs); +wl_display_post_frame(struct wl_display *display, struct wl_surface *surface, + uint32_t msecs); void wl_client_add_resource(struct wl_client *client, -- 2.7.4