[Xcb] [PATCH] Receive selected replies in event queue.

jamey at minilop.net jamey at minilop.net
Thu Sep 18 18:12:16 PDT 2008


Some clients want to receive all responses in sequence number order,
without distinguishing between replies, events, and errors.  Xlib wants
this so it doesn't have to manually merge the reply and event streams
from XCB.  Other clients want this because they want to process replies
asynchronously as soon as they arrive rather than waiting a while and
then forcing them.

Add a new request flag, XCB_REQUEST_QUEUE_RESPONSE.  If set on a
request, XCB will put the corresponding response in the event queue.
A client can then use the event queue as an in-order queue of all
responses, except for replies sent from other clients which those
clients want to receive via explicit forcing of cookies.

Commit by Josh Triplett and Jamey Sharp.
---
 src/xcb_in.c |    5 +++--
 src/xcbext.h |    3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/xcb_in.c b/src/xcb_in.c
index 2997de4..599c99d 100644
--- a/src/xcb_in.c
+++ b/src/xcb_in.c
@@ -162,8 +162,9 @@ static int read_packet(xcb_connection_t *c)
         ((xcb_generic_event_t *) buf)->full_sequence = c->in.request_read;
 
     /* reply, or checked error */
-    if( genrep.response_type == XCB_REPLY ||
-       (genrep.response_type == XCB_ERROR && pend && (pend->flags & XCB_REQUEST_CHECKED)))
+    if(!(pend && (pend->flags & XCB_REQUEST_QUEUE_RESPONSE)) &&
+       ((pend && (pend->flags & XCB_REQUEST_CHECKED) && genrep.response_type == XCB_ERROR) ||
+        genrep.response_type == XCB_REPLY))
     {
         reader_list *reader;
         struct reply_list *cur = malloc(sizeof(struct reply_list));
diff --git a/src/xcbext.h b/src/xcbext.h
index 01dd590..856ad3d 100644
--- a/src/xcbext.h
+++ b/src/xcbext.h
@@ -54,7 +54,8 @@ typedef struct {
 enum xcb_send_request_flags_t {
     XCB_REQUEST_CHECKED = 1 << 0,
     XCB_REQUEST_RAW = 1 << 1,
-    XCB_REQUEST_DISCARD_REPLY = 1 << 2
+    XCB_REQUEST_DISCARD_REPLY = 1 << 2,
+    XCB_REQUEST_QUEUE_RESPONSE = 1 << 3 /* Put the response in the event queue */
 };
 
 unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *request);
-- 
1.5.6.5

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://lists.freedesktop.org/archives/xcb/attachments/20080918/fcd9618d/attachment.pgp 


More information about the Xcb mailing list