GDI MODULE
==========
-...
+1. X Windows System interface
+-----------------------------
+
+The X libraries used to implement X clients (such as Wine) do not work
+properly if multiple threads access the same display concurrently. It is
+possible to compile the X libraries to perform their own synchronization
+(initiated by calling XInitThreads()). However, Wine does not use this
+approach. Instead Wine performs its own synchronization py putting a
+wrapper around every X call that is used. This wrapper protects library
+access with a critical section, and also arranges things so that X
+libraries compiled without -D_REENTRANT (eg. with global errno variable)
+will work with Wine.
+
+To make this scheme work, all calls to X must use the proper wrapper
+functions (or do their own synchronization that is compatible with the
+wrappers). The wrapper for a function X...() is calles TSX...() (for
+"Thread Safe X ..."). So for example, instead of calling XOpenDisplay()
+in the code, TSXOpenDisplay() must be used. Likewise, X include files
+that contain function prototypes are wrapped, so that eg. "ts_xutil.h"
+must be included rather than <X11/Xutil.h>. It is important that this
+scheme is used everywhere to avoid the introduction of nondeterministic
+and hard-to-find errors in Wine.
+
+The code for the thread safe X wrappers is contained in the tsx11/
+directory and in include/ts*.h. To use a new (ie. not previously used) X
+function in Wine, a new wrapper must be created. The wrappers are
+generated (semi-)automatically from the X11R6 includes using the
+tools/make_X11wrappers perl script. In simple cases it should be enough
+to add the name of the new function to the list in tsx11/X11_calls; if
+this does not work the wrapper must be added manually to the
+make_X11wrappers script. See comments in tsx11/X11_calls and
+tools/make_X11wrappers for further details.
+
USER MODULE
===========