Page:Xlib - C Language X Interface.pdf/32

 * It disowns all selections owned by the client (see XSetSelectionOwner).
 * It performs an XUngrabPointer and XUngrabKeyboard if the client has actively grabbed the pointer or the keyboard.
 * It performs an XUngrabServer if the client has grabbed the server.
 * It releases all passive grabs made by the client.
 * It marks all resources (including colormap entries) allocated by the client either as permanent or temporary, depending on whether the close-down mode is RetainPermanent or RetainTemporary. However, this does not prevent other client applications from explicitly destroying the resources (see XSetCloseDownMode).

When the close-down mode is DestroyAll, the X server destroys all of a client's resources as follows:


 * It examines each window in the client's save-set to determine if it is an inferior (subwindow) of a window created by the client. (The save-set is a list of other clients' windows that are referred to as save-set windows.) If so, the X server reparents the save-set window to the closest ancestor so that the save-set window is not an inferior of a window created by the client. The reparenting leaves unchanged the absolute coordinates (with respect to the root window) of the upper-left outer corner of the save-set window.
 * It performs a MapWindow request on the save-set window if the save-set window is unmapped. The X server does this even if the save-set window was not an inferior of a window created by the client.
 * It destroys all windows created by the client.
 * It performs the appropriate free request on each nonwindow resource created by the client in the server (for example, Font, Pixmap, Cursor, Colormap, and GContext).
 * It frees all colors and colormap entries allocated by a client application.

Additional processing occurs when the last connection to the X server closes. An X server goes through a cycle of having no connections and having some connections. When the last connection to the X server closes as a result of a connection closing with the close_mode of DestroyAll, the X server does the following:


 * It resets its state as if it had just been started. The X server begins by destroying all lingering resources from clients that have terminated in RetainPermanent or RetainTemporary mode.
 * It deletes all but the predefined atom identifiers.
 * It deletes all properties on all root windows (see section 4.3).
 * It resets all device maps and attributes (for example, key click, bell volume, and acceleration) as well as the access control list.
 * It restores the standard root tiles and cursors.
 * It restores the default font path.
 * It restores the input focus to state PointerRoot.

However, the X server does not reset if you close a connection with a close-down mode set to RetainPermanent or RetainTemporary.

 2.7. Using Xlib with Threads 

On systems that have threads, support may be provided to permit multiple threads to use Xlib concurrently.