Hands-on Projects for the Linux Graphics Subsystem

The X Protocol messages

At section 1 we have examined the X client-server interaction at the interprocess
communication layer between the X client and the X server (mainly Sockets)
and also the initial handshake between the X Client and the X Server that allows for
the first important info exchange, as the X Protocol determines,
for instance the supported color depth of the X Server.

We also statred discussing the stage of the established client-server operation at the
X Protocol layer, and more specifically at the X client's requests.
As we see from the following figure of the
X Window System core protocol Wikipedia article the client sends requests to the X server
and receives replies to those requests and also events (for instance a mouse key pressed on the
client's window):

In the current section we examine the client request with some more detail and we make some
experiments using as example the X Client from the section 1:

We have seen in section 1 that the Xlib routines used by the X client create request
structs, that usually are grouped together and finally are flushed to the X server.
For instance, as seen in section 1.2 function
XCreateSimpleWindow() creates struct
xCreateWindowReq. The Xlib functions source code can be examined in the X11 directory
as we see in the following figure:

The request structs used by the various Xlib functions to exchange info at the X Protocol
layer are defined in
Xproto.h
. For instance xCreateWindowReq and xChangeWindowAttributesReq are shown bellow:

As we notice the request struct fields may vary, however two fields are common, namely reqType
and length. The first is the id of the specific request, while the latter the size of the
request struct in bytes. reqType takes one of the following values, defined in
Xproto.h: