The protocol is sent over a UNIX domain stream socket. Currently, the
endpoint is named \0wayland, but it is subject
to change. The protocol is message-based. A message sent by a client
to the server is called request. A message from the server
to a client is called event. Every message is structured as
32-bit words, values are represented in the host's byte-order.
The message header has 2 words in it:
- The first word is the sender's object id (32-bit).
- The second has 2 parts of 16-bit. The upper 16-bits are the message
size in bytes, starting at the header (i.e. it has a minimum value of 8).
The lower is the request/event opcode.
The payload describes the request/event arguments. Every argument is always
aligned to 32-bits. There is no prefix that describes the type, but it is
inferred implicitly from the xml specification.
The representation of argument types are as follows:
- "int" or "uint": The value is the 32-bit value of the signed/unsigned
int.
- "string": Starts with an unsigned 32-bit length, followed by the
string contents, including terminating NUL byte, then padding to a
32-bit boundary.
- "object": A 32-bit object ID.
- "new_id": the 32-bit object ID. On requests, the client
decides the ID. The only events with "new_id" are advertisements of
globals, and the server will use IDs below 0x10000.
- "array": Starts with 32-bit array size in bytes, followed by the array
contents verbatim, and finally padding to a 32-bit boundary.
- "fd": the file descriptor is not stored in the message buffer, but in
the ancillary data of the UNIX domain socket message (msg_control).
root
2012-01-26