1.3 X Window System Software Architecture

By now, we have described enough to draw a simple picture of the X Window System architecture (see Figure 1-3).

Clients communicate with the server via Xlib calls

Figure 1-3. Clients communicate with the server via Xlib calls

A display server is a program that runs on each system that supports a graphics display, keyboard, and mouse. The X release from MIT includes sample monochrome and color servers for Sun, DEC, Hewlett Packard, IBM, Apple Macintosh, and many other systems. Commercially developed servers are available for virtually all major workstation vendors. In addition, companies such as Graphics Software Systems, Interactive Systems, and Locus Computing offer server implementations for IBM-compatible PCs. Finally, there are X terminals, which are screens controlled by an X server running in ROM. X terminals are available from companies such as Visual, Network Computing Devices, and GraphOn.

Applications communicate with the server by means of calls to a low-level library of C language routines known as Xlib.[3] Xlib provides functions for connecting to a particular display server, creating windows, drawing graphics, responding to events, and so on. Xlib calls are translated to protocol requests sent via tcp/ip either to the local server or to another server across the network. Some of the many sample applications available on the X release include xterm (a terminal emulator), xcalc (a calculator), xmh (a mail handler), xclock (a clock), and a troff previewer.

The window manager is just another program written with the X library, except that by convention it is given special authority to control the layout of windows on the screen.

Client is a slightly more general term than application, although they are almost synonymous. All clients except the window manager are called applications. When a statement in this manual applies only to the window manager or only to the applications managed by the window manager, the appropriate term is used. In other instances, whichever term seems more natural is used.

Applications and window managers can be written solely with Xlib or with a set of higher-level subroutine libraries known as toolkits. Toolkits implement a set of user interface features such as menus or command buttons (referred to generically as toolkit widgets) and allow applications to manipulate these features using object-oriented programming techniques. Toolkit intrinsics allow programmers to create new widgets.

There are several toolkits distributed with the X11 release, the most notable of them being the Xt Toolkit, which was developed by Digital and MIT, and the Interviews toolkit, which was developed by Stanford University. Xt is now officially part of the X11 standard.

Toolkits can make programming much, much easier and the finished project more thorough. Toolkits have built-in user configurability and built-in code for interaction with the window manager, which will save you a lot of trouble. You are advised to use a toolkit for most of your X programming. However, all existing toolkits in C also require or allow you to use Xlib code. And, more than that, they use Xlib internally; so understanding Xlib will help you understand how the toolkits work.

Another reason to use a toolkit is to take advantage of established user interface conventions. Several of these are available, such as OSF’s Motif and Sun’s OPEN LOOK. If you use Xlib for all your X programming, either you will have to reimplement one of the established conventions such as OPEN LOOK or your program will be an oddball that will not look or respond as people expect.

There are tradeoffs in using toolkits, however. One is that the executable for a given program using a toolkit is considerably larger than the equivalent program written using Xlib. Another is that the toolkits utilize highly abstract concepts and require strict programming conventions because of their object-oriented design. These take time to learn.

This manual describes how to write programs with Xlib. Other volumes in our X Window System series cover the toolkits.



[3] A low-level analog to Xlib exists for Lisp.

Get XLIB Programming Manual, Rel. 5, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.