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 <dh.herrmann@googlemail.com>
This commit is contained in:
David Herrmann 2012-09-11 16:09:34 +02:00 committed by Kristian Høgsberg
parent 9fe135c46f
commit 003a946aa6
2 changed files with 4 additions and 3 deletions

View file

@ -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)

View file

@ -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);