clients: Use wl_display_dispatch_pending()
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index eed9d5c..56759fc 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -769,13 +769,19 @@
 wayland_compositor_handle_event(int fd, uint32_t mask, void *data)
 {
 	struct wayland_compositor *c = data;
+	int count = 0;
 
 	if (mask & WL_EVENT_READABLE)
-		wl_display_dispatch(c->parent.wl_display);
+		count = wl_display_dispatch(c->parent.wl_display);
 	if (mask & WL_EVENT_WRITABLE)
 		wl_display_flush(c->parent.wl_display);
 
-	return 1;
+	if (mask == 0) {
+		count = wl_display_dispatch_pending(c->parent.wl_display);
+		wl_display_flush(c->parent.wl_display);
+	}
+
+	return count;
 }
 
 static void
@@ -856,6 +862,8 @@
 	if (c->parent.wl_source == NULL)
 		goto err_display;
 
+	wl_event_source_check(c->parent.wl_source);
+
 	return &c->base;
 
 err_display: