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.
This commit is contained in:
Peter Hutterer 2007-05-15 16:28:19 +09:30
parent b08a5909da
commit 6532c715c3
2 changed files with 40 additions and 2 deletions

View File

@ -115,6 +115,23 @@ typedef struct {
uint32_t full_sequence; /**< full sequence */
} xcb_generic_event_t;
/**
* @brief GE event
*
* An event as sent by the XGE extension. The length field specifies the
* number of 4-byte blocks trailing the struct.
*/
typedef struct {
uint8_t response_type; /**< Type of the response */
uint8_t pad0; /**< Padding */
uint16_t sequence; /**< Sequence number */
uint32_t length;
uint16_t event_type;
uint16_t pad1;
uint32_t pad[5]; /**< Padding */
uint32_t full_sequence; /**< full sequence */
} xcb_ge_event_t;
/**
* @brief Generic error.
*

View File

@ -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);