X Window System Core Protocol - Xlib and Other Client Libraries

Xlib and Other Client Libraries

Most client programs communicate with the server via the Xlib client library. In particular, most clients use libraries such as Xaw, Motif, GTK+, or Qt which in turn use Xlib for interacting with the server. The use of Xlib has the following effects:

  1. Xlib makes the client synchronous with respect to replies and events:
    1. the Xlib functions that send requests block until the appropriate replies, if any is expected, are received; in other words, an X Window client not using Xlib can send a request to the server and then do other operations while waiting for the reply, but a client using Xlib can only call an Xlib function that sends the request and wait for the reply, thus blocking the client while waiting for the reply (unless the client starts a new thread before calling the function);
    2. while the server sends events asynchronously, Xlib stores events received by the client in a queue; the client program can only access them by explicitly calling functions of the X11 library; in other words, the client is forced to block or busy-wait if expecting an event.
  2. Xlib does not send requests to the server immediately, but stores them in a queue, called the output buffer; the requests in the output buffer are actually sent when:
    1. the program explicitly requests so by calling a library function such as XFlush;
    2. the program calls a function that gives as a result something that involve a reply from the server, such as XGetWindowAttributes;
    3. the program asks for an event in the event queue (for example, by calling XNextEvent) and the call blocks (for example, XNextEvent blocks if the queue is empty.)

Higher-level libraries such as Xt (which is in turn used by Xaw and Motif) allow the client program to specify the callback functions associated with some events; the library takes care of polling the event queue and calling the appropriate function when required; some events such as those indicating the need of redrawing a window are handled internally by Xt.

Lower-level libraries, such as XCB, provide asynchronous access to the protocol, allowing better latency hiding.

Read more about this topic:  X Window System Core Protocol

Famous quotes containing the words client and/or libraries:

    A client is to me a mere unit, a factor in a problem.
    Sir Arthur Conan Doyle (1859–1930)

    riding flatcars to Fresno,
    Across the whole country
    Steep towns, flat towns, even New York,
    And oceans and Europe & libraries & galleries
    And the factories they make rubbers in
    Gary Snyder (b. 1930)