Site hosted by Angelfire.com: Build your free website today!

Hands-on Projects for the Linux Graphics Subsystem

New book from Christos Karayiannis

Available in Amazon Kindle format at:

amazon.com   amazon.co.uk   amazon.de   amazon.es   amazon.fr   amazon.it

Hands-on Experiment: find the messages exchanged between the X client-server

We will use the first example of section 1.1 (actually the second version of this program we mentioned in section 1.1) to illustrate the communication between the X client and the X server:


  /*
   Simple Xlib application drawing a box in a window.
   To Compile: gcc -O2 -Wall -o test test.c -L /usr/X11R6/lib -lX11 -lm
 */
 
 #include<X11/Xlib.h>
 #include<stdio.h>
 #include<stdlib.h> // prevents error for exit on line 18 when compiling with gcc
 int main() {
   Display *d;
   int s;
   Window w;
   XEvent e;
 
                        /* open connection with the server */
   d=XOpenDisplay(NULL);
   if(d==NULL) {
     printf("Cannot open display\n");
     exit(1);
   }
   s=DefaultScreen(d);
 
                        /* create window */
   w=XCreateSimpleWindow(d, RootWindow(d, s), 10, 10, 100, 100, 1,
                         BlackPixel(d, s), WhitePixel(d, s));
 
   // Prosses Window Close Event through event handler so XNextEvent does Not fail
        Atom delWindow = XInternAtom( d, "WM_DELETE_WINDOW", 0 );
        XSetWMProtocols(d , w, &delWindow, 1);
 
                        /* select kind of events we are interested in */
   XSelectInput(d, w, ExposureMask | KeyPressMask);
 
                        /* map (show) the window */
   XMapWindow(d, w);
 
                        /* event loop */
   while(1) {
     XNextEvent(d, &e);
                        /* draw or redraw the window */
     if(e.type==Expose) {
       XFillRectangle(d, w, DefaultGC(d, s), 20, 20, 10, 10);
     }
                        /* exit on key press */
     if(e.type==KeyPress)
       break;
 
     // Handle Windows Close Event
     if(e.type==ClientMessage)
        break;
   }
 
                        /* destroy our window */
   XDestroyWindow(d, w);
 
                        /* close connection to server */
   XCloseDisplay(d);
 
   return 0;
 }

I compile the program as:

gcc test.c -o test -lX11
In my Ubuntu sytem gcc complained that Xlib.h was missing and I had to download the xorg-dev package either by using the 'Ubuntu Softtare Center' from the desktop or by using the following command from xterm:
sudo aptitude install xorg-dev
I run the program as:
./test &
and I take the little white window with the black square, that lives until a key is pressed. The program's window is the active one in the following image:

Next I will run the program using the xtrace utility to have a look behind the scene.

Xtrace

For xtrace we read from the xtrace Debian page:

Description

Xtrace fakes an X server and forwards all connections to a real X server, displaying the communication between the clients and the server in an (well, theoretically) human readable form.
For further reference take a look at the manpage.

Examples

xtrace -D:9 -d:0 -k

To run a X client program under xtrace I downloaded the xtrace packet in Ubuntu and I started the xtrace utility from the command line using a 'fakedisplay', for instance display 9. By default in a common X Window session we use display 0, which is in the previous command the display that connections from the fake display 9 are forwarded. Recall that a second X Server would make use of display 1, and we would be transferred to display 1 by using Ctrl+Alt+F8 (instead Ctrl+Alt+F7 for display 0) and so on. Therefore number 9 is used as a fake display, since rarely a system needs more than one or two displays. The command that redirects 'fake' display 9 to display 0 is:

xtrace -D:9 -d:0
and then we run the X client program, for instance xtrace (or xeyes) as:
 
xterm -display :9
A number of messages exchanged between the X server and the client appear immediately in the first xterm window (the one that runned xtrace -D:9 -d:0). To demonstrate this message exchange I repeat the procedure as:
xtrace -D:9 -d:0 >loglog
where loglog the log filename and then:
xeyes -display :9
The messages captured by logfile are inspected using:
more loglog
as shown in the following image:

Back then to our simple program we have to notice that X clients usually make use of an '-display' option to allow the user choose a display. On the other hand for our simple 'test' program (the first of section 1.1) there is no dislpay option. To overcome this after we start the fake server as:

xtrace -D:9 -d:0 >logfile
we run the simple program as:
DISPLAY=:9.0 ./test 
The contents of logfile are listed bellow:

000:<: am lsb-first want 11:0 authorising with 'MIT-MAGIC-COOKIE-1' of length 16
000:>: Success, version is 11:0 vendor='The X.Org Foundation' release=10706000 resource-id=0x04000000 
resource-mask=0x001fffff motion-buffer-size=256 max-request-len=65535 image-byte-order=LSBFirst(0x00) 
bitmap-bit-order=LeastSignificant(0x00) scanline-unit=32 scanline-pad=32 min-keycode=0x08 max-keycode=0x00 
pixmap-formats={depth=1 bits/pixel=1 scanline-pad=32},{depth=4 bits/pixel=8 scanline-pad=32},{depth=8 bits/pixel=8 
scanline-pad=32},{depth=15 bits/pixel=16 scanline-pad=32},{depth=16 bits/pixel=16 scanline-pad=32},{depth=24 
bits/pixel=32 scanline-pad=32},{depth=32 bits/pixel=32 scanline-pad=32}; roots={root=0x00000101 
default-colormap=0x00000020 white-pixel=0x00ffffff black-pixel=0x00000000 
input-mask=KeyPress,KeyRelease,EnterWindow,LeaveWindow,Exposure,StructureNotify,
SubstructureNotify,SubstructureRedirect,FocusChange,PropertyChange,ColormapChange
 width[pixel]=1024 height[pixel]=768 width[mm]=302 height[mm]=222 min-installed-maps=1 max-installed-maps=1 
root=0x00000021 backing-stores=Never(0x00) save-unders=false(0x00) root-depth=24 allowed depths={depth=24 
visuals={id=0x00000021 class=TrueColor(0x04) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 
green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000c2 class=TrueColor(0x04) bits/rgb-value=8 
colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000c3 
class=TrueColor(0x04) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 
blue-mask=0x000000ff},{id=0x000000c4 class=TrueColor(0x04) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 
green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000c5 class=TrueColor(0x04) bits/rgb-value=8 
colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000c6 
class=TrueColor(0x04) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 
blue-mask=0x000000ff},{id=0x000000c7 class=TrueColor(0x04) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 
green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000c8 class=TrueColor(0x04) bits/rgb-value=8 
colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000c9 
class=TrueColor(0x04) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 
blue-mask=0x000000ff},{id=0x000000ca class=TrueColor(0x04) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 
green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000cb class=TrueColor(0x04) bits/rgb-value=8 
colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000cc 
class=TrueColor(0x04) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 
blue-mask=0x000000ff},{id=0x000000cd class=TrueColor(0x04) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 
green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000ce class=TrueColor(0x04) bits/rgb-value=8 
colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000cf 
class=TrueColor(0x04) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 
blue-mask=0x000000ff},{id=0x000000d0 class=TrueColor(0x04) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 
green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000d1 class=TrueColor(0x04) bits/rgb-value=8 
colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000d2 
class=TrueColor(0x04) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 
blue-mask=0x000000ff},{id=0x000000d3 class=TrueColor(0x04) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 
green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000d4 class=TrueColor(0x04) bits/rgb-value=8 
colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000d5 
class=TrueColor(0x04) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 
blue-mask=0x000000ff},{id=0x000000d6 class=TrueColor(0x04) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 
green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000d7 class=TrueColor(0x04) bits/rgb-value=8 
colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000d8 
class=TrueColor(0x04) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 
blue-mask=0x000000ff},{id=0x000000d9 class=TrueColor(0x04) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 
green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000da class=TrueColor(0x04) bits/rgb-value=8 
colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000db 
class=TrueColor(0x04) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 
blue-mask=0x000000ff},{id=0x000000dc class=TrueColor(0x04) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 
green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000dd class=TrueColor(0x04) bits/rgb-value=8 
colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000de 
class=TrueColor(0x04) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 
blue-mask=0x000000ff},{id=0x000000df class=TrueColor(0x04) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 
green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000e0 class=DirectColor(0x05) bits/rgb-value=8 
colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000e1 
class=DirectColor(0x05) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 
blue-mask=0x000000ff},{id=0x000000e2 class=DirectColor(0x05) bits/rgb-value=8 colormap-entries=256 
red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000e3 class=DirectColor(0x05) 
bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000e4 
class=DirectColor(0x05) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 
blue-mask=0x000000ff},{id=0x000000e5 class=DirectColor(0x05) bits/rgb-value=8 colormap-entries=256 
red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000e6 class=DirectColor(0x05) 
bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000e7 
class=DirectColor(0x05) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 
blue-mask=0x000000ff},{id=0x000000e8 class=DirectColor(0x05) bits/rgb-value=8 colormap-entries=256 
red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000e9 class=DirectColor(0x05) 
bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000ea 
class=DirectColor(0x05) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 
blue-mask=0x000000ff},{id=0x000000eb class=DirectColor(0x05) bits/rgb-value=8 colormap-entries=256 
red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000ec class=DirectColor(0x05) 
bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000ed 
class=DirectColor(0x05) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 
blue-mask=0x000000ff},{id=0x000000ee class=DirectColor(0x05) bits/rgb-value=8 colormap-entries=256 
red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000ef class=DirectColor(0x05) 
bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000f0 
class=DirectColor(0x05) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 
blue-mask=0x000000ff},{id=0x000000f1 class=DirectColor(0x05) bits/rgb-value=8 colormap-entries=256 
red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000f2 class=DirectColor(0x05) 
bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000f3 
class=DirectColor(0x05) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 
blue-mask=0x000000ff},{id=0x000000f4 class=DirectColor(0x05) bits/rgb-value=8 colormap-entries=256 
red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000f5 class=DirectColor(0x05) 
bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000f6 
class=DirectColor(0x05) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 
blue-mask=0x000000ff},{id=0x000000f7 class=DirectColor(0x05) bits/rgb-value=8 colormap-entries=256 
red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000f8 class=DirectColor(0x05) 
bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000f9 
class=DirectColor(0x05) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 
blue-mask=0x000000ff},{id=0x000000fa class=DirectColor(0x05) bits/rgb-value=8 colormap-entries=256 
red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000fb class=DirectColor(0x05) 
bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000fc 
class=DirectColor(0x05) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 
blue-mask=0x000000ff},{id=0x000000fd class=DirectColor(0x05) bits/rgb-value=8 colormap-entries=256 
red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000fe class=DirectColor(0x05) 
bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff},{id=0x000000ff 
class=DirectColor(0x05) bits/rgb-value=8 colormap-entries=256 red-mask=0x00ff0000 green-mask=0x0000ff00 
blue-mask=0x000000ff};},{depth=1 visuals=;},{depth=4 visuals=;},{depth=8 visuals=;},{depth=15 visuals=;},{depth=16 
visuals=;},{depth=32 visuals={id=0x00000041 class=TrueColor(0x04) bits/rgb-value=8 colormap-entries=256 
red-mask=0x00ff0000 green-mask=0x0000ff00 blue-mask=0x000000ff};};};
000:<:0001: 20: Request(98): QueryExtension name='BIG-REQUESTS'
000:>:0001:32: Reply to QueryExtension: present=true(0x01) major-opcode=142 first-event=0 first-error=0
000:<:0002:  4: BIG-REQUESTS-Request(142,0): Enable 
000:>:0002:32: Reply to Enable: maximum-request-length=4194303
000:<:0003: 20: Request(55): CreateGC cid=0x04000000 drawable=0x00000101 values={background=0x00ffffff}
000:<:0004: 24: Request(20): GetProperty delete=false(0x00) window=0x00000101 property=0x17("RESOURCE_MANAGER") 
type=0x1f("STRING") long-offset=0x00000000 long-length=0x05f5e100
000:>:0004:144: Reply to GetProperty: type=0x1f("STRING") bytes-after=0x00000000 
data='Xft.dpi:\t96\nXft.antialias:\t1\nXft.hinting:\t1\nXft.hintstyle:\thintslight\nXft.rgba:\trgb\nXft.lcdfilter:\tlcddefault\n'
000:<:0005: 20: Request(98): QueryExtension name='XKEYBOARD'
000:>:0005:32: Reply to QueryExtension: present=true(0x01) major-opcode=144 first-event=97 first-error=153
000:<:0006:  8: XKEYBOARD-Request(144,0): UseExtension major=1 minor=0
000:>:0006:32: Reply to UseExtension: major=1 minor=0
000:<:0007: 40: Request(1): CreateWindow depth=0x00 window=0x04000001 parent=0x00000101
x=10 y=10 width=100 height=100 border-width=1 class=CopyFromParent(0x0000) visual=CopyFromParent(0x00000000)
 value-list={background-pixel=0x00ffffff border-pixel=0x00000000}
000:<:0008: 24: Request(16): InternAtom only-if-exists=false(0x00) name='WM_DELETE_WINDOW'
000:>:0008:32: Reply to InternAtom: atom=0x129("WM_DELETE_WINDOW")
000:<:0009: 20: Request(16): InternAtom only-if-exists=false(0x00) name='WM_PROTOCOLS'
000:>:0009:32: Reply to InternAtom: atom=0x12b("WM_PROTOCOLS")
000:<:000a: 28: Request(18): ChangeProperty mode=Replace(0x00) window=0x04000001 property=0x12b("WM_PROTOCOLS")
 type=0x4("ATOM") data=0x129("WM_DELETE_WINDOW");
000:<:000b: 16: Request(2): ChangeWindowAttributes window=0x04000001 value-list={event-mask=KeyPress,Exposure}
000:<:000c:  8: Request(8): MapWindow window=0x04000001
000:>:000c: Event Expose(12) window=0x04000001 x=0 y=0 width=100 height=100 count=0x0000
000:<:000d: 20: Request(70): PolyFillRectangle drawable=0x04000001 gc=0x04000000 rectangles={x=20 y=20 w=10 h=10};
000:>:000d: Event KeyPress(2) keycode=0x3a time=0x001fd933 root=0x00000101 
event=0x04000001 child=None(0x00000000) root-x=50 root-y=147 event-x=49 event-y=69 state=0 same-screen=true(0x01)
000:<:000e:  8: Request(4): DestroyWindow window=0x04000001
000:<:000f:  8: Request(60): FreeGC gc=0x04000000
000:<:0010:  4: Request(43): GetInputFocus 
000:>:0010:32: Reply to GetInputFocus: revert-to=PointerRoot(0x01) focus=PointerRoot(0x00000001)

What the xtrace output verifies

Xtrace x-rays the message exchange between the X Server and the test client in action. Theoretically this client-server interaction were covered, in some extend, in section 1.2, where the X routines were analysed to the X Protocol messages. For instance we saw that XCreateSimpleWindow() waw resolved to a X_CreateWindow protocol request, which is defined in Xproto.h as:

#define X_CreateWindow                  1     
It is easy to recognise this protocol request usage in logfile (the xtrace output) as "Request(1)":

000:<:0007: 40: Request(1): CreateWindow depth=0x00 window=0x04000001 parent=0x00000101
x=10 y=10 width=100 height=100 border-width=1 class=CopyFromParent(0x0000) visual=CopyFromParent(0x00000000)
 value-list={background-pixel=0x00ffffff border-pixel=0x00000000}

The whole Request table from Xproto.h is illustrated next for other protocol requests, also found in logfile, and theoretically predicted in section 1.2, for instance X_ChangeWindowAttributes as Request(2), X_MapWindow as Request(8) or X_GetInputFocus as Request(43) to be identified:

/* Request codes */

#define X_CreateWindow                  1              
#define X_ChangeWindowAttributes        2        
#define X_GetWindowAttributes           3     
#define X_DestroyWindow                 4
#define X_DestroySubwindows             5   
#define X_ChangeSaveSet                 6
#define X_ReparentWindow                7
#define X_MapWindow                     8
#define X_MapSubwindows                 9
#define X_UnmapWindow                  10
#define X_UnmapSubwindows              11  
#define X_ConfigureWindow              12  
#define X_CirculateWindow              13  
#define X_GetGeometry                  14
#define X_QueryTree                    15
#define X_InternAtom                   16
#define X_GetAtomName                  17
#define X_ChangeProperty               18 
#define X_DeleteProperty               19 
#define X_GetProperty                  20
#define X_ListProperties               21 
#define X_SetSelectionOwner            22    
#define X_GetSelectionOwner            23    
#define X_ConvertSelection             24   
#define X_SendEvent                    25
#define X_GrabPointer                  26
#define X_UngrabPointer                27
#define X_GrabButton                   28
#define X_UngrabButton                 29
#define X_ChangeActivePointerGrab      30          
#define X_GrabKeyboard                 31
#define X_UngrabKeyboard               32 
#define X_GrabKey                      33
#define X_UngrabKey                    34
#define X_AllowEvents                  35       
#define X_GrabServer                   36      
#define X_UngrabServer                 37        
#define X_QueryPointer                 38        
#define X_GetMotionEvents              39           
#define X_TranslateCoords              40                
#define X_WarpPointer                  41       
#define X_SetInputFocus                42         
#define X_GetInputFocus                43         
#define X_QueryKeymap                  44       
#define X_OpenFont                     45    
#define X_CloseFont                    46     
#define X_QueryFont                    47
#define X_QueryTextExtents             48     
#define X_ListFonts                    49  
#define X_ListFontsWithInfo    	       50 
#define X_SetFontPath                  51 
#define X_GetFontPath                  52 
#define X_CreatePixmap                 53        
#define X_FreePixmap                   54      
#define X_CreateGC                     55    
#define X_ChangeGC                     56    
#define X_CopyGC                       57  
#define X_SetDashes                    58     
#define X_SetClipRectangles            59             
#define X_FreeGC                       60  
#define X_ClearArea                    61             
#define X_CopyArea                     62    
#define X_CopyPlane                    63     
#define X_PolyPoint                    64     
#define X_PolyLine                     65    
#define X_PolySegment                  66       
#define X_PolyRectangle                67         
#define X_PolyArc                      68   
#define X_FillPoly                     69    
#define X_PolyFillRectangle            70             
#define X_PolyFillArc                  71       
#define X_PutImage                     72    
#define X_GetImage                     73 
#define X_PolyText8                    74     
#define X_PolyText16                   75      
#define X_ImageText8                   76      
#define X_ImageText16                  77       
#define X_CreateColormap               78          
#define X_FreeColormap                 79        
#define X_CopyColormapAndFree          80               
#define X_InstallColormap              81           
#define X_UninstallColormap            82             
#define X_ListInstalledColormaps       83                  
#define X_AllocColor                   84      
#define X_AllocNamedColor              85           
#define X_AllocColorCells              86           
#define X_AllocColorPlanes             87            
#define X_FreeColors                   88      
#define X_StoreColors                  89       
#define X_StoreNamedColor              90           
#define X_QueryColors                  91       
#define X_LookupColor                  92       
#define X_CreateCursor                 93        
#define X_CreateGlyphCursor            94             
#define X_FreeCursor                   95      
#define X_RecolorCursor                96         
#define X_QueryBestSize                97         
#define X_QueryExtension               98          
#define X_ListExtensions               99          
#define X_ChangeKeyboardMapping        100
#define X_GetKeyboardMapping           101
#define X_ChangeKeyboardControl        102                
#define X_GetKeyboardControl           103             
#define X_Bell                         104
#define X_ChangePointerControl         105
#define X_GetPointerControl            106
#define X_SetScreenSaver               107          
#define X_GetScreenSaver               108          
#define X_ChangeHosts                  109       
#define X_ListHosts                    110     
#define X_SetAccessControl             111               
#define X_SetCloseDownMode             112
#define X_KillClient                   113 
#define X_RotateProperties	       114
#define X_ForceScreenSaver	       115
#define X_SetPointerMapping            116
#define X_GetPointerMapping            117
#define X_SetModifierMapping	       118
#define X_GetModifierMapping	       119
#define X_NoOperation                  127

A good description of the Xlib routines used in the test program can be found in the Xlib Manual. For instance we read about XCloseDisplay:

The XCloseDisplay() function closes the connection to the X server for the display specified in the Display structure and destroys all windows, resource IDs (Window, Font, Pixmap, Colormap, Cursor, and GContext), or other resources that the client has created on this display, unless the close-down mode of the resource has been changed (see XSetCloseDownMode()). Therefore, these windows, resource IDs, and other resources should never be referenced again or an error will be generated. Before exiting, you should call XCloseDisplay() explicitly so that any pending errors are reported as XCloseDisplay() performs a final XSync() operation.

Other tools to consider

Except xtrace there are some other interesting utilities: