[PATCH] display: Adds wl_display_flush to send buffered commands

Robert Bragg robert at linux.intel.com
Tue May 10 09:51:52 PDT 2011


Previously for wayland clients to flush buffered connection data to the
compositor they needed to first register an event-mask-update-callback
via wl_display_get_fd() to determine if there is anything writeable
pending.  (NB: It's considered an error to iterate connection data with
an invalid mask)

Since it's only possible to register a single update callback currently
it's a bit awkward if you want to allow multiple orthogonal components
to flush the connection data, such as Cogl and Clutter which both want
to interact with wayland and may want to flush commands at different
times.

This adds a mechanism, wl_display_flush(), which makes it possible to
flush writeable connection data without first checking the event mask.
---
 wayland/wayland-client.c |    7 +++++++
 wayland/wayland-client.h |    1 +
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/wayland/wayland-client.c b/wayland/wayland-client.c
index 531807d..59c68f7 100644
--- a/wayland/wayland-client.c
+++ b/wayland/wayland-client.c
@@ -593,6 +593,13 @@ wl_display_iterate(struct wl_display *display, uint32_t mask)
 	}
 }
 
+WL_EXPORT void
+wl_display_flush(struct wl_display *display)
+{
+	while (display->mask & WL_DISPLAY_WRITABLE)
+		wl_display_iterate (display, WL_DISPLAY_WRITABLE);
+}
+
 WL_EXPORT uint32_t
 wl_display_allocate_id(struct wl_display *display)
 {
diff --git a/wayland/wayland-client.h b/wayland/wayland-client.h
index f1ac797..eefb840 100644
--- a/wayland/wayland-client.h
+++ b/wayland/wayland-client.h
@@ -60,6 +60,7 @@ int wl_display_get_fd(struct wl_display *display,
 		      wl_display_update_func_t update, void *data);
 uint32_t wl_display_allocate_id(struct wl_display *display);
 void wl_display_iterate(struct wl_display *display, uint32_t mask);
+void wl_display_flush(struct wl_display *display);
 int wl_display_sync_callback(struct wl_display *display,
 			     wl_display_sync_func_t func, void *data);
 int wl_display_frame_callback(struct wl_display *display,
-- 
1.7.0.4



More information about the wayland-devel mailing list