diff options
author | Peter Hutterer <peter@cs.unisa.edu.au> | 2007-05-15 16:28:19 +0930 |
---|---|---|
committer | Peter Hutterer <peter@cs.unisa.edu.au> | 2008-05-21 21:22:13 +0930 |
commit | 6532c715c3805128b9976ab208f1426f691056a2 (patch) | |
tree | 442f664f63dab54cf11e271273d8a4413dc57b64 /src/xcb_in.c | |
parent | b08a5909daf589d5e06c17c55d044f39c1d3479a (diff) |
Add xcb_ge_event_t and handling for long events.
GenericEvent can be more than 32 bytes long. Ensure that the required data is
pulled off the wire and tack it onto the event.
Due to the structure of the xcb_generic_event_t, the data is appended AFTER
the full_sequence field.
Diffstat (limited to 'src/xcb_in.c')
-rw-r--r-- | src/xcb_in.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/xcb_in.c b/src/xcb_in.c index 2997de4..27ccc99 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; @@ -76,7 +77,8 @@ static void wake_up_next_reader(xcb_connection_t *c) static int read_packet(xcb_connection_t *c) { xcb_generic_reply_t genrep; - int length = 32; + int length = 32, + 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); |