From 003a946aa66333ac1cf927fc1498d85c2c9644f9 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Tue, 11 Sep 2012 16:09:34 +0200 Subject: [PATCH] event-loop: export wl_event_loop_dispatch_idle() When integrating the wayland event-loop into another event-loop, we currently have no chance of checking whether there are pending idle sources that have to be called. This patch exports the "dispatch_idle_sources()" call so other event loops can call this before going to sleep. This is what wl_event_loop_dispatch() currently does so we simply allow external event-loops to do the same now. To avoid breaking existing applications, we keep the call to dispatch_idle_sources() in wl_event_loop_dispatch() for now. However, if we want we can remove this later and require every application to call this manually. This needs to be discussed, but the overhead is negligible so we will probably leave it as it is. This finally allows to fully integrate the wayland-server API into existing event-loops without any nasty workarounds. Signed-off-by: David Herrmann --- src/event-loop.c | 6 +++--- src/wayland-server.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/event-loop.c b/src/event-loop.c index df4b8b82..93392268 100644 --- a/src/event-loop.c +++ b/src/event-loop.c @@ -378,8 +378,8 @@ post_dispatch_check(struct wl_event_loop *loop) return n; } -static void -dispatch_idle_sources(struct wl_event_loop *loop) +WL_EXPORT void +wl_event_loop_dispatch_idle(struct wl_event_loop *loop) { struct wl_event_source_idle *source; @@ -398,7 +398,7 @@ wl_event_loop_dispatch(struct wl_event_loop *loop, int timeout) struct wl_event_source *source; int i, count, n; - dispatch_idle_sources(loop); + wl_event_loop_dispatch_idle(loop); count = epoll_wait(loop->epoll_fd, ep, ARRAY_LENGTH(ep), timeout); if (count < 0) diff --git a/src/wayland-server.h b/src/wayland-server.h index 3c567291..45cc61cb 100644 --- a/src/wayland-server.h +++ b/src/wayland-server.h @@ -67,6 +67,7 @@ void wl_event_source_check(struct wl_event_source *source); int wl_event_loop_dispatch(struct wl_event_loop *loop, int timeout); +void wl_event_loop_dispatch_idle(struct wl_event_loop *loop); struct wl_event_source *wl_event_loop_add_idle(struct wl_event_loop *loop, wl_event_loop_idle_func_t func, void *data);