[Xcb-commit] xcb

Josh Triplett josh at kemper.freedesktop.org
Sun Jul 30 14:43:39 PDT 2006


 xcb/src/xcb.h    |   18 ++++++++++++++++++
 xcb/src/xcb_in.c |   18 ++++++++++++++++++
 2 files changed, 36 insertions(+)

New commits:
diff-tree 8e06bf2fd09bd57f8f3adb6172e3d69a09647f45 (from 3cc5d9000f5aef5c089c24647a95e89fe7fd8d56)
Author: Josh Triplett <josh at freedesktop.org>
Date:   Sun Jul 30 14:41:19 2006 -0700

    Add XCBRequestCheck function needed for Plan 7.

diff --git a/xcb/src/xcb.h b/xcb/src/xcb.h
index f720469..abab165 100644
--- a/xcb/src/xcb.h
+++ b/xcb/src/xcb.h
@@ -273,6 +273,24 @@ XCBGenericEvent *XCBWaitForEvent(XCBConn
 XCBGenericEvent *XCBPollForEvent(XCBConnection *c, int *error);
 
 /**
+ * @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.
+ * @return The error for the request, or NULL if none can ever arrive.
+ *
+ * The XCBVoidCookie cookie supplied to this function must have resulted from
+ * a call to XCB[RequestName]Checked().  This function will block until one of
+ * two conditions happens.  If an error is received, it will be returned.  If
+ * a reply to a subsequent request has already arrived, no error can arrive
+ * for this request, so this function will return NULL.
+ *
+ * Note that this function will perform a sync if needed to ensure that the
+ * sequence number will advance beyond that provided in cookie; this is a
+ * convenience to avoid races in determining whether the sync is needed.
+ */
+XCBGenericError *XCBRequestCheck(XCBConnection *c, XCBVoidCookie cookie);
+
+/**
  * @brief Returns the last sequence number that the server is known to
  * have processed.
  * @param c: The connection to the X server.
diff --git a/xcb/src/xcb_in.c b/xcb/src/xcb_in.c
index 6433f0e..d1118fd 100644
--- a/xcb/src/xcb_in.c
+++ b/xcb/src/xcb_in.c
@@ -402,6 +402,24 @@ XCBGenericEvent *XCBPollForEvent(XCBConn
     return ret;
 }
 
+XCBGenericError *XCBRequestCheck(XCBConnection *c, XCBVoidCookie cookie)
+{
+    /* FIXME: this could hold the lock to avoid syncing unnecessarily, but
+     * that would require factoring the locking out of XCBGetInputFocus,
+     * XCBGetInputFocusReply, and XCBWaitForReply. */
+    XCBGenericError *ret;
+    void *reply;
+    if(XCB_SEQUENCE_COMPARE(cookie.request,>,c->in.request_expected)
+       && XCB_SEQUENCE_COMPARE(cookie.request,>,c->in.request_completed))
+    {
+        free(XCBGetInputFocusReply(c, XCBGetInputFocus(c), &ret));
+        assert(!ret);
+    }
+    reply = XCBWaitForReply(c, cookie.request, &ret);
+    assert(!reply);
+    return ret;
+}
+
 unsigned int XCBGetRequestRead(XCBConnection *c)
 {
     unsigned int ret;


More information about the xcb-commit mailing list