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:
- Xlib makes the client synchronous with respect to replies and events:
- 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);
- 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.
- 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:
- the program explicitly requests so by calling a library function such as
XFlush
; - the program calls a function that gives as a result something that involve a reply from the server, such as
XGetWindowAttributes
; - 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.)
- the program explicitly requests so by calling a library function such as
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 (18591930)
“To me, nothing can be more important than giving children books, Its better to be giving books to children than drug treatment to them when theyre 15 years old. Did it ever occur to anyone that if you put nice libraries in public schools you wouldnt have to put them in prisons?”
—Fran Lebowitz (20th century)