summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2011-08-02 11:59:22 -0400
committerKristian Høgsberg <krh@bitplanet.net>2011-08-02 11:59:22 -0400
commit61fbec3d17c5b9113eb6158ef44ccc3567cf2d6d (patch)
treefd6d592b6cc94f3853a6618eeee5f4b5d3f86920
parent70ea1fa4cfe5d7b887c94bb701049c10d934ecd7 (diff)
Add force_roundtrip helper
-rw-r--r--wayland/wayland-client.c28
-rw-r--r--wayland/wayland-client.h1
2 files changed, 29 insertions, 0 deletions
diff --git a/wayland/wayland-client.c b/wayland/wayland-client.c
index ce71833..0f970b1 100644
--- a/wayland/wayland-client.c
+++ b/wayland/wayland-client.c
@@ -468,6 +468,34 @@ wl_surface_frame_callback(struct wl_surface *surface,
return wl_callback_setup(wl_surface_frame(surface), func, data);
}
+
+static void
+sync_callback(void *data, struct wl_callback *callback, uint32_t time)
+{
+ int *done = data;
+
+ *done = 1;
+ wl_callback_destroy(callback);
+}
+
+static const struct wl_callback_listener sync_listener = {
+ sync_callback
+};
+
+WL_EXPORT void
+wl_display_roundtrip(struct wl_display *display)
+{
+ struct wl_callback *callback;
+ int done;
+
+ done = 0;
+ callback = wl_display_sync(display);
+ wl_callback_add_listener(callback, &sync_listener, &done);
+ wl_display_iterate(display, WL_DISPLAY_WRITABLE);
+ while (!done)
+ wl_display_iterate(display, WL_DISPLAY_READABLE);
+}
+
static void
handle_event(struct wl_display *display,
uint32_t id, uint32_t opcode, uint32_t size)
diff --git a/wayland/wayland-client.h b/wayland/wayland-client.h
index 21f071d..a7041c3 100644
--- a/wayland/wayland-client.h
+++ b/wayland/wayland-client.h
@@ -65,6 +65,7 @@ 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_callback_func_t func, void *data);
+void wl_display_roundtrip(struct wl_display *display);
int wl_callback_setup(struct wl_callback *callback,
wl_callback_func_t func, void *data);