Add support for the abstract socket namespace under Linux
[free-sw/xcb/libxcb] / doc / tutorial / index.html
old mode 100755 (executable)
new mode 100644 (file)
index 809edf8..c540426
     <li><a class="section" href="#font">Handling text and fonts</a>
       <ol>
         <li><a class="subsection" href="#fontstruct">The Font structure</a>
-        <li>Loading a Font
-        <li>Assigning a Font to a Graphic Context
-        <li>Drawing text in a window
+        <li><a class="subsection" href="#openingfont">Opening a Font</a>
+        <li><a class="subsection" href="#assigningfont">Assigning a Font to a Graphic Context</a>
+        <li><a class="subsection" href="#drawingtext">Drawing text in a drawable</a>
+        <li><a class="subsection" href="#fontcompleteexample">Complete example</a>
       </ol>
     <li>Windows hierarchy
       <ol>
         <li>Setting preferred window size(s)
         <li>Setting miscellaneous window manager hints
         <li>Setting an application's icon
+        <li>Obeying the delete-window protocol
       </ol>
     <li><a class="section" href="#winop">Simple window operations</a>
       <ol>
-        <li><a class="subsection" href="#winmap">Mapping and un-mapping a window</a>
+        <li><a class="subsection" href="#winmap">Mapping and unmapping a window</a>
         <li><a class="subsection" href="#winconf">Configuring a window</a>
         <li><a class="subsection" href="#winmove">Moving a window around the screen</a>
         <li><a class="subsection" href="#winsize">Resizing a window</a>
         <li><a class="subsection" href="#pixmapsdraw">Drawing a pixmap in a window</a>
         <li><a class="subsection" href="#pixmapsfree">Freeing a pixmap</a>
       </ol>
-    <li>Messing with the mouse cursor
+    <li><a class="subsection" href="#mousecursor">Messing with the mouse cursor</a>
       <ol>
-        <li>Creating and destroying a mouse cursor
-        <li>Setting a window's mouse cursor
+        <li><a class="subsection" href="#mousecursorcreate">Creating and destroying a mouse cursor</a>
+        <li><a class="subsection" href="#mousecursorset">Setting a window's mouse cursor</a>
+        <li><a class="subsection" href="#mousecursorexample">Complete example</a>
       </ol>
     <li><a class="subsection" href="#translation">Translation of basic Xlib functions and macros</a>
       <ol>
       <p>
       This tutorial is based on the
       <a href="http://users.actcom.co.il/~choo/lupg/tutorials/xlib-programming/xlib-programming.html">Xlib Tutorial</a>
-      written by <a href="mailto:choor@atcom.co.il">Guy Keren</a>. The
+      written by <a href="mailto:choor at atcom dot co dot il">Guy Keren</a>. The
       author allowed me to take some parts of his text, mainly the text which
       deals with the X Windows generality.
       </p>
       <p>
-      This tutorial is intended to people who want to start to program
+      This tutorial is intended for people who want to start to program
       with the <a href="http://xcb.freedesktop.org">XCB</a>
       library. keep in mind that XCB, like the
       <a href="http://tronche.com/gui/x/xlib/introduction">Xlib</a>
       level GUI toolkit like Motif,
       <a href="http://www.lesstif.org">LessTiff</a>,
       <a href="http://www.gtk.org">GTK</a>,
-      <a href="http://www.trolltech.com">QT</a> or
-      <a href="http://www.enlightenment.org">EWL</a>, or use
+      <a href="http://www.trolltech.com">QT</a>,
+      <a href="http://www.enlightenment.org">EWL</a>,
+      <a href="http://www.enlightenment.org">ETK</a>, or use
       <a href="http://cairographics.org">Cairo</a>.
       However,
       we need to start somewhere. More than this, knowing how things
       </p>
       <p>
       After reading this tutorial, one should be able to write very
-      simple graphical programs, but not programs with descent user
+      simple graphical programs, but not programs with decent user
       interfaces. For such programs, one of the previously mentioned
-      library should be used.
+      libraries should be used.
       </p>
       <p>
       But what is XCB? Xlib has been
-      the standard C binding for the <a href="http://www.xfree86.org">X
+      the standard C binding for the <a href="http://www.x.org">X
       Window System</a> protocol for many years now. It is an
       excellent piece of work, but there are applications for which it
-      is not ideal, for example
+      is not ideal, for example:
       </p>
       <ul>
         <li><b>Small platforms</b>: Xlib is a large piece of code, and
         <li>Toolkit implementation.
         <li>Direct protocol-level programming.
         <li>Lightweight emulation of commonly used portions of the
-        Xlib API (in progress)
+        Xlib API.
       </ul>
       <br>
       <li class="title"><a name="Xmodel">The client and server model of the X window system</a>
       </p>
       <p>
       This model is the complete opposite of what is used to when
-      dealing with clients and servers. In our case, the user seats
+      dealing with clients and servers. In our case, the user sits
       near the machine controlled by the server, while the client
       might be running on a remote machine. The server controls the
       screens, mouse and keyboard. A client may connect to the server,
       request that it draws a window (or several windows), and ask the
       server to send it any input the user sends to these
       windows. Thus, several clients may connect to a single X server
-      (one might be running an mail software, one running a WWW
+      (one might be running mail software, one running a WWW
       browser, etc). When input is sent by the user to some window,
       the server sends a message to the client controlling this window
       for processing. The client decides what to do with this input,
             requests to the X server.
             <li>If the event was a quit message, exit the loop.
           </ol>
-        <li>Close down the connection to the X server. 
+        <li>Close down the connection to the X server.
         <li>Perform cleanup operations.
       </ol>
       <br>
       <li class="title"><a name="notions">Basic XCB notions</a>
       <p>
-      XCB has been created to eliminate the needs of
+      XCB has been created to eliminate the need for
       programs to actually implement the X protocol layer. This
       library gives a program a very low-level access to any X
       server. Since the protocol is standardized, a client using any
         given X server. It hides a queue of messages coming from the
         server, and a queue of pending requests that our client
         intends to send to the server. In XCB, this structure is named
-        'XCBConnection'. When we open a connection to an X server, the
+        'xcb_connection_t'. It is analogous to the Xlib Display.
+        When we open a connection to an X server, the
         library returns a pointer to such a structure. Later, we
         supply this pointer to any XCB function that should send
         messages to the X server or receive messages from this server.
         <li class="subtitle"><a name="requestsreplies">Requests and
         replies: the Xlib killers</a>
         <p>
-        To ask informations to the X server, we have to make a request
+        To ask for information from the X server, we have to make a request
         and ask for a reply. With Xlib, these two tasks are
         automatically done: Xlib locks the system, sends a request,
         waits for a reply from the X server and unlocks. This is
 #include &lt;string.h&gt;
 #include &lt;sys/time.h&gt;
 
-#include &lt;X11/XCB/xcb.h&gt;
+#include &lt;xcb/xcb.h&gt;
 
 #include &lt;X11/Xlib.h&gt;
 
@@ -391,7 +396,7 @@ double
 get_time(void)
 {
   struct timeval timev;
-  
+
   gettimeofday(&amp;timev, NULL);
 
   return (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000);
@@ -400,46 +405,45 @@ get_time(void)
 int
 main ()
 {
-  XCBConnection       *c;
-  XCBATOM             *atoms;
-  XCBInternAtomCookie *cs;
-  char               **names;
-  int                  count;
-  int                  i;
-  double               start;
-  double               end;
-  double               diff;
+  xcb_connection_t         *c;
+  xcb_atom_t               *atoms;
+  xcb_intern_atom_cookie_t *cs;
+  char                    **names;
+  int                       count;
+  int                       i;
+  double                    start;
+  double                    end;
+  double                    diff;
 
   /* Xlib */
   Display *disp;
   Atom    *atoms_x;
   double   diff_x;
 
-  c = XCBConnectBasic ();
+  c = xcb_connect (NULL, NULL);
 
   count = 500;
-  atoms = (XCBATOM *)malloc (count * sizeof (atoms));
+  atoms = (xcb_atom_t *)malloc (count * sizeof (atoms));
   names = (char **)malloc (count * sizeof (char *));
 
   /* init names */
-  for (i = 0; i &lt; count; ++i)
-    {
-      char buf[100];
+  for (i = 0; i &lt; count; ++i) {
+    char buf[100];
 
-      sprintf (buf, "NAME%d", i);
-      names[i] = strdup (buf);
-    }
+    sprintf (buf, "NAME%d", i);
+    names[i] = strdup (buf);
+  }
 
   /* bad use */
   start = get_time ();
 
   for (i = 0; i &lt; count; ++i)
-    atoms[i] = XCBInternAtomReply (c, 
-                                   XCBInternAtom (c,
-                                                  0,
-                                                  strlen(names[i]),
-                                                  names[i]),
-                                   NULL)->atom;
+    atoms[i] = xcb_intern_atom_reply (c,
+                                      xcb_intern_atom (c,
+                                                       0,
+                                                       strlen(names[i]),
+                                                       names[i]),
+                                      NULL)->atom;
 
   end = get_time ();
   diff = end - start;
@@ -448,19 +452,18 @@ main ()
   /* good use */
   start = get_time ();
 
-  cs = (XCBInternAtomCookie *) malloc (count * sizeof(XCBInternAtomCookie));
+  cs = (xcb_intern_atom_cookie_t *) malloc (count * sizeof(xcb_intern_atom_cookie_t));
   for(i = 0; i &lt; count; ++i)
-    cs[i] = XCBInternAtom (c, 0, strlen(names[i]), names[i]);
+    cs[i] = xcb_intern_atom (c, 0, strlen(names[i]), names[i]);
 
-  for(i = 0; i &lt; count; ++i)
-    {
-      XCBInternAtomRep *r;
+  for(i = 0; i &lt; count; ++i) {
+    xcb_intern_atom_reply_t *r;
 
-      r = XCBInternAtomReply(c, cs[i], 0);
-      if(r)
-        atoms[i] = r->atom;
-      free(r);
-    }
+    r = xcb_intern_atom_reply(c, cs[i], 0);
+    if(r)
+      atoms[i] = r->atom;
+    free(r);
+  }
 
   end = get_time ();
   printf ("good use time : %f\n", end - start);
@@ -469,13 +472,11 @@ main ()
 
   /* free var */
   for (i = 0; i &lt; count; ++i)
-    {
-      free (names[i]);
-    }
+    free (names[i]);
   free (atoms);
   free (cs);
 
-  XCBDisconnect (c);
+  xcb_disconnect (c);
 
   /* Xlib */
   disp = XOpenDisplay (getenv("DISPLAY"));
@@ -496,8 +497,8 @@ main ()
   free (names);
 
   XCloseDisplay (disp);
-  
-  return 1;
+
+  return 0;
 }
 </pre>
         <li class="subtitle"><a name="gc">The Graphic Context</a>
@@ -527,11 +528,12 @@ main ()
         A structure is used to pass events received from the X
         server. XCB supports exactly the events specified in the
         protocol (33 events). This structure contains the type
-        of event received, as well as the data associated with the
+        of event received (including a bit for whether it came
+        from the server or another client), as well as the data associated with the
         event (e.g. position on the screen where the event was
         generated, mouse button associated with the event, region of
         the screen associated with a "redraw" event, etc). The way to
-        read the event's data epends on the event type.
+        read the event's data depends on the event type.
         </p>
       </ol>
       <br>
@@ -540,27 +542,33 @@ main ()
       <ol>
         <li class="subtitle"><a name="inst">Installation of XCB</a>
         <p>
+        <b>TODO:</b> These instructions are out of date.
+        Just reference the <a href="http://xcb.freedesktop.org/">main XCB page</a>
+        so we don't have to maintain these instructions in more than
+        one place.
+        </p>
+        <p>
         To build XCB from source, you need to have installed at
         least:
         </p>
         <ul>
           <li>pkgconfig 0.15.0
-          <li>automake 1.7
-          <li>autoconf 2.50
+          <li><a href="http://www.gnu.org/software/automake/">automake 1.7</a>
+          <li><a href="http://www.gnu.org/software/autoconf/">autoconf 2.50</a>
           <li><a href="http://www.check.org">check</a>
           <li><a href="http://xmlsoft.org/XSLT/">xsltproc</a>
+          <li><a href="http://www.gnu.org/software/gperf/">gperf 3.0.1</a>
         </ul>
         <p>
-        You have to checkout in CVS the following modules:
+        You have to checkout in the git repository the following modules:
         </p>
         <ul>
-          <li>Xproto from xlibs
           <li>Xau from xlibs
           <li>xcb-proto
           <li>xcb
         </ul>
         <p>
-        Note that Xproto and xcb-proto exist only to install header
+        Note that xcb-proto exists only to install header
         files, so typing 'make' or 'make all' will produce the message
         "Nothing to be done for 'all'". That's normal.
         </p>
@@ -581,8 +589,8 @@ gcc -Wall prog.c -o prog `pkg-config --cflags --libs xcb`
       will be the one in the environment variable DISPLAY.
       </p>
       <pre class="code">
-XCBConnection *XCBConnect (const char *displayname,
-                           int        *screenp);
+<span class="type">xcb_connection_t</span> *xcb_connect (<span class="keyword">const</span> <span class="type">char</span> *displayname,
+                               <span class="type">int</span>        *screenp);
 </pre>
       <p>
       The second parameter returns the screen number used for the
@@ -590,24 +598,24 @@ XCBConnection *XCBConnect (const char *displayname,
       and is opaque. Here is how the connection can be opened:
       </p>
       <pre class="code">
-#include &lt;X11/XCB/xcb.h&gt;
+#<span class="include">include</span> <span class="string">&lt;xcb/xcb.h&gt;</span>
 
-int
-main (int argc, char *argv[])
+<span class="type">int</span>
+<span class="function">main</span> ()
 {
-  XCBConnection *c;
-  
-  /* Open the connection to the X server. use the DISPLAY environment variable as the default display name */
-  c = XCBConnect (NULL, NULL);
+  <span class="type">xcb_connection_t</span> *c;
+
+  /* Open the connection to the X server. Use the DISPLAY environment variable as the default display name */
+  c = xcb_connect (NULL, NULL);
 
-  return 1;
+  <span class="keyword">return</span> 0;
 }
 </pre>
       <p>
       To close a connection, it suffices to use:
       </p>
       <pre class="code">
-void XCBDisconnect (XCBConnection *c);
+<span class="type">void</span> xcb_disconnect (<span class="type">xcb_connection_t</span> *c);
 </pre>
       <div class="comp">
         <div class="title">
@@ -620,7 +628,7 @@ void XCBDisconnect (XCBConnection *c);
         </div>
         <div class="xcb">
         <ul>
-          <li>XCBConnect ()
+          <li>xcb_connect ()
         </ul>
         </div>
         <div class="xlib">
@@ -630,47 +638,46 @@ void XCBDisconnect (XCBConnection *c);
         </div>
         <div class="xcb">
         <ul>
-          <li>XCBDisconnect ()
+          <li>xcb_disconnect ()
         </ul>
         </div>
       </div>
-      <p>
-      </p>
+      <br>
       <li class="title"><a name="screen">Checking basic information about a connection</a>
       <p>
-      Once we opened a connection to an X server, we should check some
-      basic informations about it: what screens it has, what is the
+      Once we have opened a connection to an X server, we should check some
+      basic information about it: what screens it has, what is the
       size (width and height) of the screen, how many colors it
       supports (black and white ? grey scale ?, 256 colors ? more ?),
-      and so on. We get such informations from the XCBSCREEN
+      and so on. We get such information from the xcb_screen_t
       structure:
       </p>
       <pre class="code">
 typedef struct {
-    XCBWINDOW root;
-    XCBCOLORMAP default_colormap;
-    CARD32 white_pixel;
-    CARD32 black_pixel;
-    CARD32 current_input_masks;
-    CARD16 width_in_pixels;
-    CARD16 height_in_pixels;
-    CARD16 width_in_millimeters;
-    CARD16 height_in_millimeters;
-    CARD16 min_installed_maps;
-    CARD16 max_installed_maps;
-    XCBVISUALID root_visual;
-    BYTE backing_stores;
-    BOOL save_unders;
-    CARD8 root_depth;
-    CARD8 allowed_depths_len;
-} XCBSCREEN;
+    xcb_window_t   root;
+    xcb_colormap_t default_colormap;
+    uint32_t       white_pixel;
+    uint32_t       black_pixel;
+    uint32_t       current_input_masks;
+    uint16_t       width_in_pixels;
+    uint16_t       height_in_pixels;
+    uint16_t       width_in_millimeters;
+    uint16_t       height_in_millimeters;
+    uint16_t       min_installed_maps;
+    uint16_t       max_installed_maps;
+    xcb_visualid_t root_visual;
+    uint8_t        backing_stores;
+    uint8_t        save_unders;
+    uint8_t        root_depth;
+    uint8_t        allowed_depths_len;
+} xcb_screen_t;
 </pre>
       <p>
       We could retrieve the first screen of the connection by using the
       following function:
       </p>
       <pre class="code">
-XCBSCREENIter XCBConnSetupSuccessRepRootsIter (XCBConnSetupSuccessRep *R);
+xcb_screen_iterator_t xcb_setup_roots_iterator (xcb_setup_t *R);
 </pre>
       <p>
       Here is a small program that shows how to use this function:
@@ -678,165 +685,164 @@ XCBSCREENIter XCBConnSetupSuccessRepRootsIter (XCBConnSetupSuccessRep *R);
       <pre class="code">
 #include &lt;stdio.h&gt;
 
-#include &lt;X11/XCB/xcb.h&gt;
+#include &lt;xcb/xcb.h&gt;
 
 int
-main (int argc, char *argv[])
+main ()
 {
-  XCBConnection *c;
-  XCBSCREEN     *screen;
-  int            screen_nbr;
-  XCBSCREENIter  iter;
-  
+  xcb_connection_t     *c;
+  xcb_screen_t         *screen;
+  int                   screen_nbr;
+  xcb_screen_iterator_t iter;
+
   /* Open the connection to the X server. Use the DISPLAY environment variable */
-  c = XCBConnect (NULL, &amp;screen_nbr);
-  
+  c = xcb_connect (NULL, &amp;screen_nbr);
+
   /* Get the screen #screen_nbr */
-  iter = XCBConnSetupSuccessRepRootsIter (XCBGetSetup (c));
-  for (; iter.rem; --screen_nbr, XCBSCREENNext (&amp;iter))
-    if (screen_nbr == 0)
-      {
-        screen = iter.data;
-        break;
-      }
+  iter = xcb_setup_roots_iterator (xcb_get_setup (c));
+  for (; iter.rem; --screen_nbr, xcb_screen_next (&amp;iter))
+    if (screen_nbr == 0) {
+      screen = iter.data;
+      break;
+    }
 
   printf ("\n");
-  printf ("Informations of screen %ld:\n", screen-&gt;root.xid);
+  printf ("Informations of screen %ld:\n", screen-&gt;root);
   printf ("  width.........: %d\n", screen-&gt;width_in_pixels);
   printf ("  height........: %d\n", screen-&gt;height_in_pixels);
   printf ("  white pixel...: %ld\n", screen-&gt;white_pixel);
   printf ("  black pixel...: %ld\n", screen-&gt;black_pixel);
   printf ("\n");
 
-  return 1;
+  return 0;
 }
 </pre>
       <li class="title"><a name="helloworld">Creating a basic window - the "hello world" program</a>
       <p>
-      After we got some basic informations about our screen, we can
+      After we got some basic information about our screen, we can
       create our first window. In the X Window System, a window is
       characterized by an Id. So, in XCB, a window is of type:
       </p>
       <pre class="code">
-typedef struct {
-    CARD32 xid;
-} XCBWINDOW;
+typedef uint32_t xcb_window_t;
 </pre>
       <p>
       We first ask for a new Id for our window, with this function:
       </p>
       <pre class="code">
-XCBWINDOW XCBWINDOWNew(XCBConnection *c);
+xcb_window_t xcb_generate_id(xcb_connection_t *c);
 </pre>
       <p>
       Then, XCB supplies the following function to create new windows:
       </p>
       <pre class="code">
-XCBVoidCookie XCBCreateWindow (XCBConnection *c,             /* Pointer to the XCBConnection structure */
-                               CARD8          depth,         /* Depth of the screen */
-                               XCBWINDOW      wid,           /* Id of the window */
-                               XCBWINDOW      parent,        /* Id of an existing window that should be the parent of the new window */
-                               INT16          x,             /* X position of the top-left corner of the window (in pixels) */
-                               INT16          y,             /* Y position of the top-left corner of the window (in pixels) */
-                               CARD16         width,         /* Width of the window (in pixels) */
-                               CARD16         height,        /* Height of the window (in pixels) */
-                               CARD16         border_width,  /* Width of the window's border (in pixels) */
-                               CARD16         _class,
-                               XCBVISUALID    visual,
-                               CARD32         value_mask,
-                               const CARD32  *value_list);
+xcb_void_cookie_t xcb_create_window (xcb_connection_t *c,             /* Pointer to the xcb_connection_t structure */
+                                     uint8_t           depth,         /* Depth of the screen */
+                                     xcb_window_t      wid,           /* Id of the window */
+                                     xcb_window_t      parent,        /* Id of an existing window that should be the parent of the new window */
+                                     int16_t           x,             /* X position of the top-left corner of the window (in pixels) */
+                                     int16_t           y,             /* Y position of the top-left corner of the window (in pixels) */
+                                     uint16_t          width,         /* Width of the window (in pixels) */
+                                     uint16_t          height,        /* Height of the window (in pixels) */
+                                     uint16_t          border_width,  /* Width of the window's border (in pixels) */
+                                     uint16_t          _class,
+                                     xcb_visualid_t    visual,
+                                     uint32_t          value_mask,
+                                     const uint32_t   *value_list);
 </pre>
       <p>
       The fact that we created the window does not mean that it will
       be drawn on screen. By default, newly created windows are not
       mapped on the screen (they are invisible). In order to make our
-      window visible, we use the function <span class="code">XCBMapWindow()</span>, whose
+      window visible, we use the function <span class="code">xcb_map_window()</span>, whose
       prototype is
       </p>
       <pre class="code">
-XCBVoidCookie XCBMapWindow (XCBConnection *c, XCBWINDOW window);
+xcb_void_cookie_t xcb_map_window (xcb_connection_t *c,
+                                  xcb_window_t      window);
 </pre>
       <p>
       Finally, here is a small program to create a window of size
       150x150 pixels, positioned at the top-left corner of the screen:
       </p>
       <pre class="code">
-#include &lt;unistd.h&gt;
+#include &lt;unistd.h&gt;      /* pause() */
 
-#include &lt;X11/XCB/xcb.h&gt;
+#include &lt;xcb/xcb.h&gt;
 
 int
-main (int argc, char *argv[])
+main ()
 {
-  XCBConnection *c;
-  XCBSCREEN     *screen;
-  XCBDRAWABLE    win;
-  
+  xcb_connection_t *c;
+  xcb_screen_t     *screen;
+  xcb_window_t      win;
+
   /* Open the connection to the X server */
-  c = XCBConnect (NULL, NULL);
-  
+  c = xcb_connect (NULL, NULL);
+
   /* Get the first screen */
-  screen = XCBConnSetupSuccessRepRootsIter (XCBGetSetup (c)).data;
+  screen = xcb_setup_roots_iterator (xcb_get_setup (c)).data;
 
   /* Ask for our window's Id */
-  win.window = XCBWINDOWNew(c);
+  win = xcb_generate_id(c);
 
   /* Create the window */
-  XCBCreateWindow (c,                        /* Connection          */
-                   0,                        /* depth               */
-                   win.window,               /* window Id           */
-                   screen-&gt;root,          /* parent window       */
-                   0, 0,                     /* x, y                */
-                   150, 150,                 /* width, height       */
-                   10,                       /* border_width        */
-                   InputOutput,              /* class               */
-                   screen-&gt;root_visual,   /* visual              */
-                   0, NULL);                 /* masks, not used yet */
+  xcb_create_window (c,                             /* Connection          */
+                     XCB_COPY_FROM_PARENT,          /* depth (same as root)*/
+                     win,                           /* window Id           */
+                     screen-&gt;root,                  /* parent window       */
+                     0, 0,                          /* x, y                */
+                     150, 150,                      /* width, height       */
+                     10,                            /* border_width        */
+                     XCB_WINDOW_CLASS_INPUT_OUTPUT, /* class               */
+                     screen-&gt;root_visual,           /* visual              */
+                     0, NULL);                      /* masks, not used yet */
 
   /* Map the window on the screen */
-  XCBMapWindow (c, win.window);
+  xcb_map_window (c, win);
+
+  /* Make sure commands are sent before we pause, so window is shown */
+  xcb_flush (c);
 
-  XCBSync (c, 0);
-  
-  pause ();
+  pause ();    /* hold client until Ctrl-C */
 
-  return 1;
+  return 0;
 }
 </pre>
       <p>
-      In this code, you see one more function - <span class="code">XCBSync()</span>, not explained
+      In this code, you see one more function - <span class="code">xcb_flush()</span>, not explained
       yet. It is used to flush all the pending requests. More
       precisely, there are 2 functions that do such things. The first
-      one is <span class="code">XCBFlush()</span>:
+      one is <span class="code">xcb_flush()</span>:
       </p>
       <pre class="code">
-int XCBFlush (XCBConnection *c);
+int xcb_flush (xcb_connection_t *c);
 </pre>
       <p>
       This function flushes all pending requests to the X server (much
       like the <span class="code">fflush()</span> function is used to
-      flush standard output). The second function is 
-      <span class="code">XCBSync()</span>:
+      flush standard output). The second function is
+      <span class="code">xcb_aux_sync()</span>:
       </p>
       <pre class="code">
-int XCBSync(XCBConnection *c, XCBGenericError **e);
+int xcb_aux_sync (xcb_connection_t *c);
 </pre>
       <p>
       This functions also flushes all pending requests to the X
       server, and then waits until the X server finishing processing
       these requests. In a normal program, this will not be necessary
       (we'll see why when we get to write a normal X program), but for
-      now, we put it there. 
+      now, we put it there.
       </p>
       <p>
-      The window that is created by the above code has a default
-      background (gray). This one can be set to a specific color,
+      The window that is created by the above code has a non defined
+      background. This one can be set to a specific color,
       thanks to the two last parameters of
-      <span class="code">XCBCreateWindow()</span>, which are not
+      <span class="code">xcb_create_window()</span>, which are not
       described yet. See the subsections
       <a href="#winconf">Configuring a window</a> or
       <a href="#winconf">Registering for event types using event masks</a>
-      for exemples on how to use these parameters. In addition, as no
+      for examples on how to use these parameters. In addition, as no
       events are handled, you have to make a Ctrl-C to interrupt the
       program.
       </p>
@@ -855,8 +861,8 @@ int XCBSync(XCBConnection *c, XCBGenericError **e);
         </div>
         <div class="xcb">
         <ul>
-          <li>XCBWINDOWNew ()
-          <li>XCBCreateWindow ()
+          <li>xcb_generate_id ()
+          <li>xcb_create_window ()
         </ul>
         </div>
       </div>
@@ -880,65 +886,63 @@ int XCBSync(XCBConnection *c, XCBGenericError **e);
         a Graphics Context is, as a window, characterized by an Id:
         </p>
         <pre class="code">
-typedef struct {
-    CARD32 xid;
-} XCBGCONTEXT;
+typedef uint32_t xcb_gcontext_t;
 </pre>
         <p>
         We first ask the X server to attribute an Id to our graphic
         context with this function:
         </p>
         <pre class="code">
-XCBGCONTEXT XCBGCONTEXTNew (XCBConnection *c);
+xcb_gcontext_t xcb_generate_id (xcb_connection_t *c);
 </pre>
         <p>
         Then, we set the attributes of the graphic context with this function:
         </p>
         <pre class="code">
-XCBVoidCookie XCBCreateGC (XCBConnection *c,
-                           XCBGCONTEXT    cid,
-                           XCBDRAWABLE    drawable,
-                           CARD32         value_mask,
-                           const CARD32  *value_list);
+xcb_void_cookie_t xcb_create_gc (xcb_connection_t *c,
+                                 xcb_gcontext_t    cid,
+                                 xcb_drawable_t    drawable,
+                                 uint32_t          value_mask,
+                                 const uint32_t   *value_list);
 </pre>
         <p>
         We give now an example on how to allocate a graphic context
-        that specifies that each drawing functions that use it will
+        that specifies that each drawing function that uses it will
         draw in foreground with a black color.
-        </p>                   
+        </p>
         <pre class="code">
-#include &lt;X11/XCB/xcb.h&gt;
+#include &lt;xcb/xcb.h&gt;
 
 int
-main (int argc, char *argv[])
+main ()
 {
-  XCBConnection *c;
-  XCBSCREEN     *screen;
-  XCBDRAWABLE    win;
-  XCBGCONTEXT    black;
-  CARD32         mask;
-  CARD32         value[1];
-  
+  xcb_connection_t *c;
+  xcb_screen_t     *screen;
+  xcb_drawable_t    win;
+  xcb_gcontext_t    black;
+  uint32_t          mask;
+  uint32_t          value[1];
+
   /* Open the connection to the X server and get the first screen */
-  c = XCBConnect (NULL, NULL);
-  screen = XCBConnSetupSuccessRepRootsIter (XCBGetSetup (c)).data;
+  c = xcb_connect (NULL, NULL);
+  screen = xcb_setup_roots_iterator (xcb_get_setup (c)).data;
 
   /* Create a black graphic context for drawing in the foreground */
-  win.window = screen-&gt;root;
-  black = XCBGCONTEXTNew (c);
-  mask = GCForeground;
+  win = screen-&gt;root;
+  black = xcb_generate_id (c);
+  mask = XCB_GC_FOREGROUND;
   value[0] = screen-&gt;black_pixel;
-  XCBCreateGC (c, black, win, mask, value);
+  xcb_create_gc (c, black, win, mask, value);
 
-  return 1;
+  return 0;
 }
 </pre>
         <p>
         Note should be taken regarding the role of "value_mask" and
-        "value_list" in the prototype of <span class="code">XCBCreateGC()</span>. Since a 
+        "value_list" in the prototype of <span class="code">xcb_create_gc()</span>. Since a
         graphic context has many attributes, and since we often just
         want to define a few of them, we need to be able to tell the
-        <span class="code">XCBCreateGC()</span> which attributes we
+        <span class="code">xcb_create_gc()</span> which attributes we
         want to set. This is what the "value_mask" parameter is
         for. We then use the "value_list" parameter to specify actual
         values for the attribute we defined in "value_mask". Thus, for
@@ -963,8 +967,8 @@ main (int argc, char *argv[])
           </div>
           <div class="xcb">
           <ul>
-            <li>XCBGCONTEXTNew ()
-            <li>XCBCreateGC ()
+            <li>xcb_generate_id ()
+            <li>xcb_create_gc ()
           </ul>
           </div>
         </div>
@@ -975,43 +979,44 @@ main (int argc, char *argv[])
         change its attributes (for example, changing the foreground
         color we use to draw a line, or changing the attributes of the
         font we use to display strings. See Subsections Drawing with a
-        color and Assigning a Font to a Graphic Context). This is done
-        by using this function:
+        color and
+        <a href="#assigningfont">Assigning a Font to a Graphic Context</a>).
+        This is done by using this function:
         </p>
         <pre class="code">
-XCBVoidCookie XCBChangeGC (XCBConnection *c,           /* The XCB Connection */
-                           XCBGCONTEXT    gc,          /* The Graphic Context */
-                           CARD32         value_mask,  /* Components of the Graphic Context that have to be set */
-                           const CARD32  *value_list); /* Value as specified by value_mask */
+xcb_void_cookie_t xcb_change_gc (xcb_connection_t *c,           /* The XCB Connection */
+                                 xcb_gcontext_t    gc,          /* The Graphic Context */
+                                 uint32_t          value_mask,  /* Components of the Graphic Context that have to be set */
+                                 const uint32_t   *value_list); /* Value as specified by value_mask */
 </pre>
         <p>
         The <span class="code">value_mask</span> parameter could take
-        these values:
+        any combination of these masks from the xcb_gc_t enumeration:
         </p>
         <ul>
-          <li>GCFunction
-          <li>GCPlaneMask
-          <li>GCForeground
-          <li>GCBackground
-          <li>GCLineWidth
-          <li>GCLineStyle
-          <li>GCCapStyle
-          <li>GCJoinStyle
-          <li>GCFillStyle
-          <li>GCFillRule
-          <li>GCTile
-          <li>GCStipple
-          <li>GCTileStipXOrigin
-          <li>GCTileStipYOrigin
-          <li>GCFont
-          <li>GCSubwindowMode
-          <li>GCGraphicsExposures
-          <li>GCClipXOrigin
-          <li>GCClipYOrigin
-          <li>GCClipMask
-          <li>GCDashOffset
-          <li>GCDashList
-          <li>GCArcMode
+          <li>XCB_GC_FUNCTION
+          <li>XCB_GC_PLANE_MASK
+          <li>XCB_GC_FOREGROUND
+          <li>XCB_GC_BACKGROUND
+          <li>XCB_GC_LINE_WIDTH
+          <li>XCB_GC_LINE_STYLE
+          <li>XCB_GC_CAP_STYLE
+          <li>XCB_GC_JOIN_STYLE
+          <li>XCB_GC_FILL_STYLE
+          <li>XCB_GC_FILL_RULE
+          <li>XCB_GC_TILE
+          <li>XCB_GC_STIPPLE
+          <li>XCB_GC_TILE_STIPPLE_ORIGIN_X
+          <li>XCB_GC_TILE_STIPPLE_ORIGIN_Y
+          <li>XCB_GC_FONT
+          <li>XCB_GC_SUBWINDOW_MODE
+          <li>XCB_GC_GRAPHICS_EXPOSURES
+          <li>XCB_GC_CLIP_ORIGIN_X
+          <li>XCB_GC_CLIP_ORIGIN_Y
+          <li>XCB_GC_CLIP_MASK
+          <li>XCB_GC_DASH_OFFSET
+          <li>XCB_GC_DASH_LIST
+          <li>XCB_GC_ARC_MODE
         </ul>
         <p>
         It is possible to set several attributes at the same
@@ -1019,7 +1024,8 @@ XCBVoidCookie XCBChangeGC (XCBConnection *c,           /* The XCB Connection */
         color which will be used to display a string), by OR'ing these
         values in <span class="code">value_mask</span>. Then
         <span class="code">value_list</span> has to be an array which
-        lists the value for the respective attributes. See Subsection
+        lists the value for the respective attributes.  <b>These values
+        must be in the same order as masks listed above.</b> See Subsection
         Drawing with a color to have an example.
         </p>
         <p>
@@ -1033,37 +1039,41 @@ XCBVoidCookie XCBChangeGC (XCBConnection *c,           /* The XCB Connection */
         <p>
         After we have created a Graphic Context, we can draw on a
         window using this Graphic Context, with a set of XCB
-        functions, collectively called "drawing primitive". Let see
+        functions, collectively called "drawing primitives". Let see
         how they are used.
         </p>
         <p>
         To draw a point, or several points, we use
         </p>
         <pre class="code">
-XCBVoidCookie XCBPolyPoint (XCBConnection  *c,               /* The connection to the X server */
-                            BYTE            coordinate_mode, /* Coordinate mode, usually set to CoordModeOrigin */
-                            XCBDRAWABLE     drawable,        /* The drawable on which we want to draw the point(s) */
-                            XCBGCONTEXT     gc,              /* The Graphic Context we use to draw the point(s) */
-                            CARD32          points_len,      /* The number of points */
-                            const XCBPOINT *points);         /* An array of points */
+xcb_void_cookie_t xcb_poly_point (xcb_connection_t  *c,               /* The connection to the X server */
+                                  uint8_t            coordinate_mode, /* Coordinate mode, usually set to XCB_COORD_MODE_ORIGIN */
+                                  xcb_drawable_t     drawable,        /* The drawable on which we want to draw the point(s) */
+                                  xcb_gcontext_t     gc,              /* The Graphic Context we use to draw the point(s) */
+                                  uint32_t           points_len,      /* The number of points */
+                                  const xcb_point_t *points);         /* An array of points */
 </pre>
         <p>
         The <span class="code">coordinate_mode</span> parameter
         specifies the coordinate mode.  Available values are
         </p>
         <ul>
-          <li><span class="code">CoordModeOrigin</span>
-          <li><span class="code">CoordModePrevious</span>
+          <li><span class="code">XCB_COORD_MODE_ORIGIN</span>
+          <li><span class="code">XCB_COORD_MODE_PREVIOUS</span>
         </ul>
         <p>
-        The <span class="code">XCBPOINT</span> type is just a
+        If XCB_COORD_MODE_PREVIOUS is used, then all points but the first one
+        are relative to the immediately previous point.
+        </p>
+        <p>
+        The <span class="code">xcb_point_t</span> type is just a
         structure with two fields (the coordinates of the point):
         </p>
         <pre class="code">
 typedef struct {
-    INT16 x;
-    INT16 y;
-} XCBPOINT;
+    int16_t x;
+    int16_t y;
+} xcb_point_t;
 </pre>
         <p>
         You could see an example in xpoints.c. <b>TODO</b> Set the link.
@@ -1072,12 +1082,12 @@ typedef struct {
         To draw a line, or a polygonal line, we use
         </p>
         <pre class="code">
-XCBVoidCookie XCBPolyLine (XCBConnection  *c,               /* The connection to the X server */
-                           BYTE            coordinate_mode, /* Coordinate mode, usually set to CoordModeOrigin */
-                           XCBDRAWABLE     drawable,        /* The drawable on which we want to draw the line(s) */
-                           XCBGCONTEXT     gc,              /* The Graphic Context we use to draw the line(s) */
-                           CARD32          points_len,      /* The number of points in the polygonal line */
-                           const XCBPOINT *points);         /* An array of points */
+xcb_void_cookie_t xcb_poly_line (xcb_connection_t  *c,               /* The connection to the X server */
+                                 uint8_t            coordinate_mode, /* Coordinate mode, usually set to XCB_COORD_MODE_ORIGIN */
+                                 xcb_drawable_t     drawable,        /* The drawable on which we want to draw the line(s) */
+                                 xcb_gcontext_t     gc,              /* The Graphic Context we use to draw the line(s) */
+                                 uint32_t           points_len,      /* The number of points in the polygonal line */
+                                 const xcb_point_t *points);         /* An array of points */
 </pre>
         <p>
         This function will draw the line between the first and the
@@ -1088,74 +1098,73 @@ XCBVoidCookie XCBPolyLine (XCBConnection  *c,               /* The connection to
         To draw a segment, or several segments, we use
         </p>
         <pre class="code">
-XCBVoidCookie XCBPolySegment (XCBConnection    *c,              /* The connection to the X server */
-                              XCBDRAWABLE       drawable,       /* The drawable on which we want to draw the segment(s) */
-                              XCBGCONTEXT       gc,             /* The Graphic Context we use to draw the segment(s) */
-                              CARD32            segments_len,   /* The number of segments */
-                              const XCBSEGMENT *segments);      /* An array of segments */
+xcb_void_cookie_t xcb_poly_segment (xcb_connection_t    *c,              /* The connection to the X server */
+                                    xcb_drawable_t       drawable,       /* The drawable on which we want to draw the segment(s) */
+                                    xcb_gcontext_t       gc,             /* The Graphic Context we use to draw the segment(s) */
+                                    uint32_t             segments_len,   /* The number of segments */
+                                    const xcb_segment_t *segments);      /* An array of segments */
 </pre>
         <p>
-        The <span class="code">XCBSEGMENT</span> type is just a
+        The <span class="code">xcb_segment_t</span> type is just a
         structure with four fields (the coordinates of the two points
         that define the segment):
         </p>
         <pre class="code">
 typedef struct {
-    INT16 x1;
-    INT16 y1;
-    INT16 x2;
-    INT16 y2;
-} XCBSEGMENT;
+    int16_t x1;
+    int16_t y1;
+    int16_t x2;
+    int16_t y2;
+} xcb_segment_t;
 </pre>
         <p>
         To draw a rectangle, or several rectangles, we use
         </p>
         <pre class="code">
-XCBVoidCookie XCBPolyRectangle (XCBConnection      *c,              /* The connection to the X server */
-                                XCBDRAWABLE         drawable,       /* The drawable on which we want to draw the rectangle(s) */
-                                XCBGCONTEXT         gc,             /* The Graphic Context we use to draw the rectangle(s) */
-                                CARD32              rectangles_len, /* The number of rectangles */
-                                const XCBRECTANGLE *rectangles);    /* An array of rectangles */
+xcb_void_cookie_t xcb_poly_rectangle (xcb_connection_t      *c,              /* The connection to the X server */
+                                      xcb_drawable_t         drawable,       /* The drawable on which we want to draw the rectangle(s) */
+                                      xcb_gcontext_t         gc,             /* The Graphic Context we use to draw the rectangle(s) */
+                                      uint32_t               rectangles_len, /* The number of rectangles */
+                                      const xcb_rectangle_t *rectangles);    /* An array of rectangles */
 </pre>
         <p>
-        The <span class="code">XCBRECTANGLE</span> type is just a
+        The <span class="code">xcb_rectangle_t</span> type is just a
         structure with four fields (the coordinates of the top-left
         corner of the rectangle, and its width and height):
         </p>
         <pre class="code">
 typedef struct {
-    INT16 x;
-    INT16 y;
-    CARD16 width;
-    CARD16 height;
-} XCBRECTANGLE;
+    int16_t  x;
+    int16_t  y;
+    uint16_t width;
+    uint16_t height;
+} xcb_rectangle_t;
 </pre>
-        <p>
-        <b>TODO</b>: there's no coordinate_mode. Is it normal ?
-        </p>
+        <!-- There's no coordinate_mode. Is it normal? -->
+        <!-- [iano] Yes, it's not in the protocol. -->
         <p>
         To draw an elliptical arc, or several elliptical arcs, we use
         </p>
         <pre class="code">
-XCBVoidCookie XCBPolyArc (XCBConnection *c,          /* The connection to the X server */
-                          XCBDRAWABLE    drawable,   /* The drawable on which we want to draw the arc(s) */
-                          XCBGCONTEXT    gc,         /* The Graphic Context we use to draw the arc(s) */
-                          CARD32         arcs_len,   /* The number of arcs */
-                          const XCBARC  *arcs);      /* An array of arcs */
+xcb_void_cookie_t xcb_poly_arc (xcb_connection_t *c,          /* The connection to the X server */
+                                xcb_drawable_t    drawable,   /* The drawable on which we want to draw the arc(s) */
+                                xcb_gcontext_t    gc,         /* The Graphic Context we use to draw the arc(s) */
+                                uint32_t          arcs_len,   /* The number of arcs */
+                                const xcb_arc_t  *arcs);      /* An array of arcs */
 </pre>
         <p>
-        The <span class="code">XCBARC</span> type is a structure with
+        The <span class="code">xcb_arc_t</span> type is a structure with
         six fields:
         </p>
         <pre class="code">
 typedef struct {
-    INT16 x;        /* Top left x coordinate of the rectangle surrounding the ellipse */
-    INT16 y;        /* Top left y coordinate of the rectangle surrounding the ellipse */
-    CARD16 width;   /* Width of the rectangle surrounding the ellipse */
-    CARD16 height;  /* Height of the rectangle surrounding the ellipse */
-    INT16 angle1;   /* Angle at which the arc begins */
-    INT16 angle2;   /* Angle at which the arc ends */
-} XCBARC;
+    int16_t  x;       /* Top left x coordinate of the rectangle surrounding the ellipse */
+    int16_t  y;       /* Top left y coordinate of the rectangle surrounding the ellipse */
+    uint16_t width;   /* Width of the rectangle surrounding the ellipse */
+    uint16_t height;  /* Height of the rectangle surrounding the ellipse */
+    int16_t  angle1;  /* Angle at which the arc begins */
+    int16_t  angle2;  /* Angle at which the arc ends */
+} xcb_arc_t;
 </pre>
         <div class="emph">
         <p>
@@ -1167,13 +1176,11 @@ typedef struct {
         indicate clockwise motion.
         </p>
         </div>
-        <p>
-        <b>TODO</b>: there's no coordinate_mode. Is it normal ?
-        </p>
-        <p>
-        <b>TODO</b>: I think that (x,y) should be the center of the
-        ellipse, and (width, height) the radius. It's more logical.
-        </p>
+        <!-- I think that (x,y) should be the center of the
+        ellipse, and (width, height) the radius. It's more logical. -->
+        <!-- iano: Yes, and I bet some toolkits do that.
+         But the protocol (and many other graphics APIs) define arcs
+         by bounding rectangles. -->
         <p>
         The corresponding function which fill inside the geometrical
         object are listed below, without  further explanation, as they
@@ -1184,13 +1191,13 @@ typedef struct {
         we use
         </p>
         <pre class="code">
-XCBVoidCookie XCBFillPoly (XCBConnection  *c,
-                           XCBDRAWABLE     drawable,
-                           XCBGCONTEXT     gc,
-                           CARD8           shape,
-                           CARD8           coordinate_mode,
-                           CARD32          points_len,
-                           const XCBPOINT *points);
+xcb_void_cookie_t xcb_fill_poly (xcb_connection_t  *c,
+                                 xcb_drawable_t     drawable,
+                                 xcb_gcontext_t     gc,
+                                 uint8_t            shape,
+                                 uint8_t            coordinate_mode,
+                                 uint32_t           points_len,
+                                 const xcb_point_t *points);
 </pre>
         <p>
         The <span class="code">shape</span> parameter specifies a
@@ -1198,180 +1205,156 @@ XCBVoidCookie XCBFillPoly (XCBConnection  *c,
         values are
         </p>
         <ul>
-          <li><span class="code">Complex</span>
-          <li><span class="code">Convex</span>
-          <li><span class="code">Nonconvex</span>
+          <li><span class="code">XCB_POLY_SHAPE_COMPLEX</span>
+          <li><span class="code">XCB_POLY_SHAPE_NONCONVEX</span>
+          <li><span class="code">XCB_POLY_SHAPE_CONVEX</span>
         </ul>
         <p>
         To fill one or several rectangles, we use
         </p>
         <pre class="code">
-XCBVoidCookie XCBPolyFillRectangle (XCBConnection      *c,
-                                    XCBDRAWABLE         drawable,
-                                    XCBGCONTEXT         gc,
-                                    CARD32              rectangles_len,
-                                    const XCBRECTANGLE *rectangles);
+xcb_void_cookie_t xcb_poly_fill_rectangle (xcb_connection_t      *c,
+                                           xcb_drawable_t         drawable,
+                                           xcb_gcontext_t         gc,
+                                           uint32_t               rectangles_len,
+                                           const xcb_rectangle_t *rectangles);
 </pre>
         <p>
         To fill one or several arcs, we use
         </p>
         <pre class="code">
-XCBVoidCookie XCBPolyFillArc (XCBConnection *c,
-                              XCBDRAWABLE    drawable,
-                              XCBGCONTEXT    gc,
-                              CARD32         arcs_len,
-                              const XCBARC  *arcs);
+xcb_void_cookie_t xcb_poly_fill_arc (xcb_connection_t *c,
+                                     xcb_drawable_t    drawable,
+                                     xcb_gcontext_t    gc,
+                                     uint32_t          arcs_len,
+                                     const xcb_arc_t  *arcs);
 </pre>
         <br>
+        <a name="points.c"></a>
         <p>
         To illustrate these functions, here is an example that draws
         four points, a polygonal line, two segments, two rectangles
         and two arcs. Remark that we use events for the first time, as
         an introduction to the next section.
         </p>
+        <p>
+        <b>TODO:</b> Use screen-&gt;root_depth for depth parameter.
+        </p>
         <pre class="code">
 #include &lt;stdlib.h&gt;
 #include &lt;stdio.h&gt;
 
-#include &lt;X11/XCB/xcb.h&gt;
-
-/* Get the depth of the screen. Needed in order to draw something */
-int
-get_depth(XCBConnection *c,
-          XCBSCREEN     *root)
-{
-  XCBDRAWABLE        drawable;
-  XCBGetGeometryRep *geom;
-  int                depth;
-
-  drawable.window = root-&gt;root;
-  geom = XCBGetGeometryReply (c, XCBGetGeometry(c, drawable), 0);
-
-  if(!geom)
-    {
-      perror ("GetGeometry(root) failed");
-      exit (0);
-    }
-  
-  depth = geom-&gt;depth;
-  free (geom);
-
-  return depth;
-}
+#include &lt;xcb/xcb.h&gt;
 
 int
-main (int argc, char *argv[])
+main ()
 {
-  XCBConnection   *c;
-  XCBSCREEN       *screen;
-  XCBDRAWABLE      win;
-  XCBGCONTEXT      foreground;
-  XCBGenericEvent *e;
-  CARD32           mask = 0;
-  CARD32           values[2];
+  xcb_connection_t    *c;
+  xcb_screen_t        *screen;
+  xcb_drawable_t       win;
+  xcb_gcontext_t       foreground;
+  xcb_generic_event_t *e;
+  uint32_t             mask = 0;
+  uint32_t             values[2];
 
   /* geometric objects */
-  XCBPOINT         points[] = {
+  xcb_point_t          points[] = {
     {10, 10},
     {10, 20},
     {20, 10},
     {20, 20}};
 
-  XCBPOINT         polyline[] = {
+  xcb_point_t          polyline[] = {
     {50, 10},
-    {55, 30},
-    {80, 10},
-    {90, 20}};
+    { 5, 20},     /* rest of points are relative */
+    {25,-20},
+    {10, 10}};
 
-  XCBSEGMENT       segments[] = {
+  xcb_segment_t        segments[] = {
     {100, 10, 140, 30},
     {110, 25, 130, 60}};
 
-  XCBRECTANGLE     rectangles[] = {
+  xcb_rectangle_t      rectangles[] = {
     { 10, 50, 40, 20},
     { 80, 50, 10, 40}};
 
-  XCBARC           arcs[] = {
-    {10, 100, 60, 40, 0, 90 << 6},
-    {90, 100, 55, 40, 0, 270 << 6}};
-  
+  xcb_arc_t            arcs[] = {
+    {10, 100, 60, 40, 0, 90 &lt;&lt; 6},
+    {90, 100, 55, 40, 0, 270 &lt;&lt; 6}};
+
   /* Open the connection to the X server */
-  c = XCBConnect (NULL, NULL);
-  
+  c = xcb_connect (NULL, NULL);
+
   /* Get the first screen */
-  screen = XCBConnSetupSuccessRepRootsIter (XCBGetSetup (c)).data;
+  screen = xcb_setup_roots_iterator (xcb_get_setup (c)).data;
 
-  /* Create black (foregroung) graphic context */
-  win.window = screen-&gt;root;
+  /* Create black (foreground) graphic context */
+  win = screen-&gt;root;
 
-  foreground = XCBGCONTEXTNew (c);
-  mask = GCForeground | GCGraphicsExposures;
+  foreground = xcb_generate_id (c);
+  mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES;
   values[0] = screen-&gt;black_pixel;
   values[1] = 0;
-  XCBCreateGC (c, foreground, win, mask, values);
+  xcb_create_gc (c, foreground, win, mask, values);
 
   /* Ask for our window's Id */
-  win.window = XCBWINDOWNew(c);
+  win = xcb_generate_id(c);
 
   /* Create the window */
-  mask = XCBCWBackPixel | XCBCWEventMask;
+  mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
   values[0] = screen-&gt;white_pixel;
-  values[1] = ExposureMask;
-  XCBCreateWindow (c,                        /* Connection          */
-                   0,                        /* depth               */
-                   win.window,               /* window Id           */
-                   screen-&gt;root,          /* parent window       */
-                   0, 0,                     /* x, y                */
-                   150, 150,                 /* width, height       */
-                   10,                       /* border_width        */
-                   InputOutput,              /* class               */
-                   screen-&gt;root_visual,   /* visual              */
-                   mask, values);            /* masks */
+  values[1] = XCB_EVENT_MASK_EXPOSURE;
+  xcb_create_window (c,                             /* Connection          */
+                     XCB_COPY_FROM_PARENT,          /* depth               */
+                     win,                           /* window Id           */
+                     screen-&gt;root,                  /* parent window       */
+                     0, 0,                          /* x, y                */
+                     150, 150,                      /* width, height       */
+                     10,                            /* border_width        */
+                     XCB_WINDOW_CLASS_INPUT_OUTPUT, /* class               */
+                     screen-&gt;root_visual,           /* visual              */
+                     mask, values);                 /* masks */
 
   /* Map the window on the screen */
-  XCBMapWindow (c, win.window);
+  xcb_map_window (c, win);
 
 
   /* We flush the request */
-  XCBSync (c, 0);
-
-  while ((e = XCBWaitEvent (c)))
-    {
-      switch (e-&gt;response_type)
-        {
-        case XCBExpose:
-          {
-            /* We draw the points */
-            XCBPolyPoint (c, CoordModeOrigin, win, foreground, 4, points);
-            
-            /* We draw the polygonal line */
-            XCBPolyLine (c, CoordModeOrigin, win, foreground, 4, polyline);
-            
-            /* We draw the segements */
-            XCBPolySegment (c, win, foreground, 2, segments);
-            
-            /* We draw the rectangles */
-            XCBPolyRectangle (c, win, foreground, 2, rectangles);
-            
-            /* We draw the arcs */
-            XCBPolyArc (c, win, foreground, 2, arcs);
-
-            /* We flush the request */
-            XCBSync (c, 0);
-            
-            break;
-          }
-        default:
-          {
-            /* Unknown event type, ignore it */
-            break;
-          }
-        }
-      /* Free the Generic Event */
-      free (e);
+  xcb_flush (c);
+
+  while ((e = xcb_wait_for_event (c))) {
+    switch (e-&gt;response_type &amp; ~0x80) {
+    case XCB_EXPOSE: {
+      /* We draw the points */
+      xcb_poly_point (c, XCB_COORD_MODE_ORIGIN, win, foreground, 4, points);
+
+      /* We draw the polygonal line */
+      xcb_poly_line (c, XCB_COORD_MODE_PREVIOUS, win, foreground, 4, polyline);
+
+      /* We draw the segements */
+      xcb_poly_segment (c, win, foreground, 2, segments);
+
+      /* We draw the rectangles */
+      xcb_poly_rectangle (c, win, foreground, 2, rectangles);
+
+      /* We draw the arcs */
+      xcb_poly_arc (c, win, foreground, 2, arcs);
+
+      /* We flush the request */
+      xcb_flush (c);
+
+      break;
+    }
+    default: {
+      /* Unknown event type, ignore it */
+      break;
+    }
     }
+    /* Free the Generic Event */
+    free (e);
+  }
 
-  return 1;
+  return 0;
 }
 </pre>
       </ol>
@@ -1399,91 +1382,91 @@ main (int argc, char *argv[])
         </p>
         <p>
         In XCB, you use the "value_mask" and "value_list" data in the
-        <span class="code">XCBCreateWindow()</span> function to
+        <span class="code">xcb_create_window()</span> function to
         register for events. Here is how we register for
         <span class="code">Expose</span> event when creating a window:
         </p>
         <pre class="code">
-  mask = XCBCWEventMask;
-  valwin[0] = ExposureMask;
-  win.window = XCBWINDOWNew (c);
-  XCBCreateWindow (c, depth, win.window, root-&gt;root,
-                   0, 0, 150, 150, 10,
-                   InputOutput, root-&gt;root_visual,
-                   mask, valwin);
+  mask = XCB_CW_EVENT_MASK;
+  valwin[0] = XCB_EVENT_MASK_EXPOSURE;
+  win = xcb_generate_id (c);
+  xcb_create_window (c, depth, win, root-&gt;root,
+                     0, 0, 150, 150, 10,
+                     XCB_WINDOW_CLASS_INPUT_OUTPUT, root-&gt;root_visual,
+                     mask, valwin);
 </pre>
         <p>
-        <span class="code">ExposureMask</span> is a constant defined
-        in the "X.h" header file. If we wanted to register to several
+        <span class="code">XCB_EVENT_MASK_EXPOSURE</span> is a constant defined
+        in the xcb_event_mask_t enumeration in the "xproto.h" header file. If we wanted to register for several
         event types, we can logically "or" them, as follows:
         </p>
         <pre class="code">
-  mask = XCBCWEventMask;
-  valwin[0] = ExposureMask | ButtonPressMask;
-  win.window = XCBWINDOWNew (c);
-  XCBCreateWindow (c, depth, win.window, root-&gt;root,
-                   0, 0, 150, 150, 10,
-                   InputOutput, root-&gt;root_visual,
-                   mask, valwin);
+  mask = XCB_CW_EVENT_MASK;
+  valwin[0] = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_BUTTON_PRESS;
+  win = xcb_generate_id (c);
+  xcb_create_window (c, depth, win, root-&gt;root,
+                     0, 0, 150, 150, 10,
+                     XCB_WINDOW_CLASS_INPUT_OUTPUT, root-&gt;root_visual,
+                     mask, valwin);
 </pre>
         <p>
         This registers for <span class="code">Expose</span> events as
-        well as for mouse button presses insode the created
+        well as for mouse button presses inside the created
         window. You should note that a mask may represent several
         event sub-types.
         </p>
         <p>
         The values that a mask could take are given
-        by the <span class="code">XCBCW</span> enumeration:
+        by the <span class="code">xcb_cw_t</span> enumeration:
         </p>
         <pre class="code">
 typedef enum {
-    XCBCWBackPixmap       = 1L<<0,
-    XCBCWBackPixel        = 1L<<1,
-    XCBCWBorderPixmap     = 1L<<2,
-    XCBCWBorderPixel      = 1L<<3,
-    XCBCWBitGravity       = 1L<<4,
-    XCBCWWinGravity       = 1L<<5,
-    XCBCWBackingStore     = 1L<<6,
-    XCBCWBackingPlanes    = 1L<<7,
-    XCBCWBackingPixel     = 1L<<8,
-    XCBCWOverrideRedirect = 1L<<9,
-    XCBCWSaveUnder        = 1L<<10,
-    XCBCWEventMask        = 1L<<11,
-    XCBCWDontPropagate    = 1L<<12,
-    XCBCWColormap         = 1L<<13,
-    XCBCWCursor           = 1L<<14
-} XCBCW;
+    XCB_CW_BACK_PIXMAP       = 1L<<0,
+    XCB_CW_BACK_PIXEL        = 1L<<1,
+    XCB_CW_BORDER_PIXMAP     = 1L<<2,
+    XCB_CW_BORDER_PIXEL      = 1L<<3,
+    XCB_CW_BIT_GRAVITY       = 1L<<4,
+    XCB_CW_WIN_GRAVITY       = 1L<<5,
+    XCB_CW_BACKING_STORE     = 1L<<6,
+    XCB_CW_BACKING_PLANES    = 1L<<7,
+    XCB_CW_BACKING_PIXEL     = 1L<<8,
+    XCB_CW_OVERRIDE_REDIRECT = 1L<<9,
+    XCB_CW_SAVE_UNDER        = 1L<<10,
+    XCB_CW_EVENT_MASK        = 1L<<11,
+    XCB_CW_DONT_PROPAGATE    = 1L<<12,
+    XCB_CW_COLORMAP          = 1L<<13,
+    XCB_CW_CURSOR            = 1L<<14
+} xcb_cw_t;
 </pre>
         <div class="emph">
         <p>Note: we must be careful when setting the values of the valwin
         parameter, as they have to follow the order the
-        <span class="code">XCBCW</span> enumeration. Here is an
+        <span class="code">xcb_cw_t</span> enumeration. Here is an
         example:
         </p>
         </div>
         <pre class="code">
-  mask = XCBCWEventMask | XCBCWBackPixmap;
-  valwin[0] = None;                           /* for XCBCWBackPixmap (whose value is 1)    */
-  valwin[1] = ExposureMask | ButtonPressMask; /* for XCBCWEventMask, whose value (2048)    */
-                                              /* is superior to the one of XCBCWBackPixmap */
+  mask = XCB_CW_EVENT_MASK | XCB_CW_BACK_PIXMAP;
+  valwin[0] = XCB_NONE;                                              /* for XCB_CW_BACK_PIXMAP (whose value is 1)     */
+  valwin[1] = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_BUTTON_PRESS; /* for XCB_CW_EVENT_MASK, whose value (2048)     */
+                                                                     /* is greater than the one of XCB_CW_BACK_PIXMAP */
 </pre>
         <p>
         If the window has already been created, we can use the
-        <span class="code">XCBConfigureWindow()</span> function to set
+        <span class="code">xcb_configure_window()</span> function to set
         the events that the window will receive. The subsection
         <a href="#winconf">Configuring a window</a> shows its
         prototype. As an example, here is a piece of code that
         configures the window to receive the
         <span class="code">Expose</span> and
-        <span class="code">ButtonPressMask</span> events:
+        <span class="code">ButtonPress</span> events:
         </p>
         <pre class="code">
-const static CARD32 values[] = { ExposureMask | ButtonPressMask };
+const static uint32_t values[] = { XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_BUTTON_PRESS };
 
 /* The connection c and the window win are supposed to be defined */
 
-XCBConfigureWindow (c, win, XCBCWEventMask, values);
+xcb_configure_window (c, win, XCB_CW_EVENT_MASK, values);
 </pre>
         <div class="emph">
         <p>
@@ -1501,101 +1484,94 @@ XCBConfigureWindow (c, win, XCBCWEventMask, values);
         After we have registered for the event types we are interested
         in, we need to enter a loop of receiving events and handling
         them. There are two ways to receive events: a blocking way and
-        a non blocking way:
+        a non-blocking way:
         </p>
         <ul>
           <li>
-          <span class="code">XCBWaitEvent (XCBConnection *c)</span>
+          <span class="code">xcb_wait_for_event (xcb_connection_t *c)</span>
           is the blocking way. It waits (so blocks...) until an event is
           queued in the X server. Then it retrieves it into a newly
           allocated structure (it dequeues it from the queue) and returns
           it. This structure has to be freed. The function returns
           <span class="code">NULL</span> if an error occurs.
-          
+
           <br>
           <li>
-          <span class="code">XCBPollForEvent (XCBConnection *c, int
-          *error)</span> is the non blocking way. It looks at the event
+          <span class="code">xcb_poll_for_event (xcb_connection_t *c, int
+          *error)</span> is the non-blocking way. It looks at the event
           queue and returns (and dequeues too) an existing event into
           a newly allocated structure. This structure has to be
           freed. It returns <span class="code">NULL</span> if there is
           no event. If an error occurs, the parameter <span
           class="code">error</span> will be filled with the error
           status.
-           
         </ul>
         <p>
         There are various ways to write such a loop. We present two
         ways to write such a loop, with the two functions above. The
-        first one uses <span class="code">XCBWaitEvent</span>, which
+        first one uses <span class="code">xcb_wait_for_event_t</span>, which
         is similar to an event Xlib loop using only <span
         class="code">XNextEvent</span>:
         </p>
         <pre class="code">
-  XCBGenericEvent *e;
+  xcb_generic_event_t *e;
 
-  while ((e = XCBWaitEvent (c)))
-    {
-      switch (e-&gt;response_type)
-        {
-        case XCBExpose:
-          {
-            /* Handle the Expose event type */
-            XCBExposeEvent *ev = (XCBExposeEvent *)e;
+  while ((e = xcb_wait_for_event (c))) {
+    switch (e-&gt;response_type &amp; ~0x80) {
+    case XCB_EXPOSE: {
+      /* Handle the Expose event type */
+      xcb_expose_event_t *ev = (xcb_expose_event_t *)e;
 
-            /* ... */
+      /* ... */
 
-            break;
-          }
-        case XCBButtonPress: 
-          {
-            /* Handle the ButtonPress event type */
-            XCBButtonPressEvent *ev = (XCBButtonPressEvent *)e;
+      break;
+    }
+    case XCB_BUTTON_PRESS: {
+      /* Handle the ButtonPress event type */
+      xcb_button_press_event_t *ev = (xcb_button_press_event_t *)e;
 
-            /* ... */
+      /* ... */
 
-            break;
-          }
-        default:
-          {
-            /* Unknown event type, ignore it */
-            break;
-          }
-        }
-      /* Free the Generic Event */
-      free (e);
+      break;
+    }
+    default: {
+      /* Unknown event type, ignore it */
+      break;
     }
+    }
+    /* Free the Generic Event */
+    free (e);
+  }
 </pre>
         <p>
         You will certainly want to use <span
-        class="code">XCBPollForEvent(XCBConnection *c, int
+        class="code">xcb_poll_for_event(xcb_connection_t *c, int
         *error)</span> if, in Xlib, you use <span
-        class="code">XPending</span>:
+        class="code">XPending</span> or
+        <span class="code">XCheckMaskEvent</span>:
         </p>
         <pre class="code">
-  while (XPending (display))
-    {
-      XEvent ev;
+  while (XPending (display)) {
+    XEvent ev;
 
-      XNextEvent(d, &amp;ev);
-      
-      /* Manage your event */
-    }
+    XNextEvent(d, &amp;ev);
+
+    /* Manage your event */
+  }
 </pre>
         <p>
         Such a loop in XCB looks like:
         </p>
         <pre class="code">
-  XCBGenericEvent *ev;
+  xcb_generic_event_t *ev;
 
-  while ((ev = XCBPollForEvent (conn, 0)))
-    {
-      /* Manage your event */
-    }
+  while ((ev = xcb_poll_for_event (conn, 0))) {
+    /* Manage your event */
+  }
 </pre>
         <p>
         The events are managed in the same way as with <span
-        class="code">XCBWaitEvent</span>.
+        class="code">xcb_wait_for_event_t</span>.
         Obviously, we will need to give the user some way of
         terminating the program. This is usually done by handling a
         special "quit" event, as we will soon see.
@@ -1611,19 +1587,18 @@ XCBConfigureWindow (c, win, XCBCWEventMask, values);
           </div>
           <div class="xcb">
             <ul>
-              <li>XCBWaitEvent ()
+              <li>xcb_wait_for_event ()
             </ul>
           </div>
           <div class="xlib">
             <ul>
               <li>XPending ()
-              <li>XNextEvent ()
+              <li>XCheckMaskEvent ()
             </ul>
           </div>
           <div class="xcb">
             <ul>
-              <li>XCBPollForEvent ()
-              <br>
+              <li>xcb_poll_for_event ()
             </ul>
           </div>
         </div>
@@ -1659,17 +1634,17 @@ XCBConfigureWindow (c, win, XCBCWEventMask, values);
         </p>
         <pre class="code">
 typedef struct {
-    BYTE response_type;  /* The type of the event, here it is XCBExpose */
-    CARD8 pad0;
-    CARD16 sequence;
-    XCBWINDOW window;    /* The Id of the window that receives the event (in case */
-                         /* our application registered for events on several windows */
-    CARD16 x;            /* The x coordinate of the top-left part of the window that needs to be redrawn */
-    CARD16 y;            /* The y coordinate of the top-left part of the window that needs to be redrawn */
-    CARD16 width;        /* The width of the part of the window that needs to be redrawn */
-    CARD16 height;       /* The height of the part of the window that needs to be redrawn */
-    CARD16 count;
-} XCBExposeEvent;
+    uint8_t      response_type; /* The type of the event, here it is XCB_EXPOSE */
+    uint8_t      pad0;
+    uint16_t     sequence;
+    xcb_window_t window;        /* The Id of the window that receives the event (in case */
+                                /* our application registered for events on several windows */
+    uint16_t     x;             /* The x coordinate of the top-left part of the window that needs to be redrawn */
+    uint16_t     y;             /* The y coordinate of the top-left part of the window that needs to be redrawn */
+    uint16_t     width;         /* The width of the part of the window that needs to be redrawn */
+    uint16_t     height;        /* The height of the part of the window that needs to be redrawn */
+    uint16_t     count;
+} xcb_expose_event_t;
 </pre>
         <li class="subtitle"><a name="userinput">Getting user input</a>
         <p>
@@ -1688,9 +1663,9 @@ typedef struct {
           (or more) of the following masks when we create our window:
           </p>
           <ul>
-            <li><span class="code">ButtonPressMask</span>: notify us
+            <li><span class="code">XCB_EVENT_MASK_BUTTON_PRESS</span>: notify us
             of any button that was pressed in one of our windows.
-            <li><span class="code">ButtonReleaseMask</span>: notify us
+            <li><span class="code">XCB_EVENT_MASK_BUTTON_RELEASE</span>: notify us
             of any button that was released in one of our windows.
           </ul>
           <p>
@@ -1699,22 +1674,22 @@ typedef struct {
           </p>
           <pre class="code">
 typedef struct {
-    BYTE response_type;  /* The type of the event, here it is XCBButtonPressEvent or XCBButtonReleaseEvent */
-    XCBBUTTON detail;
-    CARD16 sequence;
-    XCBTIMESTAMP time;   /* Time, in milliseconds the event took place in */
-    XCBWINDOW root;
-    XCBWINDOW event;
-    XCBWINDOW child;
-    INT16 root_x;
-    INT16 root_y;
-    INT16 event_x;       /* The x coordinate where the mouse has been pressed in the window */
-    INT16 event_y;       /* The y coordinate where the mouse has been pressed in the window */
-    CARD16 state;        /* A mask of the buttons (or keys) during the event */
-    BOOL same_screen;
-} XCBButtonPressEvent;
-
-typedef XCBButtonPressEvent XCBButtonReleaseEvent;
+    uint8_t         response_type; /* The type of the event, here it is xcb_button_press_event_t or xcb_button_release_event_t */
+    xcb_button_t    detail;
+    uint16_t        sequence;
+    xcb_timestamp_t time;          /* Time, in milliseconds the event took place in */
+    xcb_window_t    root;
+    xcb_window_t    event;
+    xcb_window_t    child;
+    int16_t         root_x;
+    int16_t         root_y;
+    int16_t         event_x;       /* The x coordinate where the mouse has been pressed in the window */
+    int16_t         event_y;       /* The y coordinate where the mouse has been pressed in the window */
+    uint16_t        state;         /* A mask of the buttons (or keys) during the event */
+    uint8_t         same_screen;
+} xcb_button_press_event_t;
+
+typedef xcb_button_press_event_t xcb_button_release_event_t;
 </pre>
           <p>
           The <span class="code">time</span> field may be used to calculate "double-click"
@@ -1724,22 +1699,23 @@ typedef XCBButtonPressEvent XCBButtonReleaseEvent;
           </p>
           <p>
           The <span class="code">state</span> field is a mask of the buttons held down during
-          the event. It is a bitwise OR of any of the following:
+          the event. It is a bitwise OR of any of the following (from the xcb_button_mask_t and
+          xcb_mod_mask_t enumerations):
           </p>
           <ul>
-            <li><span class="code">Button1Mask</span>
-            <li><span class="code">Button2Mask</span>
-            <li><span class="code">Button3Mask</span>
-            <li><span class="code">Button4Mask</span>
-            <li><span class="code">Button5Mask</span>
-            <li><span class="code">ShiftMask</span>
-            <li><span class="code">LockMask</span>
-            <li><span class="code">ControlMask</span>
-            <li><span class="code">Mod1Mask</span>
-            <li><span class="code">Mod2Mask</span>
-            <li><span class="code">Mod3Mask</span>
-            <li><span class="code">Mod4Mask</span>
-            <li><span class="code">Mod5Mask</span>
+            <li><span class="code">XCB_BUTTON_MASK_1</span>
+            <li><span class="code">XCB_BUTTON_MASK_2</span>
+            <li><span class="code">XCB_BUTTON_MASK_3</span>
+            <li><span class="code">XCB_BUTTON_MASK_4</span>
+            <li><span class="code">XCB_BUTTON_MASK_5</span>
+            <li><span class="code">XCB_MOD_MASK_SHIFT</span>
+            <li><span class="code">XCB_MOD_MASK_LOCK</span>
+            <li><span class="code">XCB_MOD_MASK_CONTROL</span>
+            <li><span class="code">XCB_MOD_MASK_1</span>
+            <li><span class="code">XCB_MOD_MASK_2</span>
+            <li><span class="code">XCB_MOD_MASK_3</span>
+            <li><span class="code">XCB_MOD_MASK_4</span>
+            <li><span class="code">XCB_MOD_MASK_5</span>
           </ul>
           <p>
           Their names are self explanatory, where the first 5 refer to
@@ -1752,7 +1728,7 @@ typedef XCBButtonPressEvent XCBButtonReleaseEvent;
           change when clicking with various buttons.
           </p>
             <li class="subsubtitle"><a name="mousemvnt">Mouse movement events</a>
-          <p> 
+          <p>
           Similar to mouse button press and release events, we also
           can be notified of various mouse movement events. These can
           be split into two families. One is of mouse pointer
@@ -1763,20 +1739,20 @@ typedef XCBButtonPressEvent XCBButtonReleaseEvent;
           during the creation of our window:
           </p>
           <ul>
-            <li><span class="code">PointerMotionMask</span>: events of
+            <li><span class="code">XCB_EVENT_MASK_POINTER_MOTION</span>: events of
             the pointer moving in one of the windows controlled by our
             application, while no mouse button is held pressed.
-            <li><span class="code">ButtonMotionMask</span>: Events of
+            <li><span class="code">XCB_EVENT_MASK_BUTTON_MOTION</span>: Events of
             the pointer moving while one or more of the mouse buttons
             is held pressed.
-            <li><span class="code">Button1MotionMask</span>: same as
-            <span class="code">ButtonMotionMask</span>, but only when
+            <li><span class="code">XCB_EVENT_MASK_BUTTON_1_MOTION</span>: same as
+            <span class="code">XCB_EVENT_MASK_BUTTON_MOTION</span>, but only when
             the 1st mouse button is held pressed.
-            <li><span class="code">Button2MotionMask</span>,
-            <span class="code">Button3MotionMask</span>,
-            <span class="code">Button4MotionMask</span>,
-            <span class="code">Button5MotionMask</span>: same as
-            <span class="code">Button1MotionMask</span>, but
+            <li><span class="code">XCB_EVENT_MASK_BUTTON_2_MOTION</span>,
+            <span class="code">XCB_EVENT_MASK_BUTTON_3_MOTION</span>,
+            <span class="code">XCB_EVENT_MASK_BUTTON_4_MOTION</span>,
+            <span class="code">XCB_EVENT_MASK_BUTTON_5_MOTION</span>: same as
+            <span class="code">XCB_EVENT_MASK_BUTTON_1_MOTION</span>, but
             respectively for 2nd, 3rd, 4th and 5th mouse button.
           </ul>
           <p>
@@ -1785,36 +1761,36 @@ typedef XCBButtonPressEvent XCBButtonReleaseEvent;
           </p>
           <pre class="code">
 typedef struct {
-    BYTE response_type;  /* The type of the event */
-    BYTE detail;
-    CARD16 sequence;
-    XCBTIMESTAMP time;   /* Time, in milliseconds the event took place in */
-    XCBWINDOW root;
-    XCBWINDOW event;
-    XCBWINDOW child;
-    INT16 root_x;
-    INT16 root_y;
-    INT16 event_x;       /* The x coordinate of the mouse when the  event was generated */
-    INT16 event_y;       /* The y coordinate of the mouse when the  event was generated */
-    CARD16 state;        /* A mask of the buttons (or keys) during the event */
-    BOOL same_screen;
-} XCBMotionNotifyEvent;
+    uint8_t         response_type; /* The type of the event */
+    uint8_t         detail;
+    uint16_t        sequence;
+    xcb_timestamp_t time;          /* Time, in milliseconds the event took place in */
+    xcb_window_t    root;
+    xcb_window_t    event;
+    xcb_window_t    child;
+    int16_t         root_x;
+    int16_t         root_y;
+    int16_t         event_x;       /* The x coordinate of the mouse when the  event was generated */
+    int16_t         event_y;       /* The y coordinate of the mouse when the  event was generated */
+    uint16_t        state;         /* A mask of the buttons (or keys) during the event */
+    uint8_t         same_screen;
+} xcb_motion_notify_event_t;
 </pre>
             <li class="subsubtitle"><a name="mouseenter">Mouse pointer enter and leave events</a>
           <p>
           Another type of event that applications might be interested
-          at, is a mouse pointer entering a window the program
+          in, is a mouse pointer entering a window the program
           controls, or leaving such a window. Some programs use these
-          events to show the user tht the applications is now in
+          events to show the user that the application is now in
           focus. In order to register for such an event type, we
           should add one (or more) of the following masks when we
           create our window:
           </p>
           <ul>
-            <li><span class="code">EnterWindowMask</span>: notify us
+            <li><span class="code">xcb_event_enter_window_t</span>: notify us
             when the mouse pointer enters any of our controlled
             windows.
-            <li><span class="code">LeaveWindowMask</span>: notify us
+            <li><span class="code">xcb_event_leave_window_t</span>: notify us
             when the mouse pointer leaves any of our controlled
             windows.
           </ul>
@@ -1824,23 +1800,23 @@ typedef struct {
           </p>
           <pre class="code">
 typedef struct {
-    BYTE response_type;  /* The type of the event */
-    BYTE detail;
-    CARD16 sequence;
-    XCBTIMESTAMP time;   /* Time, in milliseconds the event took place in */
-    XCBWINDOW root;
-    XCBWINDOW event;
-    XCBWINDOW child;
-    INT16 root_x;
-    INT16 root_y;
-    INT16 event_x;       /* The x coordinate of the mouse when the  event was generated */
-    INT16 event_y;       /* The y coordinate of the mouse when the  event was generated */
-    CARD16 state;        /* A mask of the buttons (or keys) during the event */
-    BYTE mode;           /* The number of mouse button that was clicked */
-    BYTE same_screen_focus;
-} XCBEnterNotifyEvent;
-
-typedef XCBEnterNotifyEvent XCBLeaveNotifyEvent;
+    uint8_t         response_type; /* The type of the event */
+    uint8_t         detail;
+    uint16_t        sequence;
+    xcb_timestamp_t time;          /* Time, in milliseconds the event took place in */
+    xcb_window_t    root;
+    xcb_window_t    event;
+    xcb_window_t    child;
+    int16_t         root_x;
+    int16_t         root_y;
+    int16_t         event_x;       /* The x coordinate of the mouse when the  event was generated */
+    int16_t         event_y;       /* The y coordinate of the mouse when the  event was generated */
+    uint16_t        state;         /* A mask of the buttons (or keys) during the event */
+    uint8_t         mode;          /* The number of mouse button that was clicked */
+    uint8_t         same_screen_focus;
+} xcb_enter_notify_event_t;
+
+typedef xcb_enter_notify_event_t xcb_leave_notify_event_t;
 </pre>
           <li class="subsubtitle"><a name="focus">The keyboard focus</a>
           <p>
@@ -1849,9 +1825,9 @@ typedef XCBEnterNotifyEvent XCBLeaveNotifyEvent;
           which window should be sent a given keyboard input ? This is
           done using the keyboard focus. Only a single window on the
           screen may have the keyboard focus at a given time. There
-          is a XCB function that allow a program to set the keyboard
+          is a XCB function that allows a program to set the keyboard
           focus to a given window. The user can usually set the
-          keyboard ficus using the window manager (often by clicking
+          keyboard focus using the window manager (often by clicking
           on the title bar of the desired window). Once our window
           has the keyboard focus, every key press or key release will
           cause an event to be sent to our program (if it regsitered
@@ -1865,10 +1841,10 @@ typedef XCBEnterNotifyEvent XCBLeaveNotifyEvent;
           masks when we create our window:
           </p>
           <ul>
-            <li><span class="code">KeyPressMask</span>: notify us when
+            <li><span class="code">XCB_EVENT_MASK_KEY_PRESS</span>: notify us when
             a key was pressed while any of our controlled windows had
             the keyboard focus.
-            <li><span class="code">KeyReleaseMask</span>: notify us
+            <li><span class="code">XCB_EVENT_MASK_KEY_RELEASE</span>: notify us
             when a key was released while any of our controlled
             windows had the keyboard focus.
           </ul>
@@ -1878,25 +1854,25 @@ typedef XCBEnterNotifyEvent XCBLeaveNotifyEvent;
           </p>
           <pre class="code">
 typedef struct {
-    BYTE response_type;  /* The type of the event */
-    XCBKEYCODE detail;
-    CARD16 sequence;
-    XCBTIMESTAMP time;   /* Time, in milliseconds the event took place in */
-    XCBWINDOW root;
-    XCBWINDOW event;
-    XCBWINDOW child;
-    INT16 root_x;
-    INT16 root_y;
-    INT16 event_x;
-    INT16 event_y;
-    CARD16 state;
-    BOOL same_screen;
-} XCBKeyPressEvent;
-
-typedef XCBKeyPressEvent XCBKeyReleaseEvent;
-</pre>
-        <p>
-        The <span class="code">detail</span> field refer to the
+    uint8_t         response_type; /* The type of the event */
+    xcb_keycode_t   detail;
+    uint16_t        sequence;
+    xcb_timestamp_t time;          /* Time, in milliseconds the event took place in */
+    xcb_window_t    root;
+    xcb_window_t    event;
+    xcb_window_t    child;
+    int16_t         root_x;
+    int16_t         root_y;
+    int16_t         event_x;
+    int16_t         event_y;
+    uint16_t        state;
+    uint8_t         same_screen;
+} xcb_key_press_event_t;
+
+typedef xcb_key_press_event_t xcb_key_release_event_t;
+</pre>
+        <p>
+        The <span class="code">detail</span> field refers to the
         physical key on the keyboard.
         </p>
         <p>
@@ -1906,177 +1882,158 @@ typedef XCBKeyPressEvent XCBKeyReleaseEvent;
         <li class="subtitle"><a name="eventex">X events: a complete example</a>
         <p>
         As an example for handling events, we show a program that
-        creates a window, enter an events loop and check for all the
-        events described above, and write on the terminal the relevant
+        creates a window, enters an events loop and checks for all the
+        events described above, and writes on the terminal the relevant
         characteristics of the event. With this code, it should be
         easy to add drawing operations, like those which have been
         described above.
         </p>
         <pre class="code">
-#include &lt;malloc.h&gt;
+#include &lt;stdlib.h&gt;
 #include &lt;stdio.h&gt;
 
-#include &lt;X11/XCB/xcb.h&gt;
+#include &lt;xcb/xcb.h&gt;
+
+void
+print_modifiers (uint32_t mask)
+{
+  const char **mod, *mods[] = {
+    "Shift", "Lock", "Ctrl", "Alt",
+    "Mod2", "Mod3", "Mod4", "Mod5",
+    "Button1", "Button2", "Button3", "Button4", "Button5"
+  };
+  printf ("Modifier mask: ");
+  for (mod = mods ; mask; mask &gt;&gt;= 1, mod++)
+    if (mask &amp; 1)
+      printf(*mod);
+  putchar ('\n');
+}
 
 int
-main (int argc, char *argv[])
+main ()
 {
-  XCBConnection   *c;
-  XCBSCREEN       *screen;
-  XCBDRAWABLE      win;
-  XCBGenericEvent *e;
-  CARD32           mask = 0;
-  CARD32           values[2];
-  
+  xcb_connection_t    *c;
+  xcb_screen_t        *screen;
+  xcb_window_t         win;
+  xcb_generic_event_t *e;
+  uint32_t             mask = 0;
+  uint32_t             values[2];
+
   /* Open the connection to the X server */
-  c = XCBConnect (NULL, NULL);
-  
+  c = xcb_connect (NULL, NULL);
+
   /* Get the first screen */
-  screen = XCBConnSetupSuccessRepRootsIter (XCBGetSetup (c)).data;
+  screen = xcb_setup_roots_iterator (xcb_get_setup (c)).data;
 
   /* Ask for our window's Id */
-  win.window = XCBWINDOWNew(c);
+  win = xcb_generate_id (c);
 
   /* Create the window */
-  mask = XCBCWBackPixel | XCBCWEventMask;
+  mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
   values[0] = screen-&gt;white_pixel;
-  values[1] = ExposureMask      | ButtonPressMask  | ButtonReleaseMask |
-              PointerMotionMask | EnterWindowMask  | LeaveWindowMask   |
-               KeyPressMask     | KeyReleaseMask;
-  XCBCreateWindow (c,                        /* Connection          */
-                   0,                        /* depth               */
-                   win.window,               /* window Id           */
-                   screen-&gt;root,          /* parent window       */
-                   0, 0,                     /* x, y                */
-                   150, 150,                 /* width, height       */
-                   10,                       /* border_width        */
-                   InputOutput,              /* class               */
-                   screen-&gt;root_visual,   /* visual              */
-                   mask, values);            /* masks */
+  values[1] = XCB_EVENT_MASK_EXPOSURE       | XCB_EVENT_MASK_BUTTON_PRESS   |
+              XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION |
+              XCB_EVENT_MASK_ENTER_WINDOW   | XCB_EVENT_MASK_LEAVE_WINDOW   |
+              XCB_EVENT_MASK_KEY_PRESS      | XCB_EVENT_MASK_KEY_RELEASE;
+  xcb_create_window (c,                             /* Connection          */
+                     0,                             /* depth               */
+                     win,                           /* window Id           */
+                     screen-&gt;root,                  /* parent window       */
+                     0, 0,                          /* x, y                */
+                     150, 150,                      /* width, height       */
+                     10,                            /* border_width        */
+                     XCB_WINDOW_CLASS_INPUT_OUTPUT, /* class               */
+                     screen-&gt;root_visual,           /* visual              */
+                     mask, values);                 /* masks */
 
   /* Map the window on the screen */
-  XCBMapWindow (c, win.window);
-
-  XCBSync (c, 0);
-  while ((e = XCBWaitEvent (c)))
-    {
-      switch (e-&gt;response_type)
-        {
-        case XCBExpose:
-          {
-            XCBExposeEvent *ev = (XCBExposeEvent *)e;
-            
-            printf ("Window %ld exposed. Region to be redrawn at location (%d,%d), with dimension (%d,%d)\n",
-                    ev-&gt;window.xid, ev-&gt;x, ev-&gt;y, ev-&gt;width, ev-&gt;height);
-            break;
-          }
-        case XCBButtonPress: 
-          {
-            XCBButtonPressEvent *ev = (XCBButtonPressEvent *)e;
-            int                  button_num = 0;
-            
-            if ((ev-&gt;state | Button1Mask) == Button1Mask)
-              button_num = 1;
-            if ((ev-&gt;state | Button2Mask) == Button2Mask)
-              button_num = 2;
-            if ((ev-&gt;state | Button3Mask) == Button3Mask)
-              button_num = 3;
-            if ((ev-&gt;state | Button4Mask) == Button4Mask)
-              button_num = 4;
-            if ((ev-&gt;state | Button5Mask) == Button5Mask)
-              button_num = 5;
-              
-            switch (ev-&gt;detail.id)
-              {
-              case 4:
-                {
-                printf ("Wheel Button up in window %ld, at coordinates (%d,%d)\n",
-                        ev-&gt;event.xid, ev-&gt;event_x, ev-&gt;event_y);
-                break;
-                }
-              case 5:
-                {
-                printf ("Wheel Button down in window %ld, at coordinates (%d,%d)\n",
-                        ev-&gt;event.xid, ev-&gt;event_x, ev-&gt;event_y);
-                break;
-                }
-              default:
-                printf ("Button %d pressed in window %ld, at coordinates (%d,%d)\n",
-                        ev-&gt;detail.id, ev-&gt;event.xid, ev-&gt;event_x, ev-&gt;event_y);
-              }
-            break;
-          }
-        case XCBButtonRelease: 
-          {
-            XCBButtonReleaseEvent *ev = (XCBButtonReleaseEvent *)e;
-            int                    button_num = 0;
-            
-            if ((ev-&gt;state | Button1Mask) == Button1Mask)
-              button_num = 1;
-            if ((ev-&gt;state | Button2Mask) == Button2Mask)
-              button_num = 2;
-            if ((ev-&gt;state | Button3Mask) == Button3Mask)
-              button_num = 3;
-            if ((ev-&gt;state | Button4Mask) == Button4Mask)
-              button_num = 4;
-            if ((ev-&gt;state | Button5Mask) == Button5Mask)
-              button_num = 5;
-            
-            printf ("Button %d released in window %ld, at coordinates (%d,%d)\n",
-                    ev-&gt;detail.id, ev-&gt;event.xid, ev-&gt;event_x, ev-&gt;event_y);
-            break;
-          }
-        case XCBMotionNotify:
-          {
-            XCBMotionNotifyEvent *ev = (XCBMotionNotifyEvent *)e;
-            
-            printf ("Mouse moved in window %ld, at coordinates (%d,%d)\n",
-                    ev-&gt;event.xid, ev-&gt;event_x, ev-&gt;event_y);
-            break;
-          }
-        case XCBEnterNotify:
-          {
-            XCBEnterNotifyEvent *ev = (XCBEnterNotifyEvent *)e;
-            
-            printf ("Mouse entered window %ld, at coordinates (%d,%d)\n",
-                    ev-&gt;event.xid, ev-&gt;event_x, ev-&gt;event_y);
-            break;
-          }
-        case XCBLeaveNotify:
-          {
-            XCBLeaveNotifyEvent *ev = (XCBLeaveNotifyEvent *)e;
-            
-            printf ("Mouse leaved window %ld, at coordinates (%d,%d)\n",
-                    ev-&gt;event.xid, ev-&gt;event_x, ev-&gt;event_y);
-            break;
-          }
-        case XCBKeyPress: 
-          {
-            XCBKeyPressEvent *ev = (XCBKeyPressEvent *)e;
-
-            printf ("Key pressed in window %ld\n",
-                    ev-&gt;event.xid);
-            break;
-          }
-        case XCBKeyRelease: 
-          {
-            XCBKeyReleaseEvent *ev = (XCBKeyReleaseEvent *)e;
-
-            printf ("Key releaseed in window %ld\n",
-                    ev-&gt;event.xid);
-            break;
-          }
-        default:
-          {
-            /* Unknown event type, ignore it */
-            break;
-          }
-        }
-      /* Free the Generic Event */
-      free (e);
+  xcb_map_window (c, win);
+
+  xcb_flush (c);
+
+  while ((e = xcb_wait_for_event (c))) {
+    switch (e-&gt;response_type &amp; ~0x80) {
+    case XCB_EXPOSE: {
+      xcb_expose_event_t *ev = (xcb_expose_event_t *)e;
+
+      printf ("Window %ld exposed. Region to be redrawn at location (%d,%d), with dimension (%d,%d)\n",
+              ev-&gt;window, ev-&gt;x, ev-&gt;y, ev-&gt;width, ev-&gt;height);
+      break;
+    }
+    case XCB_BUTTON_PRESS: {
+      xcb_button_press_event_t *ev = (xcb_button_press_event_t *)e;
+      print_modifiers(ev-&gt;state);
+
+      switch (ev-&gt;detail) {
+      case 4:
+        printf ("Wheel Button up in window %ld, at coordinates (%d,%d)\n",
+                ev-&gt;event, ev-&gt;event_x, ev-&gt;event_y);
+        break;
+      case 5:
+        printf ("Wheel Button down in window %ld, at coordinates (%d,%d)\n",
+                ev-&gt;event, ev-&gt;event_x, ev-&gt;event_y);
+        break;
+      default:
+        printf ("Button %d pressed in window %ld, at coordinates (%d,%d)\n",
+                ev-&gt;detail, ev-&gt;event, ev-&gt;event_x, ev-&gt;event_y);
+      }
+      break;
+    }
+    case XCB_BUTTON_RELEASE: {
+      xcb_button_release_event_t *ev = (xcb_button_release_event_t *)e;
+      print_modifiers(ev-&gt;state);
+
+      printf ("Button %d released in window %ld, at coordinates (%d,%d)\n",
+              ev-&gt;detail, ev-&gt;event, ev-&gt;event_x, ev-&gt;event_y);
+      break;
+    }
+    case XCB_MOTION_NOTIFY: {
+      xcb_motion_notify_event_t *ev = (xcb_motion_notify_event_t *)e;
+
+      printf ("Mouse moved in window %ld, at coordinates (%d,%d)\n",
+              ev-&gt;event, ev-&gt;event_x, ev-&gt;event_y);
+      break;
     }
+    case XCB_ENTER_NOTIFY: {
+      xcb_enter_notify_event_t *ev = (xcb_enter_notify_event_t *)e;
 
-  return 1;
+      printf ("Mouse entered window %ld, at coordinates (%d,%d)\n",
+              ev-&gt;event, ev-&gt;event_x, ev-&gt;event_y);
+      break;
+    }
+    case XCB_LEAVE_NOTIFY: {
+      xcb_leave_notify_event_t *ev = (xcb_leave_notify_event_t *)e;
+
+      printf ("Mouse left window %ld, at coordinates (%d,%d)\n",
+              ev-&gt;event, ev-&gt;event_x, ev-&gt;event_y);
+      break;
+    }
+    case XCB_KEY_PRESS: {
+      xcb_key_press_event_t *ev = (xcb_key_press_event_t *)e;
+      print_modifiers(ev-&gt;state);
+
+      printf ("Key pressed in window %ld\n",
+              ev-&gt;event);
+      break;
+    }
+    case XCB_KEY_RELEASE: {
+      xcb_key_release_event_t *ev = (xcb_key_release_event_t *)e;
+      print_modifiers(ev-&gt;state);
+
+      printf ("Key released in window %ld\n",
+              ev-&gt;event);
+      break;
+    }
+    default:
+      /* Unknown event type, ignore it */
+      printf("Unknown event: %d\n", e-&gt;response_type);
+      break;
+    }
+    /* Free the Generic Event */
+    free (e);
+  }
+
+  return 0;
 }
 </pre>
       </ol>
@@ -2092,18 +2049,314 @@ main (int argc, char *argv[])
       <ol>
         <li class="subtitle"><a name="fontstruct">The Font structure</a>
         <p>
-        In order to support flexible fonts, a font structure is
-        defined. You know what ? Its an Id:
+        In order to support flexible fonts, a font type is
+        defined. You know what ? It's an Id:
         </p>
         <pre class="code">
-typedef struct {
-    CARD32 xid;
-} XCBFONT;
+typedef uint32_t xcb_font_t;
 </pre>
         <p>
         It is used to contain information about a font, and is passed
         to several functions that handle fonts selection and text drawing.
+        We ask the X server to attribute an  Id to our font with the
+        function:
+        </p>
+        <pre class="code">
+xcb_font_t xcb_generate_id (xcb_connection_t *c);
+</pre>
+        <br>
+        <li class="subtitle"><a name="openingfont">Opening a Font</a>
+        <p>
+        To open a font, we use the following function:
+        </p>
+        <pre class="code">
+xcb_void_cookie_t xcb_open_font (xcb_connection_t *c,
+                                 xcb_font_t        fid,
+                                 uint16_t          name_len,
+                                 const char       *name);
+</pre>
+        <p>
+        The <span class="code">fid</span> parameter is the font Id
+        defined by <span class="code">xcb_generate_id()</span> (see
+        above). The <span class="code">name</span> parameter is the
+        name of the font you want to open. Use the command
+        <span class="code">xlsfonts</span> in a terminal to know which
+        are the fonts available on your computer. The parameter
+        <span class="code">name_len</span> is the length of the name
+        of the font (given by <span class="code">strlen()</span>).
+        </p>
+        <li class="subtitle"><a name="assigningfont">Assigning a Font to a Graphic Context</a>
+        <p>
+        Once a font is opened, you have to create a Graphic Context
+        that will contain the informations about the color of the
+        foreground and the background used when you draw a text in a
+        Drawable. Here is an exemple of a Graphic Context that will
+        allow us to draw an opened font with a black foreground and a
+        white background:
+        </p>
+        <pre class="code">
+  /*
+   * c is the connection
+   * screen is the screen where the window is displayed
+   * window is the window in which we will draw the text
+   * font is the opened font
+   */
+
+  uint32_t             value_list[3];
+  xcb_gcontext_t       gc;
+  uint32_t             mask;
+
+  gc = xcb_generate_id (c);
+  mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT;
+  value_list[0] = screen->black_pixel;
+  value_list[1] = screen->white_pixel;
+  value_list[2] = font;
+  xcb_create_gc (c, gc, window, mask, value_list);
+
+  /* The font is not needed anymore, so we close it */
+  xcb_close_font (c, font);
+</pre>
+        <li class="subtitle"><a name="drawingtext">Drawing text in a drawable</a>
+        <p>
+        To draw a text in a drawable, we use the following function:
+        </p>
+        <pre class="code">
+xcb_void_cookie_t xcb_image_text_8 (xcb_connection_t *c,
+                                    uint8_t           string_len,
+                                    xcb_drawable_t    drawable,
+                                    xcb_gcontext_t    gc,
+                                    int16_t           x,
+                                    int16_t           y,
+                                    const char       *string);
+</pre>
+        <p>
+        The <span class="code">string</span> parameter is the text to
+        draw. The location of the drawing is given by the parameters
+        <span class="code">x</span> and <span class="code">y</span>.
+        The base line of the text is exactly the parameter
+        <span class="code">y</span>.
         </p>
+        <li class="subtitle"><a name="fontcompleteexample">Complete example</a>
+        <p>
+        This example draw a text at 10 pixels (for the base line) of
+        the bottom of a window. Pressing the Esc key exits the program.
+        </p>
+        <pre class="code">
+#include &lt;stdlib.h&gt;
+#include &lt;stdio.h&gt;
+#include &lt;string.h&gt;
+
+#include &lt;xcb/xcb.h&gt;
+
+#define WIDTH 300
+#define HEIGHT 100
+
+
+
+static xcb_gc_t gc_font_get (xcb_connection_t *c,
+                             xcb_screen_t     *screen,
+                             xcb_window_t      window,
+                             const char       *font_name);
+
+static void text_draw (xcb_connection_t *c,
+                       xcb_screen_t     *screen,
+                       xcb_window_t      window,
+                       int16_t           x1,
+                       int16_t           y1,
+                       const char       *label);
+
+static void
+text_draw (xcb_connection_t *c,
+           xcb_screen_t     *screen,
+           xcb_window_t      window,
+           int16_t           x1,
+           int16_t           y1,
+           const char       *label)
+{
+  xcb_void_cookie_t    cookie_gc;
+  xcb_void_cookie_t    cookie_text;
+  xcb_generic_error_t *error;
+  xcb_gcontext_t       gc;
+  uint8_t              length;
+
+  length = strlen (label);
+
+  gc = gc_font_get(c, screen, window, "7x13");
+
+  cookie_text = xcb_image_text_8_checked (c, length, window, gc,
+                                          x1,
+                                          y1, label);
+  error = xcb_request_check (c, cookie_text);
+  if (error) {
+    fprintf (stderr, "ERROR: can't paste text : %d\n", error->error_code);
+    xcb_disconnect (c);
+    exit (-1);
+  }
+
+  cookie_gc = xcb_free_gc (c, gc);
+  error = xcb_request_check (c, cookie_gc);
+  if (error) {
+    fprintf (stderr, "ERROR: can't free gc : %d\n", error->error_code);
+    xcb_disconnect (c);
+    exit (-1);
+  }
+}
+
+static xcb_gc_t
+gc_font_get (xcb_connection_t *c,
+             xcb_screen_t     *screen,
+             xcb_window_t      window,
+             const char       *font_name)
+{
+  uint32_t             value_list[3];
+  xcb_void_cookie_t    cookie_font;
+  xcb_void_cookie_t    cookie_gc;
+  xcb_generic_error_t *error;
+  xcb_font_t           font;
+  xcb_gcontext_t       gc;
+  uint32_t             mask;
+
+  font = xcb_generate_id (c);
+  cookie_font = xcb_open_font_checked (c, font,
+                                       strlen (font_name),
+                                       font_name);
+
+  error = xcb_request_check (c, cookie_font);
+  if (error) {
+    fprintf (stderr, "ERROR: can't open font : %d\n", error->error_code);
+    xcb_disconnect (c);
+    return -1;
+  }
+
+  gc = xcb_generate_id (c);
+  mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT;
+  value_list[0] = screen->black_pixel;
+  value_list[1] = screen->white_pixel;
+  value_list[2] = font;
+  cookie_gc = xcb_create_gc_checked (c, gc, window, mask, value_list);
+  error = xcb_request_check (c, cookie_gc);
+  if (error) {
+    fprintf (stderr, "ERROR: can't create gc : %d\n", error->error_code);
+    xcb_disconnect (c);
+    exit (-1);
+  }
+
+  cookie_font = xcb_close_font_checked (c, font);
+  error = xcb_request_check (c, cookie_font);
+  if (error) {
+    fprintf (stderr, "ERROR: can't close font : %d\n", error->error_code);
+    xcb_disconnect (c);
+    exit (-1);
+  }
+
+  return gc;
+}
+
+int main ()
+{
+  xcb_screen_iterator_t screen_iter;
+  xcb_connection_t     *c;
+  const xcb_setup_t    *setup;
+  xcb_screen_t         *screen;
+  xcb_generic_event_t  *e;
+  xcb_generic_error_t  *error;
+  xcb_void_cookie_t     cookie_window;
+  xcb_void_cookie_t     cookie_map;
+  xcb_window_t          window;
+  uint32_t              mask;
+  uint32_t              values[2];
+  int                   screen_number;
+
+  /* getting the connection */
+  c = xcb_connect (NULL, &amp;screen_number);
+  if (!c) {
+    fprintf (stderr, "ERROR: can't connect to an X server\n");
+    return -1;
+  }
+
+  /* getting the current screen */
+  setup = xcb_get_setup (c);
+
+  screen = NULL;
+  screen_iter = xcb_setup_roots_iterator (setup);
+  for (; screen_iter.rem != 0; --screen_number, xcb_screen_next (&amp;screen_iter))
+    if (screen_number == 0)
+      {
+        screen = screen_iter.data;
+        break;
+      }
+  if (!screen) {
+    fprintf (stderr, "ERROR: can't get the current screen\n");
+    xcb_disconnect (c);
+    return -1;
+  }
+
+  /* creating the window */
+  window = xcb_generate_id (c);
+  mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
+  values[0] = screen->white_pixel;
+  values[1] =
+    XCB_EVENT_MASK_KEY_RELEASE |
+    XCB_EVENT_MASK_BUTTON_PRESS |
+    XCB_EVENT_MASK_EXPOSURE |
+    XCB_EVENT_MASK_POINTER_MOTION;
+  cookie_window = xcb_create_window_checked (c,
+                                             screen->root_depth,
+                                             window, screen->root,
+                                             20, 200, WIDTH, HEIGHT,
+                                             0, XCB_WINDOW_CLASS_INPUT_OUTPUT,
+                                             screen->root_visual,
+                                             mask, values);
+  cookie_map = xcb_map_window_checked (c, window);
+
+  /* error managing */
+  error = xcb_request_check (c, cookie_window);
+  if (error) {
+    fprintf (stderr, "ERROR: can't create window : %d\n", error->error_code);
+    xcb_disconnect (c);
+    return -1;
+  }
+  error = xcb_request_check (c, cookie_map);
+  if (error) {
+    fprintf (stderr, "ERROR: can't map window : %d\n", error->error_code);
+    xcb_disconnect (c);
+    return -1;
+  }
+
+  xcb_flush(c);
+
+  while (1) {
+    e = xcb_poll_for_event(c);
+    if (e) {
+      switch (e->response_type &amp; ~0x80) {
+      case XCB_EXPOSE: {
+        char *text;
+
+        text = "Press ESC key to exit...";
+        text_draw (c, screen, window, 10, HEIGHT - 10, text);
+        break;
+      }
+      case XCB_KEY_RELEASE: {
+        xcb_key_release_event_t *ev;
+
+        ev = (xcb_key_release_event_t *)e;
+
+        switch (ev->detail) {
+          /* ESC */
+        case 9:
+          free (e);
+          xcb_disconnect (c);
+          return 0;
+        }
+      }
+      }
+      free (e);
+    }
+  }
+
+  return 0;
+}
+</pre>
       </ol>
       <li class="title"><a name="wm">Interacting with the window manager</a>
       <p>
@@ -2124,49 +2377,48 @@ typedef struct {
         <p>
         Many of the parameters communicated to the window manager are
         passed using data called "properties". These properties are
-        attached by the X server to different windows, and are stores
+        attached by the X server to different windows, and are stored
         in a format that makes it possible to read them from different
         machines that may use different architectures (remember that
         an X client program may run on a remote machine).
         </p>
         <p>
         The property and its type (a string, an integer, etc) are
-        Id. Their type are <span class="code">XCBATOM</span>:
+        Id. Their type are <span class="code">xcb_atom_t</span>:
         </p>
         <pre class="code">
-typedef struct {
-    CARD32 xid;
-} XCBATOM;
+typedef uint32_t xcb_atom_t;
 </pre>
         <p>
         To change the property of a window, we use the following
         function:
         </p>
         <pre class="code">
-XCBVoidCookie XCBChangeProperty (XCBConnection *c,  /* Connection to the X server */
-                                 CARD8 mode,        /* Property mode */
-                                 XCBWINDOW window,  /* Window */
-                                 XCBATOM property,  /* Property to change */
-                                 XCBATOM type,      /* Type of the property */
-                                 CARD8 format,      /* Format of the property (8, 16, 32) */
-                                 CARD32 data_len,   /* Length of the data parameter */
-                                 const void *data); /* Data */
+xcb_void_cookie_t xcb_change_property (xcb_connection_t *c,       /* Connection to the X server */
+                                       uint8_t          mode,     /* Property mode */
+                                       xcb_window_t     window,   /* Window */
+                                       xcb_atom_t       property, /* Property to change */
+                                       xcb_atom_t       type,     /* Type of the property */
+                                       uint8_t          format,   /* Format of the property (8, 16, 32) */
+                                       uint32_t         data_len, /* Length of the data parameter */
+                                       const void      *data);    /* Data */
 </pre>
         <p>
         The <span class="code">mode</span> parameter coud be one of
-        the following value (defined in the X.h header file):
+        the following values (defined in enumeration xcb_prop_mode_t in
+        the xproto.h header file):
         </p>
         <ul>
-          <li>PropModeReplace
-          <li>PropModePrepend
-          <li>PropModeAppend
+          <li>XCB_PROP_MODE_REPLACE
+          <li>XCB_PROP_MODE_PREPEND
+          <li>XCB_PROP_MODE_APPEND
         </ul>
         <br>
         <li class="subtitle"><a name="wmname">Setting the window name and icon name</a>
         <p>
-        The firt thing we want to do would be to set the name for our
+        The first thing we want to do would be to set the name for our
         window. This is done using the
-        <span class="code">XCBChangeProperty()</span> function. This
+        <span class="code">xcb_change_property()</span> function. This
         name may be used by the window manager as the title of the
         window (in the title bar), in a task list, etc. The property
         atom to use to set the name of a window is
@@ -2178,59 +2430,59 @@ XCBVoidCookie XCBChangeProperty (XCBConnection *c,  /* Connection to the X serve
         <pre class="code">
 #include &lt;string.h&gt;
 
-#include &lt;X11/XCB/xcb.h&gt;
-#include &lt;X11/XCB/xcb_atom.h&gt;
+#include &lt;xcb/xcb.h&gt;
+#include &lt;xcb/xcb_atom.h&gt;
 
 int
-main (int argc, char *argv[])
+main ()
 {
-  XCBConnection *c;
-  XCBSCREEN     *screen;
-  XCBDRAWABLE    win;
-  char          *title = "Hello World !";
-  char          *title_icon = "Hello World ! (iconified)";
+  xcb_connection_t *c;
+  xcb_screen_t     *screen;
+  xcb_window_t      win;
+  char             *title = "Hello World !";
+  char             *title_icon = "Hello World ! (iconified)";
+
 
 
-  
   /* Open the connection to the X server */
-  c = XCBConnect (NULL, NULL);
-  
+  c = xcb_connect (NULL, NULL);
+
   /* Get the first screen */
-  screen = XCBConnSetupSuccessRepRootsIter (XCBGetSetup (c)).data;
+  screen = xcb_setup_roots_iterator (xcb_get_setup (c)).data;
 
   /* Ask for our window's Id */
-  win.window = XCBWINDOWNew(c);
+  win = xcb_generate_id (c);
 
   /* Create the window */
-  XCBCreateWindow (c,                        /* Connection          */
-                    0,                        /* depth               */
-                   win.window,               /* window Id           */
-                   screen-&gt;root,             /* parent window       */
-                   0, 0,                     /* x, y                */
-                   250, 150,                 /* width, height       */
-                   10,                       /* border_width        */
-                   InputOutput,              /* class               */
-                   screen-&gt;root_visual,      /* visual              */
-                   0, NULL);                 /* masks, not used     */
+  xcb_create_window (c,                             /* Connection          */
+                     0,                             /* depth               */
+                     win,                           /* window Id           */
+                     screen-&gt;root,                  /* parent window       */
+                     0, 0,                          /* x, y                */
+                     250, 150,                      /* width, height       */
+                     10,                            /* border_width        */
+                     XCB_WINDOW_CLASS_INPUT_OUTPUT, /* class               */
+                     screen-&gt;root_visual,           /* visual              */
+                     0, NULL);                      /* masks, not used     */
 
   /* Set the title of the window */
-  XCBChangeProperty(c, PropModeReplace, win.window,
-                    WM_NAME, STRING, 8,
-                    strlen(title), title);
+  xcb_change_property (c, XCB_PROP_MODE_REPLACE, win,
+                       WM_NAME, STRING, 8,
+                       strlen (title), title);
 
   /* Set the title of the window icon */
-  XCBChangeProperty(c, PropModeReplace, win.window,
-                    WM_ICON_NAME, STRING, 8,
-                    strlen(title_icon), title_icon);
+  xcb_change_property (c, XCB_PROP_MODE_REPLACE, win,
+                       WM_ICON_NAME, STRING, 8,
+                       strlen(title_icon), title_icon);
 
   /* Map the window on the screen */
-  XCBMapWindow (c, win.window);
+  xcb_map_window (c, win);
+
+  xcb_flush (c);
 
-  XCBSync (c, 0);
-  
   while (1) {}
 
-  return 1;
+  return 0;
 }
 </pre>
         <div class="emph">
@@ -2277,7 +2529,8 @@ gcc prog.c -o prog `pkg-config --cflags --libs xcb_atom`
         To map a window, you use the following function:
         </p>
         <pre class="code">
-XCBVoidCookie XCBMapWindow(XCBConnection *c, XCBWINDOW window);
+xcb_void_cookie_t xcb_map_window (xcb_connection_t *c,
+                                  xcb_window_t      window);
 </pre>
         <p>
         To have a simple example, see the <a href="#helloworld">example</a>
@@ -2290,44 +2543,45 @@ XCBVoidCookie XCBMapWindow(XCBConnection *c, XCBWINDOW window);
         Un-mapping a window is also simple. You use the function
         </p>
         <pre class="code">
-XCBVoidCookie XCBUnmapWindow(XCBConnection *c, XCBWINDOW window);
+xcb_void_cookie_t xcb_unmap_window (xcb_connection_t *c,
+                                    xcb_window_t      window);
 </pre>
         <p>
         The utilization of this function is the same as
-        <span class="code">XCBMapWindow()</span>.
+        <span class="code">xcb_map_window()</span>.
         </p>
         <li class="subtitle"><a name="winconf">Configuring a window</a>
         <p>
         As we have seen when we have created our first window, in the
-        X Events subsection, we can set some attributes to the window
+        X Events subsection, we can set some attributes for the window
         (that is, the position, the size, the events the window will
         receive, etc). If we want to modify them, but the window is
         already created, we can change them by using the following
         function:
         </p>
         <pre class="code">
-XCBVoidCookie XCBConfigureWindow (XCBConnection *c,            /* The connection to the X server*/
-                                  XCBWINDOW      window,       /* The window to configure */
-                                  CARD16         value_mask,   /* The mask */
-                                  const CARD32  *value_list);  /* The values to set */
+xcb_void_cookie_t xcb_configure_window (xcb_connection_t *c,            /* The connection to the X server*/
+                                        xcb_window_t      window,       /* The window to configure */
+                                        uint16_t          value_mask,   /* The mask */
+                                        const uint32_t   *value_list);  /* The values to set */
 </pre>
         <p>
         We set the <span class="code">value_mask</span> to one or
-        several mask values that are in the X.h header:
+        several mask values that are in the xcb_config_window_t enumeration in the xproto.h header:
         </p>
         <ul>
-           <li><span class="code">CWX</span>: new x coordinate of the window's top left corner
-          <li><span class="code">CWY</span>: new y coordinate of the window's top left corner
-          <li><span class="code">CWWidth</span>: new width of the window
-          <li><span class="code">CWHeight</span>: new height of the window
-          <li><span class="code">CWBorderWidth</span>: new width of the border of the window
-          <li><span class="code">CWSibling</span>
-          <li><span class="code">CWStackMode</span>: the new stacking order
+          <li><span class="code">XCB_CONFIG_WINDOW_X</span>: new x coordinate of the window's top left corner
+          <li><span class="code">XCB_CONFIG_WINDOW_Y</span>: new y coordinate of the window's top left corner
+          <li><span class="code">XCB_CONFIG_WINDOW_WIDTH</span>: new width of the window
+          <li><span class="code">XCB_CONFIG_WINDOW_HEIGHT</span>: new height of the window
+          <li><span class="code">XCB_CONFIG_WINDOW_BORDER_WIDTH</span>: new width of the border of the window
+          <li><span class="code">XCB_CONFIG_WINDOW_SIBLING</span>
+          <li><span class="code">XCB_CONFIG_WINDOW_STACK_MODE</span>: the new stacking order
         </ul>
         <p>
         We then give to <span class="code">value_mask</span> the new
         value. We now describe how to use
-        <span class="code">XCBConfigureWindow</span> in some useful
+        <span class="code">xcb_configure_window_t</span> in some useful
         situations.
         </p>
         <li class="subtitle"><a name="winmove">Moving a window around the screen</a>
@@ -2336,12 +2590,12 @@ XCBVoidCookie XCBConfigureWindow (XCBConnection *c,            /* The connection
         to a different location. This can be done like this:
         </p>
         <pre class="code">
-const static CARD32 values[] = { 10, 20 };
+const static uint32_t values[] = { 10, 20 };
 
 /* The connection c and the window win are supposed to be defined */
 
 /* Move the window to coordinates x = 10 and y = 20 */
-XCBConfigureWindow (c, win, CWX | CWY, values);
+xcb_configure_window (c, win, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, values);
 </pre>
         <p>
         Note that when the window is moved, it might get partially
@@ -2355,51 +2609,51 @@ XCBConfigureWindow (c, win, CWX | CWY, values);
         window. This is done using the following code:
         </p>
         <pre class="code">
-const static CARD32 values[] = { 200, 300 };
+const static uint32_t values[] = { 200, 300 };
 
 /* The connection c and the window win are supposed to be defined */
 
 /* Resize the window to width = 10 and height = 20 */
-XCBConfigureWindow (c, win, CWWidth | CWHeight, values);
+xcb_configure_window (c, win, XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, values);
 </pre>
         <p>
         We can also combine the move and resize operations using one
-        single call to <span class="code">XCBConfigureWindow</span>:
+        single call to <span class="code">xcb_configure_window_t</span>:
         </p>
         <pre class="code">
-const static CARD32 values[] = { 10, 20, 200, 300 };
+const static uint32_t values[] = { 10, 20, 200, 300 };
 
 /* The connection c and the window win are supposed to be defined */
 
 /* Move the window to coordinates x = 10 and y = 20 */
 /* and resize the window to width = 10 and height = 20 */
-XCBConfigureWindow (c, win, CWX | CWY | CWWidth | CWHeight, values);
+xcb_configure_window (c, win, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, values);
 </pre>
         <li class="subtitle"><a name="winstack">Changing windows stacking order: raise and lower</a>
         <p>
         Until now, we changed properties of a single window. We'll see
         that there are properties that relate to the window and other
-        windows. One of hem is the stacking order. That is, the order
+        windows. One of them is the stacking order. That is, the order
         in which the windows are layered on top of each other. The
         front-most window is said to be on the top of the stack, while
         the back-most window is at the bottom of the stack. Here is
         how to manipulate our windows stack order:
         </p>
         <pre class="code">
-const static CARD32 values[] = { Above };
+const static uint32_t values[] = { XCB_STACK_MODE_ABOVE };
 
 /* The connection c and the window win are supposed to be defined */
 
 /* Move the window on the top of the stack */
-XCBConfigureWindow (c, win, CWStackMode, values);
+xcb_configure_window (c, win, XCB_CONFIG_WINDOW_STACK_MODE, values);
 </pre>
         <pre class="code">
-const static CARD32 values[] = { Below };
+const static uint32_t values[] = { XCB_STACK_MODE_BELOW };
 
 /* The connection c and the window win are supposed to be defined */
 
 /* Move the window on the bottom of the stack */
-XCBConfigureWindow (c, win, CWStackMode, values);
+xcb_configure_window (c, win, XCB_CONFIG_WINDOW_STACK_MODE, values);
 </pre>
         <li class="subtitle"><a name="wingetinfo">Getting information about a window</a>
         <p>
@@ -2412,47 +2666,47 @@ XCBConfigureWindow (c, win, CWStackMode, values);
         </p>
         <pre class="code">
 typedef struct {
-    BYTE response_type;
-    CARD8 depth;            /* depth of the window */
-    CARD16 sequence;
-    CARD32 length;
-    XCBWINDOW root;         /* Id of the root window *>
-    INT16 x;                /* X coordinate of the window's location */
-    INT16 y;                /* Y coordinate of the window's location */
-    CARD16 width;           /* Width of the window */
-    CARD16 height;          /* Height of the window */
-    CARD16 border_width;    /* Width of the window's border */
-} XCBGetGeometryRep;
+    uint8_t      response_type;
+    uint8_t      depth;         /* depth of the window */
+    uint16_t     sequence;
+    uint32_t     length;
+    xcb_window_t root;          /* Id of the root window *>
+    int16_t      x;             /* X coordinate of the window's location */
+    int16_t      y;             /* Y coordinate of the window's location */
+    uint16_t     width;         /* Width of the window */
+    uint16_t     height;        /* Height of the window */
+    uint16_t     border_width;  /* Width of the window's border */
+} xcb_get_geometry_reply_t;
 </pre>
         <p>
         XCB fill this structure with two functions:
         </p>
         <pre class="code">
-XCBGetGeometryCookie  XCBGetGeometry      (XCBConnection         *c,
-                                           XCBDRAWABLE            drawable);
-XCBGetGeometryRep    *XCBGetGeometryReply (XCBConnection         *c,
-                                           XCBGetGeometryCookie   cookie,
-                                           XCBGenericError      **e);
+xcb_get_geometry_cookie_t  xcb_get_geometry       (xcb_connection_t         *c,
+                                                   xcb_drawable_t            drawable);
+xcb_get_geometry_reply_t  *xcb_get_geometry_reply (xcb_connection_t         *c,
+                                                   xcb_get_geometry_cookie_t cookie,
+                                                   xcb_generic_error_t     **e);
 </pre>
         <p>
         You use them as follows:
         </p>
         <pre class="code">
-  XCBConnection     *c;
-  XCBDRAWABLE        win;
-  XCBGetGeometryRep *geom;
+  xcb_connection_t         *c;
+  xcb_drawable_t            win;
+  xcb_get_geometry_reply_t *geom;
 
   /* You initialize c and win */
 
-  geom = XCBGetGeometryReply (c, XCBGetGeometry (c, win), 0);
+  geom = xcb_get_geometry_reply (c, xcb_get_geometry (c, win), NULL);
 
   /* Do something with the fields of geom */
-  
+
   free (geom);
 </pre>
         <p>
         Remark that you have to free the structure, as
-        <span class="code">XCBGetGeometryReply</span> allocates a
+        <span class="code">xcb_get_geometry_reply_t</span> allocates a
         newly one.
         </p>
         <p>
@@ -2469,79 +2723,79 @@ XCBGetGeometryRep    *XCBGetGeometryReply (XCBConnection         *c,
         </p>
         <pre class="code">
 typedef struct {
-    BYTE response_type;
-    CARD8 pad0;
-    CARD16 sequence;
-    CARD32 length;
-    XCBWINDOW root;
-    XCBWINDOW parent;    /* Id of the parent window */
-    CARD16 children_len;
-    CARD8 pad1[14];
-} XCBQueryTreeRep;
+    uint8_t      response_type;
+    uint8_t      pad0;
+    uint16_t     sequence;
+    uint32_t     length;
+    xcb_window_t root;
+    xcb_window_t parent;       /* Id of the parent window */
+    uint16_t     children_len;
+    uint8_t      pad1[14];
+} xcb_query_tree_reply_t;
 </pre>
         <p>
         To fill this structure, we use these two functions:
         </p>
         <pre class="code">
-XCBQueryTreeCookie XCBQueryTree      (XCBConnection       *c,
-                                      XCBWINDOW            window);
-XCBQueryTreeRep   *XCBQueryTreeReply (XCBConnection       *c,
-                                      XCBQueryTreeCookie   cookie,
-                                      XCBGenericError    **e);
+xcb_query_tree_cookie_t xcb_query_tree       (xcb_connection_t        *c,
+                                              xcb_window_t             window);
+xcb_query_tree_reply_t *xcb_query_tree_reply (xcb_connection_t        *c,
+                                              xcb_query_tree_cookie_t  cookie,
+                                              xcb_generic_error_t    **e);
 </pre>
         <p>
         The translated coordinates will be found in this structure:
         </p>
         <pre class="code">
 typedef struct {
-    BYTE response_type;
-    BOOL same_screen;
-    CARD16 sequence;
-    CARD32 length;
-    XCBWINDOW child;
-    CARD16 dst_x;        /* Translated x coordinate */
-    CARD16 dst_y;        /* Translated y coordinate */
-} XCBTranslateCoordinatesRep;
+    uint8_t      response_type;
+    uint8_t      same_screen;
+    uint16_t     sequence;
+    uint32_t     length;
+    xcb_window_t child;
+    uint16_t     dst_x;        /* Translated x coordinate */
+    uint16_t     dst_y;        /* Translated y coordinate */
+} xcb_translate_coordinates_reply_t;
 </pre>
         <p>
         As usual, we need two functions to fill this structure:
         </p>
         <pre class="code">
-XCBTranslateCoordinatesCookie XCBTranslateCoordinates      (XCBConnection                  *c,
-                                                            XCBWINDOW                       src_window,
-                                                            XCBWINDOW                       dst_window,
-                                                            INT16                           src_x,
-                                                            INT16                           src_y);
-XCBTranslateCoordinatesRep   *XCBTranslateCoordinatesReply (XCBConnection                 *c,
-                                                            XCBTranslateCoordinatesCookie   cookie,
-                                                            XCBGenericError               **e);
+xcb_translate_coordinates_cookie_t xcb_translate_coordinates       (xcb_connection_t                  *c,
+                                                                    xcb_window_t                       src_window,
+                                                                    xcb_window_t                       dst_window,
+                                                                    int16_t                            src_x,
+                                                                    int16_t                            src_y);
+xcb_translate_coordinates_reply_t *xcb_translate_coordinates_reply (xcb_connection_t                  *c,
+                                                                    xcb_translate_coordinates_cookie_t cookie,
+                                                                    xcb_generic_error_t              **e);
 </pre>
         <p>
         We use them as follows:
         </p>
         <pre class="code">
-  XCBConnection              *c;
-  XCBDRAWABLE                 win;
-  XCBGetGeometryRep          *geom;
-  XCBQueryTreeRep            *tree;
-  XCBTranslateCoordinatesRep *trans;
+  xcb_connection_t                  *c;
+  xcb_drawable_t                     win;
+  xcb_get_geometry_reply_t          *geom;
+  xcb_query_tree_reply_t            *tree;
+  xcb_translate_coordinates_reply_t *trans;
 
   /* You initialize c and win */
 
-  geom  = XCBGetGeometryReply (c, XCBGetGeometry (c, win), 0);
+  geom  = xcb_get_geometry_reply (c, xcb_get_geometry (c, win), NULL);
   if (!geom)
     return 0;
 
-  tree  = XCBQueryTreeReply (c, XCBQueryTree (c, win), 0);
+  tree  = xcb_query_tree_reply (c, xcb_query_tree (c, win), NULL);
   if (!tree)
     return 0;
 
-  trans = XCBTranslateCoordinatesReply (c,
-                                        XCBTranslateCoordinates (c,
-                                                                 win,
-                                                                 tree-&gt;parent,
-                                                                 geom-&gt;x, geom-&gt;y),
-                                        0);
+  trans = xcb_translate_coordinates_reply (c,
+                                           xcb_translate_coordinates (c,
+                                                                      win,
+                                                                      tree-&gt;parent,
+                                                                      geom-&gt;x, geom-&gt;y),
+                                           NULL);
   if (!trans)
     return 0;
 
@@ -2568,53 +2822,53 @@ XCBTranslateCoordinatesRep   *XCBTranslateCoordinatesReply (XCBConnection
         </p>
         <pre class="code">
 typedef struct {
-    BYTE response_type;
-    CARD8 backing_store;
-    CARD16 sequence;
-    CARD32 length;
-    XCBVISUALID visual;            /* Visual of the window */
-    CARD16 _class;
-    CARD8 bit_gravity;
-    CARD8 win_gravity;
-    CARD32 backing_planes;
-    CARD32 backing_pixel;
-    BOOL save_under;
-    BOOL map_is_installed;
-    CARD8 map_state;               /* Map state of the window */
-    BOOL override_redirect;
-    XCBCOLORMAP colormap;          /* Colormap of the window */
-    CARD32 all_event_masks;
-    CARD32 your_event_mask;
-    CARD16 do_not_propagate_mask;
-} XCBGetWindowAttributesRep;
+    uint8_t        response_type;
+    uint8_t        backing_store;
+    uint16_t       sequence;
+    uint32_t       length;
+    xcb_visualid_t visual;                /* Visual of the window */
+    uint16_t       _class;
+    uint8_t        bit_gravity;
+    uint8_t        win_gravity;
+    uint32_t       backing_planes;
+    uint32_t       backing_pixel;
+    uint8_t        save_under;
+    uint8_t        map_is_installed;
+    uint8_t        map_state;             /* Map state of the window */
+    uint8_t        override_redirect;
+    xcb_colormap_t colormap;              /* Colormap of the window */
+    uint32_t       all_event_masks;
+    uint32_t       your_event_mask;
+    uint16_t       do_not_propagate_mask;
+} xcb_get_window_attributes_reply_t;
 </pre>
         <p>
         XCB supplies these two functions to fill it:
         </p>
         <pre class="code">
-XCBGetWindowAttributesCookie XCBGetWindowAttributes      (XCBConnection                 *c, 
-                                                          XCBWINDOW                      window);
-XCBGetWindowAttributesRep   *XCBGetWindowAttributesReply (XCBConnection                 *c, 
-                                                          XCBGetWindowAttributesCookie   cookie,
-                                                          XCBGenericError              **e);
+xcb_get_window_attributes_cookie_t xcb_get_window_attributes       (xcb_connection_t                  *c,
+                                                                    xcb_window_t                       window);
+xcb_get_window_attributes_reply_t *xcb_get_window_attributes_reply (xcb_connection_t                  *c,
+                                                                    xcb_get_window_attributes_cookie_t cookie,
+                                                                    xcb_generic_error_t              **e);
 </pre>
         <p>
         You use them as follows:
         </p>
         <pre class="code">
-  XCBConnection             *c;
-  XCBDRAWABLE                win;
-  XCBGetWindowAttributesRep *attr;
+  xcb_connection_t                  *c;
+  xcb_drawable_t                     win;
+  xcb_get_window_attributes_reply_t *attr;
 
   /* You initialize c and win */
 
-  attr = XCBGetWindowAttributesReply (c, XCBGetWindowAttributes (c, win), 0);
+  attr = xcb_get_window_attributes_reply (c, xcb_get_window_attributes (c, win), NULL);
 
   if (!attr)
     return 0;
 
   /* Do something with the fields of attr */
-  
+
   free (attr);
 </pre>
         <p>
@@ -2638,7 +2892,7 @@ XCBGetWindowAttributesRep   *XCBGetWindowAttributesReply (XCBConnection
         application allocated the colors it needed, and when all the
         color entries (4, 16, 256 colors) were in use, the next color
         allocation would fail.
-        </p>      
+        </p>
         <p>
         Thus, the notion of "a color map" was introduced. A color map
         is a table whose size is the same as the number of
@@ -2693,36 +2947,34 @@ XCBGetWindowAttributesRep   *XCBGetWindowAttributesReply (XCBConnection
         In XCB, a color map is (as often in X) an Id:
         </p>
         <pre class="code">
-typedef struct {
-    CARD32 xid;
-} XCBCOLORMAP;
+typedef uint32_t xcb_colormap_t;
 </pre>
         <p>
         In order to access the screen's default color map, you just
-        have to retrieve the <span class="code">default_colormap</span> 
-        field of the <span class="code">XCBSCREEN</span> structure
+        have to retrieve the <span class="code">default_colormap</span>
+        field of the <span class="code">xcb_screen_t</span> structure
         (see Section
         <a href="#screen">Checking basic information about a connection</a>):
         </p>
         <pre class="code">
 #include &lt;stdio.h&gt;
 
-#include &lt;X11/XCB/xcb.h&gt;
+#include &lt;xcb/xcb.h&gt;
 
 int
-main (int argc, char *argv[])
+main ()
 {
-  XCBConnection *c;
-  XCBSCREEN     *screen;
-  XCBCOLORMAP    colormap;
-  
+  xcb_connection_t *c;
+  xcb_screen_t     *screen;
+  xcb_colormap_t    colormap;
+
   /* Open the connection to the X server and get the first screen */
-  c = XCBConnect (NULL, NULL);
-  screen = XCBConnSetupSuccessRepRootsIter (XCBGetSetup (c)).data;
+  c = xcb_connect (NULL, NULL);
+  screen = xcb_setup_roots_iterator (xcb_get_setup (c)).data;
 
   colormap = screen-&gt;default_colormap;
 
-  return 1;
+  return 0;
 }
 </pre>
         <p>
@@ -2736,42 +2988,42 @@ main (int argc, char *argv[])
         map, with this function:
         </p>
         <pre class="code">
-XCBCOLORMAP XCBCOLORMAPNew (XCBConnection *c);
+xcb_colormap_t xcb_generate_id (xcb_connection_t *c);
 </pre>
         <p>
         Then, we create the color map with
         </p>
         <pre class="code">
-XCBVoidCookie XCBCreateColormap (XCBConnection *c,       /* Pointer to the XCBConnection structure */
-                                 BYTE           alloc,   /* Colormap entries to be allocated (AllocNone or AllocAll) */
-                                 XCBCOLORMAP    mid,     /* Id of the color map */
-                                 XCBWINDOW      window,  /* Window on whose screen the colormap will be created */
-                                 XCBVISUALID    visual); /* Id of the visual supported by the screen */
+xcb_void_cookie_t xcb_create_colormap (xcb_connection_t *c,       /* Pointer to the xcb_connection_t structure */
+                                       uint8_t           alloc,   /* Colormap entries to be allocated (AllocNone or AllocAll) */
+                                       xcb_colormap_t    mid,     /* Id of the color map */
+                                       xcb_window_t      window,  /* Window on whose screen the colormap will be created */
+                                       xcb_visualid_t    visual); /* Id of the visual supported by the screen */
 </pre>
         <p>
         Here is an example of creation of a new color map:
         </p>
         <pre class="code">
-#include &lt;X11/XCB/xcb.h&gt;
+#include &lt;xcb/xcb.h&gt;
 
 int
-main (int argc, char *argv[])
+main ()
 {
-  XCBConnection *c;
-  XCBSCREEN     *screen;
-  XCBWINDOW      win;
-  XCBCOLORMAP    cmap
-  
+  xcb_connection_t *c;
+  xcb_screen_t     *screen;
+  xcb_window_t      win;
+  xcb_colormap_t    cmap
+
   /* Open the connection to the X server and get the first screen */
-  c = XCBConnect (NULL, NULL);
-  screen = XCBConnSetupSuccessRepRootsIter (XCBGetSetup (c)).data;
+  c = xcb_connect (NULL, NULL);
+  screen = xcb_setup_roots_iterator (xcb_get_setup (c)).data;
 
   /* We create the window win here*/
 
-  cmap = XCBCOLORMAPNew (c);
-  XCBCreateColormap (c, AllocNone, cmap, win, screen-&gt;root_visual);
+  cmap = xcb_generate_id (c);
+  xcb_create_colormap (c, XCB_COLORMAP_ALLOC_NONE, cmap, win, screen-&gt;root_visual);
 
-  return 1;
+  return 0;
 }
 </pre>
         <p>
@@ -2783,8 +3035,8 @@ main (int argc, char *argv[])
         To free  a color map, it suffices to use this function:
         </p>
         <pre class="code">
-XCBVoidCookie XCBFreeColormap (XCBConnection *c,   /* The connection */
-                               XCBCOLORMAP cmap);  /* The color map */
+xcb_void_cookie_t xcb_free_colormap (xcb_connection_t *c,   /* The connection */
+                                     xcb_colormap_t cmap);  /* The color map */
 </pre>
         <div class="comp">
           <div class="title">
@@ -2797,8 +3049,8 @@ XCBVoidCookie XCBFreeColormap (XCBConnection *c,   /* The connection */
           </div>
           <div class="xcb">
             <ul>
-              <li>XCBCOLORMAPNew ()
-              <li>XCBCreateColormap ()
+              <li>xcb_generate_id ()
+              <li>xcb_create_colormap ()
             </ul>
           </div>
           <div class="xlib">
@@ -2808,7 +3060,7 @@ XCBVoidCookie XCBFreeColormap (XCBConnection *c,   /* The connection */
           </div>
           <div class="xcb">
             <ul>
-              <li>XCBFreeColormap ()
+              <li>xcb_free_colormap ()
             </ul>
           </div>
         </div>
@@ -2821,60 +3073,60 @@ XCBVoidCookie XCBFreeColormap (XCBConnection *c,   /* The connection */
         </p>
         <pre class="code">
 typedef struct {
-    BYTE response_type;
-    CARD8 pad0;
-    CARD16 sequence;
-    CARD32 length;
-    CARD16 red;          /* The red component   */
-    CARD16 green;        /* The green component */
-    CARD16 blue;         /* The blue component  */
-    CARD8 pad1[2];
-    CARD32 pixel;        /* The entry in the color map, supplied by the X server */
-} XCBAllocColorRep;
+    uint8_t  response_type;
+    uint8_t  pad0;
+    uint16_t sequence;
+    uint32_t length;
+    uint16_t red;          /* The red component   */
+    uint16_t green;        /* The green component */
+    uint16_t blue;         /* The blue component  */
+    uint8_t  pad1[2];
+    uint32_t pixel;        /* The entry in the color map, supplied by the X server */
+} xcb_alloc_color_reply_t;
 </pre>
       <p>
       XCB supplies these two functions to fill it:
       </p>
       <pre class="code">
-XCBAllocColorCookie XCBAllocColor      (XCBConnection *c,
-                                        XCBCOLORMAP    cmap,
-                                        CARD16         red,
-                                        CARD16         green,
-                                        CARD16         blue);
-XCBAllocColorRep   *XCBAllocColorReply (XCBConnection        *c,
-                                        XCBAllocColorCookie   cookie,
-                                        XCBGenericError     **e);
+xcb_alloc_color_cookie_t xcb_alloc_color       (xcb_connection_t        *c,
+                                                xcb_colormap_t           cmap,
+                                                uint16_t                 red,
+                                                uint16_t                 green,
+                                                uint16_t                 blue);
+xcb_alloc_color_reply_t *xcb_alloc_color_reply (xcb_connection_t        *c,
+                                                xcb_alloc_color_cookie_t cookie,
+                                                xcb_generic_error_t    **e);
 </pre>
       <p>
-      The fuction <span class="code">XCBAllocColor()</span> takes the
+      The fuction <span class="code">xcb_alloc_color()</span> takes the
       3 RGB components as parameters (red, green and blue). Here is an
       example of using these functions:
       </p>
       <pre class="code">
 #include &lt;malloc.h&gt;
 
-#include &lt;X11/XCB/xcb.h&gt;
+#include &lt;xcb/xcb.h&gt;
 
 int
-main (int argc, char *argv[])
+main ()
 {
-  XCBConnection    *c;
-  XCBSCREEN        *screen;
-  XCBWINDOW         win;
-  XCBCOLORMAP       cmap;
-  XCBAllocColorRep *rep;
-  
+  xcb_connection_t        *c;
+  xcb_screen_t            *screen;
+  xcb_window_t             win;
+  xcb_colormap_t           cmap;
+  xcb_alloc_color_reply_t *rep;
+
   /* Open the connection to the X server and get the first screen */
-  c = XCBConnect (NULL, NULL);
-  screen = XCBConnSetupSuccessRepRootsIter (XCBGetSetup (c)).data;
+  c = xcb_connect (NULL, NULL);
+  screen = xcb_setup_roots_iterator (xcb_get_setup (c)).data;
 
   /* We create the window win here*/
 
-  cmap = XCBCOLORMAPNew (c);
-  XCBCreateColormap (c, AllocNone, cmap, win, screen-&gt;root_visual);
+  cmap = xcb_generate_id (c);
+  xcb_create_colormap (c, XCB_COLORMAP_ALLOC_NONE, cmap, win, screen-&gt;root_visual);
+
+  rep = xcb_alloc_color_reply (c, xcb_alloc_color (c, cmap, 65535, 0, 0), NULL);
 
-  rep = XCBAllocColorReply (c, XCBAllocColor (c, cmap, 65535, 0, 0), 0);
-  
   if (!rep)
     return 0;
 
@@ -2882,11 +3134,11 @@ main (int argc, char *argv[])
 
   free (rep);
 
-  return 1;
+  return 0;
 }
 </pre>
       <p>
-      As <span class="code">XCBAllocColorReply()</span> allocates
+      As <span class="code">xcb_alloc_color_reply()</span> allocates
       memory, you have to free <span class="code">rep</span>.
       </p>
       <p>
@@ -2918,7 +3170,8 @@ main (int argc, char *argv[])
         looks like a C source file. It contains variables defining the
         width and the height of the bitmap, an array containing the
         bit values of the bitmap (the size of the array is
-        weight*height), and an optional hot-spot location (that will
+        (width+7)/8*height and the bit and byte order are LSB), and
+        an optional hot-spot location (that will
         be explained later, when discussing mouse cursors).
         </p>
         <p>
@@ -2935,24 +3188,19 @@ main (int argc, char *argv[])
         of X pixmap in XCB is an Id like a window:
         </p>
         <pre class="code">
-typedef struct {
-    CARD32 xid;
-} XCBPIXMAP;
+typedef uint32_t xcb_pixmap_t;
 </pre>
         <p>
-        In order to make the difference between a window and a pixmap,
-        XCB introduces a drawable type, which is a <b>union</b>
+        Like Xlib, there is no difference between a Drawable, a Window
+        or a Pixmap:
         </p>
         <pre class="code">
-typedef union {
-    XCBWINDOW window;
-    XCBPIXMAP pixmap;
-} XCBDRAWABLE;
+typedef uint32_t xcb_drawable_t;
 </pre>
         <p>
         in order to avoid confusion between a window and a pixmap. The
-        operations that will work indifferently on a window or a pixmap
-        will require a <span class="code">XCBDRAWABLE</span>
+        operations that will work the same on a window or a pixmap
+        will require a <span class="code">xcb_drawable_t</span>
         </p>
         <div class="emph">
         <p>
@@ -2960,7 +3208,8 @@ typedef union {
         <span class="code">Drawable</span>, a
         <span class="code">Pixmap</span> or a
         <span class="code">Window</span>: all are 32 bit long
-        integer.
+        integer.  XCB wraps all these different IDs in structures to
+        provide some measure of type-safety.
         </p>
         </div>
         <li class="subtitle"><a name="pixmapscreate">Creating a pixmap</a>
@@ -2975,25 +3224,25 @@ typedef union {
         </p>
         <p>
         To create a new pixmap, we first ask the X server to give an
-        Id to our pixmap, with this function: 
+        Id to our pixmap, with this function:
         </p>
         <pre class="code">
-XCBPIXMAP XCBPIXMAPNew (XCBConnection *c);
+xcb_pixmap_t xcb_generate_id (xcb_connection_t *c);
 </pre>
         <p>
          Then, XCB supplies the following function to create new pixmaps:
         </p>
         <pre class="code">
-XCBVoidCookie XCBCreatePixmap (XCBConnection *c,         /* Pointer to the XCBConnection structure */
-                               CARD8          depth,     /* Depth of the screen */
-                               XCBPIXMAP      pid,       /* Id of the pixmap */
-                               XCBDRAWABLE    drawable,
-                               CARD16         width,     /* Width of the window (in pixels) */
-                               CARD16         height);   /* Height of the window (in pixels) */
+xcb_void_cookie_t xcb_create_pixmap (xcb_connection_t *c,         /* Pointer to the xcb_connection_t structure */
+                                     uint8_t           depth,     /* Depth of the screen */
+                                     xcb_pixmap_t      pid,       /* Id of the pixmap */
+                                     xcb_drawable_t    drawable,
+                                     uint16_t          width,     /* Width of the window (in pixels) */
+                                     uint16_t          height);   /* Height of the window (in pixels) */
 </pre>
         <p>
         <b>TODO</b>: Explain the drawable parameter, and give an
-        example (like xpoints.c)
+        example (like <a href="xpoints.c">xpoints.c</a>)
         </p>
         <li class="subtitle"><a name="pixmapsdraw"></a>Drawing a pixmap in a window
         <p>
@@ -3001,16 +3250,16 @@ XCBVoidCookie XCBCreatePixmap (XCBConnection *c,         /* Pointer to the XCBCo
         window, using the following function:
         </p>
         <pre class="code">
-XCBVoidCookie XCBCopyArea (XCBConnection *c,             /* Pointer to the XCBConnection structure */
-                           XCBDRAWABLE    src_drawable,  /* The Drawable we want to paste */
-                           XCBDRAWABLE    dst_drawable,  /* The Drawable on which we copy the previous Drawable */
-                           XCBGCONTEXT    gc,            /* A Graphic Context */
-                           INT16          src_x,         /* Top left x coordinate of the region we want to copy */
-                           INT16          src_y,         /* Top left y coordinate of the region we want to copy */
-                           INT16          dst_x,         /* Top left x coordinate of the region where we want to copy */
-                           INT16          dst_y,         /* Top left y coordinate of the region where we want to copy */
-                           CARD16         width,         /* Width of the region we want to copy */
-                           CARD16         height);       /* Height of the region we want to copy */
+xcb_void_cookie_t xcb_copy_area (xcb_connection_t *c,             /* Pointer to the xcb_connection_t structure */
+                                 xcb_drawable_t    src_drawable,  /* The Drawable we want to paste */
+                                 xcb_drawable_t    dst_drawable,  /* The Drawable on which we copy the previous Drawable */
+                                 xcb_gcontext_t    gc,            /* A Graphic Context */
+                                 int16_t           src_x,         /* Top left x coordinate of the region we want to copy */
+                                 int16_t           src_y,         /* Top left y coordinate of the region we want to copy */
+                                 int16_t           dst_x,         /* Top left x coordinate of the region where we want to copy */
+                                 int16_t           dst_y,         /* Top left y coordinate of the region where we want to copy */
+                                 uint16_t          width,         /* Width of the region we want to copy */
+                                 uint16_t          height);       /* Height of the region we want to copy */
 </pre>
         <p>
         As you can see, we could copy the whole pixmap, as well as
@@ -3026,11 +3275,11 @@ XCBVoidCookie XCBCopyArea (XCBConnection *c,             /* Pointer to the XCBCo
         depth. If they have a different depth, the operation would
         fail. The exception to this is if we copy a specific bit plane
         of the source pixmap using the
-        <span class="code">XCBCopyPlane</span> function. In such an
-        event, we can copy a specific plain to the target window (in
+        <span class="code">xcb_copy_plane_t</span> function. In such an
+        event, we can copy a specific plane to the target window (in
         actuality, setting a specific bit in the color of each pixel
         copied). This can be used to generate strange graphic effects
-        in widow, but that is beyond the scope of this tutorial.
+        in a window, but that is beyond the scope of this tutorial.
         </p>
         <li class="subtitle"><a name="pixmapsfree"></a>Freeing a pixmap
         <p>
@@ -3039,8 +3288,8 @@ XCBVoidCookie XCBCopyArea (XCBConnection *c,             /* Pointer to the XCBCo
         using this function:
         </p>
         <pre class="code">
-XCBVoidCookie XCBFreePixmap (XCBConnection *c,        /* Pointer to the XCBConnection structure */
-                             XCBPIXMAP      pixmap);  /* A given pixmap */
+xcb_void_cookie_t xcb_free_pixmap (xcb_connection_t *c,        /* Pointer to the xcb_connection_t structure */
+                                   xcb_pixmap_t      pixmap);  /* A given pixmap */
 </pre>
         <p>
         Of course, after having freed it, we must not try accessing
@@ -3050,6 +3299,498 @@ XCBVoidCookie XCBFreePixmap (XCBConnection *c,        /* Pointer to the XCBConne
         <b>TODO</b>: Give an example, or a link to xpoints.c
         </p>
       </ol>
+      <li class="title"><a name="mousecursor">Messing with the mouse cursor</a>
+      <p>
+      It it possible to modify the shape of the mouse pointer (also
+      called the X pointer) when in certain states, as we otfen see in
+      programs. For example, a busy application would often display
+      the sand clock over its main window, to give the user a visual
+      hint that he should wait. Let's see how we can change the mouse
+      cursor of our windows.
+      </p>
+      <ol>
+        <li class="subtitle"><a name="mousecursorcreate">Creating and destroying a mouse cursor</a>
+        <p>
+        There are two methods for creating cursors. One of them is by
+        using a set of predefined cursors, that are supplied by the X
+        server, the other is by using a user-supplied bitmap.
+        </p>
+        <p>
+        In the first method, we use a special font named "cursor", and
+        the function <span class="code">xcb_create_glyph_cursor</span>:
+        </p>
+        <pre class="code">
+xcb_void_cookie_t xcb_create_glyph_cursor (xcb_connection_t *c,
+                                           xcb_cursor_t      cid,
+                                           xcb_font_t        source_font, /* font for the source glyph */
+                                           xcb_font_t        mask_font,   /* font for the mask glyph or XCB_NONE */
+                                           uint16_t          source_char, /* character glyph for the source */
+                                           uint16_t          mask_char,   /* character glyph for the mask */
+                                           uint16_t          fore_red,    /* red value for the foreground of the source */
+                                           uint16_t          fore_green,  /* green value for the foreground of the source */
+                                           uint16_t          fore_blue,   /* blue value for the foreground of the source */
+                                           uint16_t          back_red,    /* red value for the background of the source */
+                                           uint16_t          back_green,  /* green value for the background of the source */
+                                           uint16_t          back_blue)   /* blue value for the background of the source */
+</pre>
+        <p>
+        <b>TODO</b>: Describe <span class="code">source_char</span>
+        and <span class="code">mask_char</span>, for example by giving
+        an example on how to get the values. There is a list there:
+        <a href="http://tronche.com/gui/x/xlib/appendix/b/">X Font Cursors</a>
+        </p>
+        <p>
+        So we first open that font (see <a href="#loadfont">Loading a Font</a>)
+        and create the new cursor. As for every X ressource, we have to
+        ask for an X id with <span class="code">xcb_generate_id</span>
+        first:
+        </p>
+        <pre class="code">
+xcb_font_t           font;
+xcb_cursor_t         cursor;
+
+/* The connection is set */
+
+font = xcb_generate_id (conn);
+xcb_open_font (conn, font, strlen ("cursor"), "cursor");
+
+cursor = xcb_generate_id (conn);
+xcb_create_glyph_cursor (conn, cursor, font, font,
+                         58, 58 + 1,
+                         0, 0, 0,
+                         0, 0, 0);
+</pre>
+        <p>
+        We have created the cursor "right hand" by specifying 58 to
+        the <span class="code">source_fon</span>t argument and 58 + 1
+        to the <span class="code">mask_font</span>.
+        </p>
+        <p>
+        The cursor is destroyed by using the function
+        </p>
+        <pre class="code">
+xcb_void_cookie_t xcb_free_cursor (xcb_connection_t *c,
+                                   xcb_cursor_t      cursor);
+</pre>
+        <p>
+        In the second method, we create a new cursor by using a pair
+        of pixmaps, with depth of one (that is, two colors
+        pixmaps). One pixmap defines the shape of the cursor, while
+        the other works as a mask, specifying which pixels of the
+        cursor will be actually drawn. The rest of the pixels will be
+        transparent.
+        </p>
+        <p>
+        <b>TODO</b>: give an example.
+        </p>
+        <li class="subtitle"><a name="mousecursorset">Setting a window's mouse cursor</a>
+        <p>
+        Once the cursor is created, we can modify the cursor of our
+        window by using <span class="code">xcb_change_window_attributes</span>
+        and using the <span class="code">XCB_CWCURSOR</span> attribute:
+        </p>
+        <pre class="code">
+uint32_t mask;
+uint32_t value_list;
+
+/* The connection and window are set */
+/* The cursor is already created */
+
+mask = XCB_CWCURSOR;
+value_list = cursor;
+xcb_change_window_attributes (conn, window, mask, &amp;value_list);
+</pre>
+        <p>
+        Of course, the cursor and the font must be freed.
+        </p>
+        <li class="subtitle"><a name="mousecursorexample">Complete example</a>
+        <p>
+        The following example displays a window with a
+        button. When entering the window, the window cursor is changed
+        to an arrow. When clicking once on the button, the cursor is
+        changed to a hand. When clicking again on the button, the
+        cursor window gets back to the arrow. The Esc key exits the
+        application.
+        </p>
+        <pre class="code">
+#include &lt;stdlib.h&gt;
+#include &lt;stdio.h&gt;
+#include &lt;string.h&gt;
+
+#include &lt;xcb/xcb.h&gt;
+
+#define WIDTH 300
+#define HEIGHT 150
+
+
+
+static xcb_gc_t gc_font_get (xcb_connection_t *c,
+                             xcb_screen_t     *screen,
+                             xcb_window_t      window,
+                             const char       *font_name);
+
+static void button_draw (xcb_connection_t *c,
+                         xcb_screen_t     *screen,
+                         xcb_window_t      window,
+                         int16_t           x1,
+                         int16_t           y1,
+                         const char       *label);
+
+static void text_draw (xcb_connection_t *c,
+                       xcb_screen_t     *screen,
+                       xcb_window_t      window,
+                       int16_t           x1,
+                       int16_t           y1,
+                       const char       *label);
+
+static void cursor_set (xcb_connection_t *c,
+                        xcb_screen_t     *screen,
+                        xcb_window_t      window,
+                        int               cursor_id);
+
+
+static void
+button_draw (xcb_connection_t *c,
+             xcb_screen_t     *screen,
+             xcb_window_t      window,
+             int16_t           x1,
+             int16_t           y1,
+             const char       *label)
+{
+  xcb_point_t          points[5];
+  xcb_void_cookie_t    cookie_gc;
+  xcb_void_cookie_t    cookie_line;
+  xcb_void_cookie_t    cookie_text;
+  xcb_generic_error_t *error;
+  xcb_gcontext_t       gc;
+  int16_t              width;
+  int16_t              height;
+  uint8_t              length;
+  int16_t              inset;
+
+  length = strlen (label);
+  inset = 2;
+
+  gc = gc_font_get(c, screen, window, "7x13");
+
+  width = 7 * length + 2 * (inset + 1);
+  height = 13 + 2 * (inset + 1);
+  points[0].x = x1;
+  points[0].y = y1;
+  points[1].x = x1 + width;
+  points[1].y = y1;
+  points[2].x = x1 + width;
+  points[2].y = y1 - height;
+  points[3].x = x1;
+  points[3].y = y1 - height;
+  points[4].x = x1;
+  points[4].y = y1;
+  cookie_line = xcb_poly_line_checked (c, XCB_COORD_MODE_ORIGIN,
+                                       window, gc, 5, points);
+
+  error = xcb_request_check (c, cookie_line);
+  if (error) {
+    fprintf (stderr, "ERROR: can't draw lines : %d\n", error->error_code);
+    xcb_disconnect (c);
+    exit (-1);
+  }
+
+  cookie_text = xcb_image_text_8_checked (c, length, window, gc,
+                                          x1 + inset + 1,
+                                          y1 - inset - 1, label);
+  error = xcb_request_check (c, cookie_text);
+  if (error) {
+    fprintf (stderr, "ERROR: can't paste text : %d\n", error->error_code);
+    xcb_disconnect (c);
+    exit (-1);
+  }
+
+  cookie_gc = xcb_free_gc (c, gc);
+  error = xcb_request_check (c, cookie_gc);
+  if (error) {
+    fprintf (stderr, "ERROR: can't free gc : %d\n", error->error_code);
+    xcb_disconnect (c);
+    exit (-1);
+  }
+}
+
+static void
+text_draw (xcb_connection_t *c,
+           xcb_screen_t     *screen,
+           xcb_window_t      window,
+           int16_t           x1,
+           int16_t           y1,
+           const char       *label)
+{
+  xcb_void_cookie_t    cookie_gc;
+  xcb_void_cookie_t    cookie_text;
+  xcb_generic_error_t *error;
+  xcb_gcontext_t       gc;
+  uint8_t              length;
+
+  length = strlen (label);
+
+  gc = gc_font_get(c, screen, window, "7x13");
+
+  cookie_text = xcb_image_text_8_checked (c, length, window, gc,
+                                          x1,
+                                          y1, label);
+  error = xcb_request_check (c, cookie_text);
+  if (error) {
+    fprintf (stderr, "ERROR: can't paste text : %d\n", error->error_code);
+    xcb_disconnect (c);
+    exit (-1);
+  }
+
+  cookie_gc = xcb_free_gc (c, gc);
+  error = xcb_request_check (c, cookie_gc);
+  if (error) {
+    fprintf (stderr, "ERROR: can't free gc : %d\n", error->error_code);
+    xcb_disconnect (c);
+    exit (-1);
+  }
+}
+
+static xcb_gc_t
+gc_font_get (xcb_connection_t *c,
+             xcb_screen_t     *screen,
+             xcb_window_t      window,
+             const char       *font_name)
+{
+  uint32_t             value_list[3];
+  xcb_void_cookie_t    cookie_font;
+  xcb_void_cookie_t    cookie_gc;
+  xcb_generic_error_t *error;
+  xcb_font_t           font;
+  xcb_gcontext_t       gc;
+  uint32_t             mask;
+
+  font = xcb_generate_id (c);
+  cookie_font = xcb_open_font_checked (c, font,
+                                       strlen (font_name),
+                                       font_name);
+
+  error = xcb_request_check (c, cookie_font);
+  if (error) {
+    fprintf (stderr, "ERROR: can't open font : %d\n", error->error_code);
+    xcb_disconnect (c);
+    return -1;
+  }
+
+  gc = xcb_generate_id (c);
+  mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT;
+  value_list[0] = screen->black_pixel;
+  value_list[1] = screen->white_pixel;
+  value_list[2] = font;
+  cookie_gc = xcb_create_gc_checked (c, gc, window, mask, value_list);
+  error = xcb_request_check (c, cookie_gc);
+  if (error) {
+    fprintf (stderr, "ERROR: can't create gc : %d\n", error->error_code);
+    xcb_disconnect (c);
+    exit (-1);
+  }
+
+  cookie_font = xcb_close_font_checked (c, font);
+  error = xcb_request_check (c, cookie_font);
+  if (error) {
+    fprintf (stderr, "ERROR: can't close font : %d\n", error->error_code);
+    xcb_disconnect (c);
+    exit (-1);
+  }
+
+  return gc;
+}
+
+static void
+cursor_set (xcb_connection_t *c,
+            xcb_screen_t     *screen,
+            xcb_window_t      window,
+            int               cursor_id)
+{
+  uint32_t             values_list[3];
+  xcb_void_cookie_t    cookie_font;
+  xcb_void_cookie_t    cookie_gc;
+  xcb_generic_error_t *error;
+  xcb_font_t           font;
+  xcb_cursor_t         cursor;
+  xcb_gcontext_t       gc;
+  uint32_t             mask;
+  uint32_t             value_list;
+
+  font = xcb_generate_id (c);
+  cookie_font = xcb_open_font_checked (c, font,
+                                       strlen ("cursor"),
+                                       "cursor");
+  error = xcb_request_check (c, cookie_font);
+  if (error) {
+    fprintf (stderr, "ERROR: can't open font : %d\n", error->error_code);
+    xcb_disconnect (c);
+    exit (-1);
+  }
+
+  cursor = xcb_generate_id (c);
+  xcb_create_glyph_cursor (c, cursor, font, font,
+                           cursor_id, cursor_id + 1,
+                           0, 0, 0,
+                           0, 0, 0);
+
+  gc = xcb_generate_id (c);
+  mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT;
+  values_list[0] = screen->black_pixel;
+  values_list[1] = screen->white_pixel;
+  values_list[2] = font;
+  cookie_gc = xcb_create_gc_checked (c, gc, window, mask, values_list);
+  error = xcb_request_check (c, cookie_gc);
+  if (error) {
+    fprintf (stderr, "ERROR: can't create gc : %d\n", error->error_code);
+    xcb_disconnect (c);
+    exit (-1);
+  }
+
+  mask = XCB_CW_CURSOR;
+  value_list = cursor;
+  xcb_change_window_attributes (c, window, mask, &amp;value_list);
+
+  xcb_free_cursor (c, cursor);
+
+  cookie_font = xcb_close_font_checked (c, font);
+  error = xcb_request_check (c, cookie_font);
+  if (error) {
+    fprintf (stderr, "ERROR: can't close font : %d\n", error->error_code);
+    xcb_disconnect (c);
+    exit (-1);
+  }
+}
+
+int main ()
+{
+  xcb_screen_iterator_t screen_iter;
+  xcb_connection_t     *c;
+  const xcb_setup_t    *setup;
+  xcb_screen_t         *screen;
+  xcb_generic_event_t  *e;
+  xcb_generic_error_t  *error;
+  xcb_void_cookie_t     cookie_window;
+  xcb_void_cookie_t     cookie_map;
+  xcb_window_t          window;
+  uint32_t              mask;
+  uint32_t              values[2];
+  int                   screen_number;
+  uint8_t               is_hand = 0;
+
+  /* getting the connection */
+  c = xcb_connect (NULL, &amp;screen_number);
+  if (!c) {
+    fprintf (stderr, "ERROR: can't connect to an X server\n");
+    return -1;
+  }
+
+  /* getting the current screen */
+  setup = xcb_get_setup (c);
+
+  screen = NULL;
+  screen_iter = xcb_setup_roots_iterator (setup);
+  for (; screen_iter.rem != 0; --screen_number, xcb_screen_next (&amp;screen_iter))
+    if (screen_number == 0)
+      {
+        screen = screen_iter.data;
+        break;
+      }
+  if (!screen) {
+    fprintf (stderr, "ERROR: can't get the current screen\n");
+    xcb_disconnect (c);
+    return -1;
+  }
+
+  /* creating the window */
+  window = xcb_generate_id (c);
+  mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
+  values[0] = screen->white_pixel;
+  values[1] =
+    XCB_EVENT_MASK_KEY_RELEASE |
+    XCB_EVENT_MASK_BUTTON_PRESS |
+    XCB_EVENT_MASK_EXPOSURE |
+    XCB_EVENT_MASK_POINTER_MOTION;
+  cookie_window = xcb_create_window_checked (c,
+                                             screen->root_depth,
+                                             window, screen->root,
+                                             20, 200, WIDTH, HEIGHT,
+                                             0, XCB_WINDOW_CLASS_INPUT_OUTPUT,
+                                             screen->root_visual,
+                                             mask, values);
+  cookie_map = xcb_map_window_checked (c, window);
+
+  /* error managing */
+  error = xcb_request_check (c, cookie_window);
+  if (error) {
+    fprintf (stderr, "ERROR: can't create window : %d\n", error->error_code);
+    xcb_disconnect (c);
+    return -1;
+  }
+  error = xcb_request_check (c, cookie_map);
+  if (error) {
+    fprintf (stderr, "ERROR: can't map window : %d\n", error->error_code);
+    xcb_disconnect (c);
+    return -1;
+  }
+
+  cursor_set (c, screen, window, 68);
+
+  xcb_flush(c);
+
+  while (1) {
+    e = xcb_poll_for_event(c);
+    if (e) {
+      switch (e->response_type &amp; ~0x80) {
+      case XCB_EXPOSE: {
+        char *text;
+
+        text = "click here to change cursor";
+        button_draw (c, screen, window,
+                     (WIDTH - 7 * strlen(text)) / 2,
+                     (HEIGHT - 16) / 2, text);
+
+        text = "Press ESC key to exit...";
+        text_draw (c, screen, window, 10, HEIGHT - 10, text);
+        break;
+      }
+      case XCB_BUTTON_PRESS: {
+        xcb_button_press_event_t *ev;
+        int                       length;
+
+        ev = (xcb_button_press_event_t *)e;
+        length = strlen ("click here to change cursor");
+
+        if ((ev->event_x &gt;= (WIDTH - 7 * length) / 2) &amp;&amp;
+            (ev->event_x &lt;= ((WIDTH - 7 * length) / 2 + 7 * length + 6)) &amp;&amp;
+            (ev->event_y &gt;= (HEIGHT - 16) / 2 - 19) &amp;&amp;
+            (ev->event_y &lt;= ((HEIGHT - 16) / 2)))
+          is_hand = 1 - is_hand;
+
+        is_hand ? cursor_set (c, screen, window, 58) : cursor_set (c, screen, window, 68);
+      }
+      case XCB_KEY_RELEASE: {
+        xcb_key_release_event_t *ev;
+
+        ev = (xcb_key_release_event_t *)e;
+
+        switch (ev->detail) {
+          /* ESC */
+        case 9:
+          free (e);
+          xcb_disconnect (c);
+          return 0;
+        }
+      }
+      }
+      free (e);
+    }
+  }
+
+  return 0;
+}
+</pre>
+      </ol>
       <li class="title"><a name="translation">Translation of basic Xlib functions and macros</a>
       <p>
       The problem when you want to port an Xlib program to XCB is that
@@ -3060,13 +3801,15 @@ XCBVoidCookie XCBFreePixmap (XCBConnection *c,        /* Pointer to the XCBConne
       </p>
       <ol>
         <li class="subtitle"><a name="displaystructure">Members of the Display structure</a>
+        <p>
         In this section, we look at how to translate the macros that
         return some members of the <span class="code">Display</span>
         structure. They are obtained by using a function that requires a
-        <span class="code">XCBConnection *</span> or a member of the
-        <span class="code">XCBConnSetupSuccessRep</span> structure
-        (via the function <span class="code">XCBGetSetup</span>), or
+        <span class="code">xcb_connection_t *</span> or a member of the
+        <span class="code">xcb_setup_t</span> structure
+        (via the function <span class="code">xcb_get_setup</span>), or
         a function that requires that structure.
+        </p>
         <ol>
           <li class="subtitle"><a name="ConnectionNumber">ConnectionNumber</a>
           <p>
@@ -3074,27 +3817,28 @@ XCBVoidCookie XCBFreePixmap (XCBConnection *c,        /* Pointer to the XCBConne
           to the server. You just have to use that function:
           </p>
           <pre class="code">
-int XCBGetFileDescriptor(XCBConnection *c);
+int xcb_get_file_descriptor (xcb_connection_t *c);
 </pre>
           <li class="subtitle"><a name="DefaultScreen"></a>DefaultScreen
           <p>
           That number is not stored by XCB. It is returned in the
-          second parameter of the function <span class="code"><a href="#openconn">XCBConnect</a></span>.
+          second parameter of the function <span class="code"><a href="#openconn">xcb_connect</a></span>.
           Hence, you have to store it yourself if you want to use
-          it. Then, to get the <span class="code">XCBSCREEN</span>
+          it. Then, to get the <span class="code">xcb_screen_t</span>
           structure, you have to iterate on the screens.
           The equivalent function of the Xlib's
           <span class="code">ScreenOfDisplay</span> function can be
-          found <a href="#ScreenOfDisplay">below</a>. OK, here is the
+          found <a href="#ScreenOfDisplay">below</a>. This is also provided in the
+          xcb_aux_t library as <span class="code">xcb_aux_get_screen()</span>. OK, here is the
           small piece of code to get that number:
           </p>
           <pre class="code">
-XCBConnection *c;
-int            screen_default_nbr;
+xcb_connection_t *c;
+int               screen_default_nbr;
 
-/* you pass the name of the display you want to XCBConnect */
+/* you pass the name of the display you want to xcb_connect_t */
 
-c = XCBConnect (display_name, &amp;screen_default_nbr);
+c = xcb_connect (display_name, &amp;screen_default_nbr);
 
 /* screen_default_nbr contains now the number of the default screen */
 </pre>
@@ -3102,59 +3846,66 @@ c = XCBConnect (display_name, &amp;screen_default_nbr);
           <p>
           Not documented yet.
           </p>
+          <p>
+          However, this points out a basic difference in philosophy between
+          Xlib and XCB.  Xlib has several functions for filtering and
+          manipulating the incoming and outgoing X message queues.  XCB
+          wishes to hide this as much as possible from the user, which
+          allows for more freedom in implementation strategies.
+          </p>
           <li class="subtitle"><a name="ScreenCount"></a>ScreenCount
           <p>
           You get the count of screens with the functions
-          <span class="code">XCBGetSetup</span>
+          <span class="code">xcb_get_setup</span>
           and
-          <span class="code">XCBConnSetupSuccessRepRootsIter</span>
+          <span class="code">xcb_setup_roots_iterator</span>
           (if you need to iterate):
           </p>
           <pre class="code">
-XCBConnection *c;
-int            screen_count;
+xcb_connection_t *c;
+int               screen_count;
 
 /* you init the connection */
 
-screen_count = XCBConnSetupSuccessRepRootsIter (XCBGetSetup (c)).rem;
+screen_count = xcb_setup_roots_iterator (xcb_get_setup (c)).rem;
 
 /* screen_count contains now the count of screens */
 </pre>
           <p>
           If you don't want to iterate over the screens, a better way
           to get that number is to use
-          <span class="code">XCBConnSetupSuccessRepRootsLength</span>:
+          <span class="code">xcb_setup_roots_length_t</span>:
           </p>
           <pre class="code">
-XCBConnection *c;
-int            screen_count;
+xcb_connection_t *c;
+int               screen_count;
 
 /* you init the connection */
 
-screen_count = XCBConnSetupSuccessRepRootsLength (XCBGetSetup (c));
+screen_count = xcb_setup_roots_length (xcb_get_setup (c));
 
 /* screen_count contains now the count of screens */
 </pre>
           <li class="subtitle"><a name="ServerVendor"></a>ServerVendor
           <p>
           You get the name of the vendor of the server hardware with
-          the functions <span class="code">XCBGetSetup</span>
+          the functions <span class="code">xcb_get_setup</span>
           and
           <span
-          class="code">XCBConnSetupSuccessRepVendor</span>. Beware
+          class="code">xcb_setup_vendor</span>. Beware
           that, unlike Xlib, the string returned by XCB is not
           necessarily null-terminaled:
           </p>
           <pre class="code">
-XCBConnection *c;
-char          *vendor = NULL;
-int            length;
+xcb_connection_t *c;
+char             *vendor = NULL;
+int               length;
 
 /* you init the connection */
-length = XCBConnSetupSuccessRepVendorLength (XCBGetSetup (c));
+length = xcb_setup_vendor_length (xcb_get_setup (c));
 vendor = (char *)malloc (length + 1);
 if (vendor)
-memcpy (vendor, XCBConnSetupSuccessRepVendor (XCBGetSetup (c)), length);
+memcpy (vendor, xcb_setup_vendor (xcb_get_setup (c)), length);
 vendor[length] = '\0';
 
 /* vendor contains now the name of the vendor. Must be freed when not used anymore */
@@ -3162,48 +3913,48 @@ vendor[length] = '\0';
           <li class="subtitle"><a name="ProtocolVersion"></a>ProtocolVersion
           <p>
           You get the major version of the protocol in the
-          <span class="code">XCBConnSetupSuccessRep</span>
-          structure, with the function <span class="code">XCBGetSetup</span>:
+          <span class="code">xcb_setup_t</span>
+          structure, with the function <span class="code">xcb_get_setup</span>:
           </p>
           <pre class="code">
-XCBConnection *c;
-CARD16         protocol_major_version;
+xcb_connection_t *c;
+uint16_t          protocol_major_version;
 
 /* you init the connection */
 
-protocol_major_version = XCBGetSetup (c)-&gt;protocol_major_version;
+protocol_major_version = xcb_get_setup (c)-&gt;protocol_major_version;
 
 /* protocol_major_version contains now the major version of the protocol */
 </pre>
           <li class="subtitle"><a name="ProtocolRevision"></a>ProtocolRevision
           <p>
           You get the minor version of the protocol in the
-          <span class="code">XCBConnSetupSuccessRep</span>
-          structure, with the function <span class="code">XCBGetSetup</span>:
+          <span class="code">xcb_setup_t</span>
+          structure, with the function <span class="code">xcb_get_setup</span>:
           </p>
           <pre class="code">
-XCBConnection *c;
-CARD16         protocol_minor_version;
+xcb_connection_t *c;
+uint16_t          protocol_minor_version;
 
 /* you init the connection */
 
-protocol_minor_version = XCBGetSetup (c)-&gt;protocol_minor_version;
+protocol_minor_version = xcb_get_setup (c)-&gt;protocol_minor_version;
 
 /* protocol_minor_version contains now the minor version of the protocol */
 </pre>
           <li class="subtitle"><a name="VendorRelease"></a>VendorRelease
           <p>
           You get the number of the release of the server hardware in the
-          <span class="code">XCBConnSetupSuccessRep</span>
-          structure, with the function <span class="code">XCBGetSetup</span>:
+          <span class="code">xcb_setup_t</span>
+          structure, with the function <span class="code">xcb_get_setup</span>:
           </p>
           <pre class="code">
-XCBConnection *c;
-CARD32         release_number;
+xcb_connection_t *c;
+uint32_t          release_number;
 
 /* you init the connection */
 
-release_number = XCBGetSetup (c)-&gt;release_number;
+release_number = xcb_get_setup (c)-&gt;release_number;
 
 /* release_number contains now the number of the release of the server hardware */
 </pre>
@@ -3215,64 +3966,64 @@ release_number = XCBGetSetup (c)-&gt;release_number;
           <li class="subtitle"><a name="BitmapUnit"></a>BitmapUnit
           <p>
           You get the bitmap scanline unit in the
-          <span class="code">XCBConnSetupSuccessRep</span>
-          structure, with the function <span class="code">XCBGetSetup</span>:
+          <span class="code">xcb_setup_t</span>
+          structure, with the function <span class="code">xcb_get_setup</span>:
           </p>
           <pre class="code">
-XCBConnection *c;
-CARD8          bitmap_format_scanline_unit;
+xcb_connection_t *c;
+uint8_t           bitmap_format_scanline_unit;
 
 /* you init the connection */
 
-bitmap_format_scanline_unit = XCBGetSetup (c)-&gt;bitmap_format_scanline_unit;
+bitmap_format_scanline_unit = xcb_get_setup (c)-&gt;bitmap_format_scanline_unit;
 
 /* bitmap_format_scanline_unit contains now the bitmap scanline unit */
 </pre>
           <li class="subtitle"><a name="BitmapBitOrder"></a>BitmapBitOrder
           <p>
           You get the bitmap bit order in the
-          <span class="code">XCBConnSetupSuccessRep</span>
-          structure, with the function <span class="code">XCBGetSetup</span>:
+          <span class="code">xcb_setup_t</span>
+          structure, with the function <span class="code">xcb_get_setup</span>:
           </p>
           <pre class="code">
-XCBConnection *c;
-CARD8          bitmap_format_bit_order;
+xcb_connection_t *c;
+uint8_t           bitmap_format_bit_order;
 
 /* you init the connection */
 
-bitmap_format_bit_order = XCBGetSetup (c)-&gt;bitmap_format_bit_order;
+bitmap_format_bit_order = xcb_get_setup (c)-&gt;bitmap_format_bit_order;
 
 /* bitmap_format_bit_order contains now the bitmap bit order */
 </pre>
           <li class="subtitle"><a name="BitmapPad"></a>BitmapPad
           <p>
           You get the bitmap scanline pad in the
-          <span class="code">XCBConnSetupSuccessRep</span>
-          structure, with the function <span class="code">XCBGetSetup</span>:
+          <span class="code">xcb_setup_t</span>
+          structure, with the function <span class="code">xcb_get_setup</span>:
           </p>
           <pre class="code">
-XCBConnection *c;
-CARD8          bitmap_format_scanline_pad;
+xcb_connection_t *c;
+uint8_t           bitmap_format_scanline_pad;
 
 /* you init the connection */
 
-bitmap_format_scanline_pad = XCBGetSetup (c)-&gt;bitmap_format_scanline_pad;
+bitmap_format_scanline_pad = xcb_get_setup (c)-&gt;bitmap_format_scanline_pad;
 
 /* bitmap_format_scanline_pad contains now the bitmap scanline pad */
 </pre>
           <li class="subtitle"><a name="ImageByteOrder"></a>ImageByteOrder
           <p>
           You get the image byte order in the
-          <span class="code">XCBConnSetupSuccessRep</span>
-          structure, with the function <span class="code">XCBGetSetup</span>:
+          <span class="code">xcb_setup_t</span>
+          structure, with the function <span class="code">xcb_get_setup</span>:
           </p>
           <pre class="code">
-XCBConnection *c;
-CARD8          image_byte_order;
+xcb_connection_t *c;
+uint8_t           image_byte_order;
 
 /* you init the connection */
 
-image_byte_order = XCBGetSetup (c)-&gt;image_byte_order;
+image_byte_order = xcb_get_setup (c)-&gt;image_byte_order;
 
 /* image_byte_order contains now the image byte order */
 </pre>
@@ -3282,13 +4033,13 @@ image_byte_order = XCBGetSetup (c)-&gt;image_byte_order;
       in Xlib, <span class="code">ScreenOfDisplay</span> returns a
       <span class="code">Screen</span> structure that contains
       several characteristics of your screen. XCB has a similar
-      structure (<span class="code">XCBSCREEN</span>),
+      structure (<span class="code">xcb_screen_t</span>),
       but the way to obtain it is a bit different. With
       Xlib, you just provide the number of the screen and you grab it
       from an array. With XCB, you iterate over all the screens to
       obtain the one you want. The complexity of this operation is
       O(n). So the best is to store this structure if you use
-      it often. See <a href="#ScreenOfDisplay">ScreenOfDisplay</a> just below.
+      it often. See <a href="#ScreenOfDisplay">screen_of_display</a> just below.
       </p>
       <p>
       Xlib provides generally two functions to obtain the characteristics
@@ -3296,7 +4047,7 @@ image_byte_order = XCBGetSetup (c)-&gt;image_byte_order;
       the screen, which calls <span class="code">ScreenOfDisplay</span>,
       and the other that uses the <span class="code">Screen</span> structure.
       This might be a bit confusing. As mentioned above, with XCB, it
-      is better to store the <span class="code">XCBSCREEN</span>
+      is better to store the <span class="code">xcb_screen_t</span>
       structure. Then, you have to read the members of this
       structure. That's why the Xlib functions are put by pairs (or
       more) as, with XCB, you will use the same code.
@@ -3309,13 +4060,13 @@ image_byte_order = XCBGetSetup (c)-&gt;image_byte_order;
           once you get the one you want, you return it:
           </p>
           <pre class="code"><a name="ScreenOfDisplay"></a>
-XCBSCREEN *ScreenOfDisplay (XCBConnection *c,
-                            int            screen)
+xcb_screen_t *screen_of_display (xcb_connection_t *c,
+                                 int               screen)
 {
-  XCBSCREENIter iter;
+  xcb_screen_iterator_t iter;
 
-  iter = XCBConnSetupSuccessRepRootsIter (XCBGetSetup (c));
-  for (; iter.rem; --screen, XCBSCREENNext (&amp;iter))
+  iter = xcb_setup_roots_iterator (xcb_get_setup (c));
+  for (; iter.rem; --screen, xcb_screen_next (&amp;iter))
     if (screen == 0)
       return iter.data;
 
@@ -3329,39 +4080,38 @@ XCBSCREEN *ScreenOfDisplay (XCBConnection *c,
           <p>
           All the functions below will use the result of that
           function, as they just grab a specific member of the
-          <span class="code">XCBSCREEN</span> structure.
+          <span class="code">xcb_screen_t</span> structure.
           </p>
           <li class="subtitle"><a name="DefaultScreenOfDisplay"></a>DefaultScreenOfDisplay
           <p>
           It is the default screen that you obtain when you connect to
-          the X server. It suffices to call the <a href="#ScreenOfDisplay">ScreenOfDisplay</a>
+          the X server. It suffices to call the <a href="#ScreenOfDisplay">screen_of_display</a>
           function above with the connection and the number of the
           default screen.
           </p>
           <pre class="code">
-XCBConnection *c;
-int            screen_default_nbr;
-XCBSCREEN     *default_screen;  /* the returned default screen */
+xcb_connection_t *c;
+int               screen_default_nbr;
+xcb_screen_t     *default_screen;  /* the returned default screen */
 
-/* you pass the name of the display you want to XCBConnect */
+/* you pass the name of the display you want to xcb_connect_t */
 
-c = XCBConnect (display_name, &amp;screen_default_nbr);
-default_screen = ScreenOfDisplay (c, screen_default_nbr);
+c = xcb_connect (display_name, &amp;screen_default_nbr);
+default_screen = screen_of_display (c, screen_default_nbr);
 
 /* default_screen contains now the default root window, or a NULL window if no screen is found */
 </pre>
           <li class="subtitle"><a name="RootWindow">RootWindow / RootWindowOfScreen</a>
-          <p>
-          </p>
+          <br>
           <pre class="code">
-XCBConnection *c;
-XCBSCREEN     *screen;
-int            screen_nbr;
-XCBWINDOW      root_window = { 0 };  /* the returned window */
+xcb_connection_t *c;
+xcb_screen_t     *screen;
+int               screen_nbr;
+xcb_window_t      root_window = { 0 };  /* the returned window */
 
 /* you init the connection and screen_nbr */
 
-screen = ScreenOfDisplay (c, screen_nbr);
+screen = screen_of_display (c, screen_nbr);
 if (screen)
   root_window = screen-&gt;root;
 
@@ -3375,15 +4125,15 @@ if (screen)
           <a href="#RootWindow">root window</a> as above:
           </p>
           <pre class="code">
-XCBConnection *c;
-XCBSCREEN     *screen;
-int            screen_default_nbr;
-XCBWINDOW      root_window = { 0 };  /* the returned root window */
+xcb_connection_t *c;
+xcb_screen_t     *screen;
+int               screen_default_nbr;
+xcb_window_t      root_window = { 0 };  /* the returned root window */
 
-/* you pass the name of the display you want to XCBConnect */
+/* you pass the name of the display you want to xcb_connect_t */
 
-c = XCBConnect (display_name, &amp;screen_default_nbr);
-screen = ScreenOfDisplay (c, screen_default_nbr);
+c = xcb_connect (display_name, &amp;screen_default_nbr);
+screen = screen_of_display (c, screen_default_nbr);
 if (screen)
   root_window = screen-&gt;root;
 
@@ -3392,67 +4142,63 @@ if (screen)
           <li class="subtitle"><a name="DefaultVisual">DefaultVisual / DefaultVisualOfScreen</a>
           <p>
           While a Visual is, in Xlib, a structure, in XCB, there are
-          two types: <span class="code">XCBVISUALID</span>, which is
-          the Id of the visual, and <span class="code">XCBVISUALTYPE</span>,
+          two types: <span class="code">xcb_visualid_t</span>, which is
+          the Id of the visual, and <span class="code">xcb_visualtype_t</span>,
           which corresponds to the Xlib Visual. To get the Id of the
           visual of a screen, just get the
            <span class="code">root_visual</span>
-           member of a <span class="code">XCBSCREEN</span>:
+           member of a <span class="code">xcb_screen_t</span>:
           </p>
           <pre class="code">
-XCBConnection *c;
-XCBSCREEN     *screen;
-int            screen_nbr;
-XCBVISUALID    root_visual = { 0 };    /* the returned visual Id */
+xcb_connection_t *c;
+xcb_screen_t     *screen;
+int               screen_nbr;
+xcb_visualid_t    root_visual = { 0 };    /* the returned visual Id */
 
 /* you init the connection and screen_nbr */
 
-screen = ScreenOfDisplay (c, screen_nbr);
+screen = screen_of_display (c, screen_nbr);
 if (screen)
   root_visual = screen-&gt;root_visual;
 
 /* root_visual contains now the value of the Id of the visual, or a NULL visual if no screen is found */
 </pre>
           <p>
-          To get the <span class="code">XCBVISUALTYPE</span>
+          To get the <span class="code">xcb_visualtype_t</span>
           structure, it's a bit less easy. You have to get the
-          <span class="code">XCBSCREEN</span> structure that you want,
+          <span class="code">xcb_screen_t</span> structure that you want,
           get its <span class="code">root_visual</span> member,
-          then iterate over the <span class="code">XCBDEPTH</span>s
-          and the <span class="code">XCBVISUALTYPE</span>s, and compare
-          the <span class="code">XCBVISUALID</span> of these <span class="code">XCBVISUALTYPE</span>s:
+          then iterate over the <span class="code">xcb_depth_t</span>s
+          and the <span class="code">xcb_visualtype_t</span>s, and compare
+          the <span class="code">xcb_visualid_t</span> of these <span class="code">xcb_visualtype_t</span>s:
           with <span class="code">root_visual</span>:
           </p>
           <pre class="code">
-XCBConnection *c;
-XCBSCREEN     *screen;
-int            screen_nbr;
-XCBVISUALID    root_visual = { 0 };
-XCBVISUATYPE  *visual_type = NULL;    /* the returned visual type */
+xcb_connection_t *c;
+xcb_screen_t     *screen;
+int               screen_nbr;
+xcb_visualid_t    root_visual = { 0 };
+xcb_visualtype_t  *visual_type = NULL;    /* the returned visual type */
 
 /* you init the connection and screen_nbr */
 
-screen = ScreenOfDisplay (c, screen_nbr);
-if (screen)
-  {
-    XCBDEPTHIter depth_iter;
+screen = screen_of_display (c, screen_nbr);
+if (screen) {
+  xcb_depth_iterator_t depth_iter;
 
-    depth_iter = XCBSCREENAllowedDepthsIter (screen);
-    for (; depth_iter.rem; XCBDEPTHNext (&amp;depth_iter))
-      {
-        XCBVISUALTYPEIter visual_iter;
-
-        visual_iter = XCBDEPTHVisualsIter (depth_iter.data);
-        for (; visual_iter.rem; XCBVISUALTYPENext (&amp;visual_iter))
-          {
-            if (screen-&gt;root_visual.id == visual_iter.data-&gt;visual_id.id)
-              {
-                visual_type = visual_iter.data;
-                break;
-              }
-          }
+  depth_iter = xcb_screen_allowed_depths_iterator (screen);
+  for (; depth_iter.rem; xcb_depth_next (&amp;depth_iter)) {
+    xcb_visualtype_iterator_t visual_iter;
+
+    visual_iter = xcb_depth_visuals_iterator (depth_iter.data);
+    for (; visual_iter.rem; xcb_visualtype_next (&amp;visual_iter)) {
+      if (screen-&gt;root_visual == visual_iter.data-&gt;visual_id) {
+        visual_type = visual_iter.data;
+        break;
       }
+    }
   }
+}
 
 /* visual_type contains now the visual structure, or a NULL visual structure if no screen is found */
 </pre>
@@ -3460,48 +4206,47 @@ if (screen)
           <p>
           This default Graphic Context is just a newly created Graphic
           Context, associated to the root window of a
-          <span class="code">XCBSCREEN</span>,
+          <span class="code">xcb_screen_t</span>,
           using the black white pixels of that screen:
           </p>
           <pre class="code">
-XCBConnection *c;
-XCBSCREEN     *screen;
-int            screen_nbr;
-XCBGCONTEXT    gc = { 0 };    /* the returned default graphic context */
+xcb_connection_t *c;
+xcb_screen_t     *screen;
+int               screen_nbr;
+xcb_gcontext_t    gc = { 0 };    /* the returned default graphic context */
 
 /* you init the connection and screen_nbr */
 
-screen = ScreenOfDisplay (c, screen_nbr);
-if (screen)
-  {
-    XCBDRAWABLE draw;
-    CARD32      mask;
-    CARD32      values[2];
-
-    gc = XCBGCONTEXTNew (c);
-    draw.window = screen-&gt;root;
-    mask = GCForeground | GCBackground;
-    values[0] = screen-&gt;black_pixel;
-    values[1] = screen-&gt;white_pixel;
-    XCBCreateGC (c, gc, draw, mask, values);
-  }
+screen = screen_of_display (c, screen_nbr);
+if (screen) {
+  xcb_drawable_t draw;
+  uint32_t       mask;
+  uint32_t       values[2];
+
+  gc = xcb_generate_id (c);
+  draw = screen-&gt;root;
+  mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND;
+  values[0] = screen-&gt;black_pixel;
+  values[1] = screen-&gt;white_pixel;
+  xcb_create_gc (c, gc, draw, mask, values);
+}
 
 /* gc contains now the default graphic context */
 </pre>
           <li class="subtitle"><a name="BlackPixel">BlackPixel / BlackPixelOfScreen</a>
           <p>
           It is the Id of the black pixel, which is in the structure
-          of an <span class="code">XCBSCREEN</span>.
+          of an <span class="code">xcb_screen_t</span>.
           </p>
           <pre class="code">
-XCBConnection *c;
-XCBSCREEN     *screen;
-int            screen_nbr;
-CARD32         black_pixel = 0;    /* the returned black pixel */
+xcb_connection_t *c;
+xcb_screen_t     *screen;
+int               screen_nbr;
+uint32_t          black_pixel = 0;    /* the returned black pixel */
 
 /* you init the connection and screen_nbr */
 
-screen = ScreenOfDisplay (c, screen_nbr);
+screen = screen_of_display (c, screen_nbr);
 if (screen)
   black_pixel = screen-&gt;black_pixel;
 
@@ -3510,17 +4255,17 @@ if (screen)
           <li class="subtitle"><a name="WhitePixel">WhitePixel / WhitePixelOfScreen</a>
           <p>
           It is the Id of the white pixel, which is in the structure
-          of an <span class="code">XCBSCREEN</span>.
+          of an <span class="code">xcb_screen_t</span>.
           </p>
           <pre class="code">
-XCBConnection *c;
-XCBSCREEN     *screen;
-int            screen_nbr;
-CARD32         white_pixel = 0;    /* the returned white pixel */
+xcb_connection_t *c;
+xcb_screen_t     *screen;
+int               screen_nbr;
+uint32_t          white_pixel = 0;    /* the returned white pixel */
 
 /* you init the connection and screen_nbr */
 
-screen = ScreenOfDisplay (c, screen_nbr);
+screen = screen_of_display (c, screen_nbr);
 if (screen)
   white_pixel = screen-&gt;white_pixel;
 
@@ -3530,17 +4275,17 @@ if (screen)
           <p>
           It is the width in pixels of the screen that you want, and
           which is in the structure of the corresponding
-          <span class="code">XCBSCREEN</span>.
+          <span class="code">xcb_screen_t</span>.
           </p>
           <pre class="code">
-XCBConnection *c;
-XCBSCREEN     *screen;
-int            screen_nbr;
-CARD32         width_in_pixels = 0;    /* the returned width in pixels */
+xcb_connection_t *c;
+xcb_screen_t     *screen;
+int               screen_nbr;
+uint32_t          width_in_pixels = 0;    /* the returned width in pixels */
 
 /* you init the connection and screen_nbr */
 
-screen = ScreenOfDisplay (c, screen_nbr);
+screen = screen_of_display (c, screen_nbr);
 if (screen)
   width_in_pixels = screen-&gt;width_in_pixels;
 
@@ -3550,17 +4295,17 @@ if (screen)
           <p>
           It is the height in pixels of the screen that you want, and
           which is in the structure of the corresponding
-          <span class="code">XCBSCREEN</span>.
+          <span class="code">xcb_screen_t</span>.
           </p>
           <pre class="code">
-XCBConnection *c;
-XCBSCREEN     *screen;
-int            screen_nbr;
-CARD32         height_in_pixels = 0;    /* the returned height in pixels */
+xcb_connection_t *c;
+xcb_screen_t     *screen;
+int               screen_nbr;
+uint32_t          height_in_pixels = 0;    /* the returned height in pixels */
 
 /* you init the connection and screen_nbr */
 
-screen = ScreenOfDisplay (c, screen_nbr);
+screen = screen_of_display (c, screen_nbr);
 if (screen)
   height_in_pixels = screen-&gt;height_in_pixels;
 
@@ -3570,17 +4315,17 @@ if (screen)
           <p>
           It is the width in millimeters of the screen that you want, and
           which is in the structure of the corresponding
-          <span class="code">XCBSCREEN</span>.
+          <span class="code">xcb_screen_t</span>.
           </p>
           <pre class="code">
-XCBConnection *c;
-XCBSCREEN     *screen;
-int            screen_nbr;
-CARD32         width_in_millimeters = 0;    /* the returned width in millimeters */
+xcb_connection_t *c;
+xcb_screen_t     *screen;
+int               screen_nbr;
+uint32_t          width_in_millimeters = 0;    /* the returned width in millimeters */
 
 /* you init the connection and screen_nbr */
 
-screen = ScreenOfDisplay (c, screen_nbr);
+screen = screen_of_display (c, screen_nbr);
 if (screen)
   width_in_millimeters = screen-&gt;width_in_millimeters;
 
@@ -3590,17 +4335,17 @@ if (screen)
           <p>
           It is the height in millimeters of the screen that you want, and
           which is in the structure of the corresponding
-          <span class="code">XCBSCREEN</span>.
+          <span class="code">xcb_screen_t</span>.
           </p>
           <pre class="code">
-XCBConnection *c;
-XCBSCREEN     *screen;
-int            screen_nbr;
-CARD32         height_in_millimeters = 0;    /* the returned height in millimeters */
+xcb_connection_t *c;
+xcb_screen_t     *screen;
+int               screen_nbr;
+uint32_t          height_in_millimeters = 0;    /* the returned height in millimeters */
 
 /* you init the connection and screen_nbr */
 
-screen = ScreenOfDisplay (c, screen_nbr);
+screen = screen_of_display (c, screen_nbr);
 if (screen)
   height_in_millimeters = screen-&gt;height_in_millimeters;
 
@@ -3609,17 +4354,17 @@ if (screen)
           <li class="subtitle"><a name="DisplayPlanes">DisplayPlanes / DefaultDepth / DefaultDepthOfScreen / PlanesOfScreen</a>
           <p>
           It is the depth (in bits) of the root window of the
-          screen. You get it from the <span class="code">XCBSCREEN</span> structure.
+          screen. You get it from the <span class="code">xcb_screen_t</span> structure.
           </p>
           <pre class="code">
-XCBConnection *c;
-XCBSCREEN     *screen;
-int            screen_nbr;
-CARD8          root_depth = 0;  /* the returned depth of the root window */
+xcb_connection_t *c;
+xcb_screen_t     *screen;
+int               screen_nbr;
+uint8_t           root_depth = 0;  /* the returned depth of the root window */
 
 /* you init the connection and screen_nbr */
 
-screen = ScreenOfDisplay (c, screen_nbr);
+screen = screen_of_display (c, screen_nbr);
 if (screen)
   root_depth = screen-&gt;root_depth;
 
@@ -3629,17 +4374,17 @@ if (screen)
           <p>
           This is the default colormap of the screen (and not the
           (default) colormap of the default screen !). As usual, you
-          get it from the <span class="code">XCBSCREEN</span> structure:
+          get it from the <span class="code">xcb_screen_t</span> structure:
           </p>
           <pre class="code">
-XCBConnection *c;
-XCBSCREEN     *screen;
-int            screen_nbr;
-XCBCOLORMAP    default_colormap = { 0 };  /* the returned default colormap */
+xcb_connection_t *c;
+xcb_screen_t     *screen;
+int               screen_nbr;
+xcb_colormap_t    default_colormap = { 0 };  /* the returned default colormap */
 
 /* you init the connection and screen_nbr */
 
-screen = ScreenOfDisplay (c, screen_nbr);
+screen = screen_of_display (c, screen_nbr);
 if (screen)
   default_colormap = screen-&gt;default_colormap;
 
@@ -3647,17 +4392,17 @@ if (screen)
 </pre>
           <li class="subtitle"><a name="MinCmapsOfScreen"></a>MinCmapsOfScreen
           <p>
-          You get the minimum installed colormaps in the <span class="code">XCBSCREEN</span> structure:
+          You get the minimum installed colormaps in the <span class="code">xcb_screen_t</span> structure:
           </p>
           <pre class="code">
-XCBConnection *c;
-XCBSCREEN     *screen;
-int            screen_nbr;
-CARD16         min_installed_maps = 0;  /* the returned minimum installed colormaps */
+xcb_connection_t *c;
+xcb_screen_t     *screen;
+int               screen_nbr;
+uint16_t          min_installed_maps = 0;  /* the returned minimum installed colormaps */
 
 /* you init the connection and screen_nbr */
 
-screen = ScreenOfDisplay (c, screen_nbr);
+screen = screen_of_display (c, screen_nbr);
 if (screen)
   min_installed_maps = screen-&gt;min_installed_maps;
 
@@ -3665,17 +4410,17 @@ if (screen)
 </pre>
           <li class="subtitle"><a name="MaxCmapsOfScreen"></a>MaxCmapsOfScreen
           <p>
-          You get the maximum installed colormaps in the <span class="code">XCBSCREEN</span> structure:
+          You get the maximum installed colormaps in the <span class="code">xcb_screen_t</span> structure:
           </p>
           <pre class="code">
-XCBConnection *c;
-XCBSCREEN     *screen;
-int            screen_nbr;
-CARD16         max_installed_maps = 0;  /* the returned maximum installed colormaps */
+xcb_connection_t *c;
+xcb_screen_t     *screen;
+int               screen_nbr;
+uint16_t          max_installed_maps = 0;  /* the returned maximum installed colormaps */
 
 /* you init the connection and screen_nbr */
 
-screen = ScreenOfDisplay (c, screen_nbr);
+screen = screen_of_display (c, screen_nbr);
 if (screen)
   max_installed_maps = screen-&gt;max_installed_maps;
 
@@ -3684,17 +4429,17 @@ if (screen)
           <li class="subtitle"><a name="DoesSaveUnders"></a>DoesSaveUnders
           <p>
           You know if <span class="code">save_unders</span> is set,
-          by looking in the <span class="code">XCBSCREEN</span> structure:
+          by looking in the <span class="code">xcb_screen_t</span> structure:
           </p>
           <pre class="code">
-XCBConnection *c;
-XCBSCREEN     *screen;
-int            screen_nbr;
-BOOL           save_unders = 0;  /* the returned value of save_unders */
+xcb_connection_t *c;
+xcb_screen_t     *screen;
+int               screen_nbr;
+uint8_t           save_unders = 0;  /* the returned value of save_unders */
 
 /* you init the connection and screen_nbr */
 
-screen = ScreenOfDisplay (c, screen_nbr);
+screen = screen_of_display (c, screen_nbr);
 if (screen)
   save_unders = screen-&gt;save_unders;
 
@@ -3703,17 +4448,17 @@ if (screen)
           <li class="subtitle"><a name="DoesBackingStore"></a>DoesBackingStore
           <p>
           You know the value of <span class="code">backing_stores</span>,
-          by looking in the <span class="code">XCBSCREEN</span> structure:
+          by looking in the <span class="code">xcb_screen_t</span> structure:
           </p>
           <pre class="code">
-XCBConnection *c;
-XCBSCREEN     *screen;
-int            screen_nbr;
-BYTE           backing_stores = 0;  /* the returned value of backing_stores */
+xcb_connection_t *c;
+xcb_screen_t     *screen;
+int               screen_nbr;
+uint8_t           backing_stores = 0;  /* the returned value of backing_stores */
 
 /* you init the connection and screen_nbr */
 
-screen = ScreenOfDisplay (c, screen_nbr);
+screen = screen_of_display (c, screen_nbr);
 if (screen)
   backing_stores = screen-&gt;backing_stores;
 
@@ -3722,17 +4467,17 @@ if (screen)
           <li class="subtitle"><a name="EventMaskOfScreen"></a>EventMaskOfScreen
           <p>
           To get the current input masks,
-          you look in the <span class="code">XCBSCREEN</span> structure:
+          you look in the <span class="code">xcb_screen_t</span> structure:
           </p>
           <pre class="code">
-XCBConnection *c;
-XCBSCREEN     *screen;
-int            screen_nbr;
-CARD32         current_input_masks = 0;  /* the returned value of current input masks */
+xcb_connection_t *c;
+xcb_screen_t     *screen;
+int               screen_nbr;
+uint32_t          current_input_masks = 0;  /* the returned value of current input masks */
 
 /* you init the connection and screen_nbr */
 
-screen = ScreenOfDisplay (c, screen_nbr);
+screen = screen_of_display (c, screen_nbr);
 if (screen)
   current_input_masks = screen-&gt;current_input_masks;
 
@@ -3742,7 +4487,7 @@ if (screen)
       <li class="subtitle"><a name="misc">Miscellaneous macros</a>
         <ol>
           <li class="subtitle"><a name="DisplayOfScreen"></a>DisplayOfScreen
-          <p> 
+          <p>
           in Xlib, the <span class="code">Screen</span> structure
           stores its associated <span class="code">Display</span>
           structure. This is not the case in the X Window protocol,
@@ -3752,13 +4497,13 @@ if (screen)
           <li class="subtitle"><a name="DisplayCells"></a>DisplayCells / CellsOfScreen
           <p>
           To get the colormap entries,
-          you look in the <span class="code">XCBVISUALTYPE</span>
+          you look in the <span class="code">xcb_visualtype_t</span>
           structure, that you grab like <a class="subsection" href="#DefaultVisual">here</a>:
           </p>
           <pre class="code">
-XCBConnection *c;
-XCBVISUALTYPE *visual_type;
-CARD16         colormap_entries = 0;  /* the returned value of the colormap entries */
+xcb_connection_t *c;
+xcb_visualtype_t *visual_type;
+uint16_t          colormap_entries = 0;  /* the returned value of the colormap entries */
 
 /* you init the connection and visual_type */