[Xcb] [RFC libxcb 4/5] Add xcb_rcv_event with optional out for full_seq

Daniel Martin consume.noise at gmail.com
Tue Jun 4 15:52:05 PDT 2013


Add the function

    xcb_generic_event_t *
    xcb_rcv_event(xcb_connection_t *c,
                  xcb_rcv_style_t style,
                  uint64_t *full_sequence).

Internally, it makes the same as
    xcb_wait_for_event(),
    xcb_poll_for_event() or
    xcb_poll_for_queued_event()
depending on the style option (XCB_RCV_QUEUED, XCB_RCV_POLL,
XCB_RCV_WAIT). Additionally to that, it has an optional out parameter
full_sequence to get the sequence number for an event. Which has been
removed from the event structure lately.

Signed-off-by: Daniel Martin <consume.noise at gmail.com>
---
 src/xcb.h    | 26 ++++++++++++++++++++++----
 src/xcb_in.c |  5 +++++
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/src/xcb.h b/src/xcb.h
index b804d9f..3cc85c0 100644
--- a/src/xcb.h
+++ b/src/xcb.h
@@ -261,11 +261,14 @@ void xcb_prefetch_maximum_request_length(xcb_connection_t *c);
 
 /* xcb_in.c */
 
-/* Atm. internally used only */
+/**
+ * @enum xcb_rcv_style_t
+ * @brief Howto to retrieve data.
+ */
 typedef enum xcb_rcv_style_t {
-    XCB_RCV_QUEUED,
-    XCB_RCV_POLL,
-    XCB_RCV_WAIT
+    XCB_RCV_QUEUED, /**< Just examine the queue. Don't cause any I/O. */
+    XCB_RCV_POLL,   /**< Poll the connection once if nothing is in the queue. */
+    XCB_RCV_WAIT    /**< Wait until something can be returned. */
 } xcb_rcv_style_t;
 
 /**
@@ -310,6 +313,21 @@ xcb_generic_event_t *xcb_poll_for_event(xcb_connection_t *c);
 xcb_generic_event_t *xcb_poll_for_queued_event(xcb_connection_t *c);
 
 /**
+ * @brief Returns the next event with or without reading from the connection.
+ * @param c: The connection to the X server.
+ * @param style: Howto behave if there's no queued event.
+ * @return The next event from the server or NULL.
+ *
+ * This function returns the next event from the queue. If there is nothing
+ * in the queue and @style is
+ * - XCB_RCV_QUEUED: then it returns NULL,
+ * - XCB_RCV_POLL: then it polls the connection once for pending data and
+ *   returns the next event - if one became available - or NULL,
+ * - XCB_RCV_WAIT: then it blocks until the next event can be returned.
+ */
+xcb_generic_event_t *xcb_rcv_event(xcb_connection_t *c, xcb_rcv_style_t style, uint64_t *full_sequence);
+
+/**
  * @brief Return the error for a request, or NULL if none can ever arrive.
  * @param c: The connection to the X server.
  * @param cookie: The request cookie.
diff --git a/src/xcb_in.c b/src/xcb_in.c
index e82baff..b8eeeb0 100644
--- a/src/xcb_in.c
+++ b/src/xcb_in.c
@@ -562,6 +562,11 @@ xcb_generic_event_t *xcb_poll_for_queued_event(xcb_connection_t *c)
     return get_event_locked(c, XCB_RCV_QUEUED, NULL);
 }
 
+xcb_generic_event_t *xcb_rcv_event(xcb_connection_t *c, xcb_rcv_style_t style, uint64_t *full_sequence)
+{
+    return get_event_locked(c, style, full_sequence);
+}
+
 xcb_generic_error_t *xcb_request_check(xcb_connection_t *c, xcb_void_cookie_t cookie)
 {
     uint64_t request;
-- 
1.8.3



More information about the Xcb mailing list