[Xcb] Xevent and XCBEvent

Josh Triplett josh.trip at verizon.net
Sun May 22 17:52:54 PDT 2005

Jamey Sharp wrote:
> On Sat, 2005-05-07 at 09:00 +0200, Vincent Torri wrote:
> Hey Vincent! I just sat down to fix your problem, and realized I need
> Josh to tell me how.


>>In a function of ecore, an XEvent is defined as follows :
>>   xev.xclient.type = ClientMessage;
>>   xev.xclient.display = disp;
>>   xev.xclient.window = win;
>>   xev.xclient.message_type = Atom1;
>>   xev.xclient.format = 32;
>>   xev.xclient.data.l[0] = Atom2;
>>   xev.xclient.data.l[1] = CurrentTime;
>>1) How could I fill the char event[32] that I have to pass to XCBSendEvent
>>with these informations ?

Hmmm.  I was going to suggest that you should create an
XCBClientMessageEvent and then pass the address to XCBSendEvent, but I
just realized that XCBSendEvent always assumes the client buffer is 32
bytes long, and will therefore read data past the end of the array if
attempting to send an event which is less than 32 bytes long.
XCBClientMessageEvent has data out to 32 bytes, but other events don't.

Any suggestions, Jamey?  Having to create a 32-byte array and copy the
data in is really ugly; even uglier is creating a 32-byte (or 8-dword
for alignment) array, casting the pointer to an XCBSomethingEvent, and
setting the members that way.  Padding every single event structure out
to 32 bytes seems highly suboptimal as well.

>>2) I've already asked the question, but there was no precise answer : i
>>don't know where the data field of th xclient field of a XEvent can be
>>found in XCB. Doe someone have an idea about that ?
> The ClientMessage event is much like the ChangeProperty request: it has
> a format field (indicating that the data is a list of 8-, 16-, or 32-bit
> quantities) and then a list of elements of the given length. Unlike
> ChangeProperty, clients routinely need to both construct and examine
> this event.
> Josh, in the short term, how should we encode this union-of-lists type
> such that it'll be a minimum pain to work with?

This is now fixed:
>   <union name="ClientMessageData">
>     <!-- The format member of the ClientMessage event determines which array
>          to use. -->
>     <list type="CARD8"  name="data8" ><value>20</value></list> <!--  8 -->
>     <list type="CARD16" name="data16"><value>10</value></list> <!-- 16 -->
>     <list type="CARD32" name="data32"><value>5</value></list>  <!-- 32 -->
>   </union>
>   <event name="ClientMessage" number="33">
>     <field type="CARD8" name="format" /> <!-- 8, 16, or 32. -->
>     <field type="WINDOW" name="window" />
>     <field type="ATOM" name="type" />
>     <field type="ClientMessageData" name="data" />
>   </event>

Note that this was only easy because the lists are fixed-length.

- Josh Triplett
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 251 bytes
Desc: OpenPGP digital signature
Url : http://lists.freedesktop.org/archives/xcb/attachments/20050522/ad29f8bf/signature.pgp

More information about the xcb mailing list