summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2012-10-15 11:38:20 -0400
committerKristian Høgsberg <krh@bitplanet.net>2012-10-15 11:38:24 -0400
commitf8d55a878c578c3fa023e0ad0706d0d831ee450a (patch)
tree1f3771d6bb3cd7d1b340c3bb573ed9da27fdfd24 /src
parent78cfa967681c965d23f6cbf76e080bbb0b564ff6 (diff)
client: Return number of events dispatched from dispatch functions
To let clients determine whether any events were dispatched, we return the number of dispatched events. An event source with an event queue (such as wl_display or an X connection) may queue up event as a result of processing a different event source (data on a network socket, timerfd etc). After dispatching data from fd (or just before blocking) we have to check such event sources, which is what wl_event_source_check() is used for. A checked event source will have its handler called with mask=0 just before blocking. If any work is done in any of these handlers, we have to check all the checked sources again, since the work could have queued up events in a different source. This is why the event handlers must return a positive number if events were handled. Which in turn is why we need the wl_display dispatch functions to return that as well.
Diffstat (limited to 'src')
-rw-r--r--src/wayland-client.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/wayland-client.c b/src/wayland-client.c
index 9077338..9f24700 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -556,7 +556,7 @@ static int
dispatch_queue(struct wl_display *display,
struct wl_event_queue *queue, int block)
{
- int len, size;
+ int len, size, count;
pthread_mutex_lock(&display->mutex);
@@ -580,12 +580,12 @@ dispatch_queue(struct wl_display *display,
pthread_cond_wait(&queue->cond, &display->mutex);
}
- while (!wl_list_empty(&queue->event_list))
+ for (count = 0; !wl_list_empty(&queue->event_list); count++)
dispatch_event(display, queue);
pthread_mutex_unlock(&display->mutex);
- return 0;
+ return count;
}
WL_EXPORT int