#define XCB_ERROR 0
#define XCB_REPLY 1
+#define XCB_XGE_EVENT 35
struct event_list {
xcb_generic_event_t *event;
{
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;
}
c->in.request_completed = c->in.request_read - 1;
}
- if(genrep.response_type == XCB_ERROR)
- c->in.request_completed = c->in.request_read;
while(c->in.pending_replies &&
XCB_SEQUENCE_COMPARE (c->in.pending_replies->request, <=, c->in.request_completed))
c->in.pending_replies_tail = &c->in.pending_replies;
free(oldpend);
}
+
+ if(genrep.response_type == XCB_ERROR)
+ c->in.request_completed = c->in.request_read;
}
if(genrep.response_type == XCB_ERROR || genrep.response_type == XCB_REPLY)
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);
if(!cur)
{
_xcb_conn_shutdown(c);
+ free(buf);
return 0;
}
cur->reply = buf;
}
}
-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)
{
_xcb_lock_io(c);
/* FIXME: follow X meets Z architecture changes. */
- if(_xcb_in_read(c)) /* _xcb_in_read shuts down the connection on error */
+ ret = get_event(c);
+ if(!ret && _xcb_in_read(c)) /* _xcb_in_read shuts down the connection on error */
ret = get_event(c);
_xcb_unlock_io(c);
}