diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2011-11-17 16:46:36 -0500 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2011-11-17 17:52:01 -0500 |
commit | 4abc56bd6d476cf386fcc998d40e3d7753a2b03e (patch) | |
tree | 5223cfca93756e393b116d1f7a40bec97ba79746 /src/wayland-server.c | |
parent | 3a1e6df39aa34df53c97ce9c7a1bfddf5a97faf3 (diff) |
Introduce wl_resource_queue_event() for sending events later
Some events, such as the display.delete_id, aren't very urgent and we
would like to not always send them immdiately and cause an unnecessary
context switch. The wl_resource_queue_event() function will place the
event in the connection output buffer but not request the main loop to
poll for writable. The effect is that the event will just sit in the
output buffer until a more important event comes around and requires
flushing.
Diffstat (limited to 'src/wayland-server.c')
-rw-r--r-- | src/wayland-server.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/wayland-server.c b/src/wayland-server.c index 0004c15..f3d8050 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -108,6 +108,28 @@ wl_resource_post_event(struct wl_resource *resource, uint32_t opcode, ...) wl_closure_destroy(closure); } + +WL_EXPORT void +wl_resource_queue_event(struct wl_resource *resource, uint32_t opcode, ...) +{ + struct wl_closure *closure; + struct wl_object *object = &resource->object; + va_list ap; + + va_start(ap, opcode); + closure = wl_connection_vmarshal(resource->client->connection, + object, opcode, ap, + &object->interface->events[opcode]); + va_end(ap); + + wl_closure_queue(closure, resource->client->connection); + + if (wl_debug) + wl_closure_print(closure, object, true); + + wl_closure_destroy(closure); +} + WL_EXPORT void wl_resource_post_error(struct wl_resource *resource, uint32_t code, const char *msg, ...) @@ -314,8 +336,8 @@ wl_resource_destroy(struct wl_resource *resource, uint32_t time) { struct wl_client *client = resource->client; - wl_resource_post_event(resource->client->display_resource, - WL_DISPLAY_DELETE_ID, resource->object.id); + wl_resource_queue_event(resource->client->display_resource, + WL_DISPLAY_DELETE_ID, resource->object.id); wl_map_insert_at(&client->objects, resource->object.id, NULL); destroy_resource(resource, &time); } |