[PATCH wayland v3] client: add a public function to make a roundtrip on a custom queue

Giulio Camuffo giuliocamuffo at gmail.com
Wed Jul 23 06:06:13 PDT 2014


wl_display_roundtrip(display) works on the default queue. Add a
parallel wl_event_queue_roundtrip(queue).
---

v3: renamed wl_display_roundtrip_queue() to wl_event_queue_roundtrip()

 src/wayland-client.c | 29 +++++++++++++++++++++++------
 src/wayland-client.h |  1 +
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/src/wayland-client.c b/src/wayland-client.c
index e8aab7e..b195e21 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -831,29 +831,30 @@ static const struct wl_callback_listener sync_listener = {
 	sync_callback
 };
 
-/** Block until all pending request are processed by the server
+/** Block until all pending request on a queue are processed by the server
  *
- * \param display The display context object
+ * \param queue The queue on which to run the roundtrip
  * \return The number of dispatched events on success or -1 on failure
  *
  * Blocks until the server process all currently issued requests and
- * sends out pending events on all event queues.
+ * sends out pending events on the given event queue.
  *
  * \memberof wl_display
  */
 WL_EXPORT int
-wl_display_roundtrip(struct wl_display *display)
+wl_event_queue_roundtrip(struct wl_event_queue *queue)
 {
 	struct wl_callback *callback;
 	int done, ret = 0;
 
 	done = 0;
-	callback = wl_display_sync(display);
+	callback = wl_display_sync(queue->display);
 	if (callback == NULL)
 		return -1;
+	wl_proxy_set_queue(callback, queue);
 	wl_callback_add_listener(callback, &sync_listener, &done);
 	while (!done && ret >= 0)
-		ret = wl_display_dispatch(display);
+		ret = wl_display_dispatch_queue(queue->display, queue);
 
 	if (ret == -1 && !done)
 		wl_callback_destroy(callback);
@@ -861,6 +862,22 @@ wl_display_roundtrip(struct wl_display *display)
 	return ret;
 }
 
+/** Block until all pending request on the default queue are processed by the server
+ *
+ * \param display The display context object
+ * \return The number of dispatched events on success or -1 on failure
+ *
+ * Blocks until the server process all currently issued requests and
+ * sends out pending events on the default event queue.
+ *
+ * \memberof wl_display
+ */
+WL_EXPORT int
+wl_display_roundtrip(struct wl_display *display)
+{
+	wl_event_queue_roundtrip(&display->default_queue);
+}
+
 static int
 create_proxies(struct wl_proxy *sender, struct wl_closure *closure)
 {
diff --git a/src/wayland-client.h b/src/wayland-client.h
index 2a32785..465a39e 100644
--- a/src/wayland-client.h
+++ b/src/wayland-client.h
@@ -120,6 +120,7 @@ struct wl_display;
 struct wl_event_queue;
 
 void wl_event_queue_destroy(struct wl_event_queue *queue);
+int wl_event_queue_roundtrip(struct wl_event_queue *queue);
 
 void wl_proxy_marshal(struct wl_proxy *p, uint32_t opcode, ...);
 void wl_proxy_marshal_array(struct wl_proxy *p, uint32_t opcode,
-- 
2.0.2



More information about the wayland-devel mailing list