X-Git-Url: http://git.demorecorder.com/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fxcb_in.c;h=f61377274f49fce15e7e54d1bfb6eef7919ae253;hb=db332dcda989b5b021dc220c102666f695c772cf;hp=2997de4c43f24e88128c6258f6fcd570ad525709;hpb=e20a31d72b8838cdf31b568431b5ad78492c1481;p=free-sw%2Fxcb%2Flibxcb diff --git a/src/xcb_in.c b/src/xcb_in.c index 2997de4..f613772 100644 --- a/src/xcb_in.c +++ b/src/xcb_in.c @@ -39,6 +39,7 @@ #define XCB_ERROR 0 #define XCB_REPLY 1 +#define XCB_XGE_EVENT 35 struct event_list { xcb_generic_event_t *event; @@ -77,6 +78,7 @@ static int read_packet(xcb_connection_t *c) { xcb_generic_reply_t genrep; int length = 32; + int eventlength = 0; /* length after first 32 bytes for GenericEvents */ void *buf; pending_reply *pend = 0; struct event_list *event; @@ -141,17 +143,36 @@ static int read_packet(xcb_connection_t *c) length += genrep.length * 4; } - buf = malloc(length + (genrep.response_type == XCB_REPLY ? 0 : sizeof(uint32_t))); + /* XGE events may have sizes > 32 */ + if (genrep.response_type == XCB_XGE_EVENT) + { + eventlength = ((xcb_ge_event_t*)&genrep)->length * 4; + } + + buf = malloc(length + eventlength + + (genrep.response_type == XCB_REPLY ? 0 : sizeof(uint32_t))); if(!buf) { _xcb_conn_shutdown(c); return 0; } + if(_xcb_in_read_block(c, buf, length) <= 0) { free(buf); return 0; } + + /* pull in XGE event data if available, append after event struct */ + if (eventlength) + { + if(_xcb_in_read_block(c, &((xcb_generic_event_t*)buf)[1], eventlength) <= 0) + { + free(buf); + return 0; + } + } + if(pend && (pend->flags & XCB_REQUEST_DISCARD_REPLY)) { free(buf); @@ -170,6 +191,7 @@ static int read_packet(xcb_connection_t *c) if(!cur) { _xcb_conn_shutdown(c); + free(buf); return 0; } cur->reply = buf; @@ -231,7 +253,7 @@ static void free_reply_list(struct reply_list *head) } } -static int read_block(const int fd, void *buf, const size_t len) +static int read_block(const int fd, void *buf, const ssize_t len) { int done = 0; while(done < len)