The X.Org (www.x.org) document
X Window System Protocol
describes in detail how the X Window System protocol works. It also includes detailed descriptions of the core protocol messages.
The document is the size of a book and includes an index in a separate
The X.Org document
X11 Nonrectangular Window Shape Extension describes how the Shape extension works, the new protocol requests added by the
extension, and the C language bindings needed by a client program to make use of the Shape extension.
Another web site for getting X Window System documents is http://www.x-docs.org. A list of
documents in PDF format is nicely organized on a web page.