An Introduction to the X Window System
This chapter describes the features of a typical X display, while introducing some basic window system concepts. It also provides an overview of the X Window System’s client-server architecture and briefly describes the most commonly used clients.
In This Chapter:
An Introduction to the X Window System
The X Window System, called X for short, is a network-based graphics window system that was developed at MIT in 1984. Several versions of X have been developed, the most recent of which is X Version 11 (X11), first released in 1987.
X11 has been adopted as an industry-standard windowing system. X is supported by a consortium of industry leaders such as DEC, Hewlett-Packard. Sun, IBM. and AT&T that have united to direct, contribute to, and fund its continuing development In addition to the system software development directed by the X Consortium, many independent developers are producing application software specifically for use with X. Because X11 is a relatively new standard. much of this application software has yet to be released.
First, we’ll take a look at a typical X display and consider some general system features. Then we’ll discuss what distinguishes the X Window System from other window systems. We’ll also briefly consider some of the more important programs included in the standard distribution of X.
X is typically run on a workstation with a large screen (although it also runs on PCs and special X terminals, as well as on many larger systems). X allows you to work with multiple programs simultaneously, each in a separate window. The display in Figure 1-1 includes five windows.
The operations performed within a window can vary greatly, depending on the type of program running it. Certain windows accept input from the user: they may function as terminals, allow you to create graphics, etc. Other windows simply display information, such as the time of day or a picture of the characters in a particular font, etc.
The windows you will probably use most frequently are terminal emulators, windows that function as standard terminals. The terminal emulator included with the standard release of X is called xterm. Figure 1-1 depicts three xterm windows. In an xterm window, you can do anything you might do in a regular terminal: enter commands, run editing sessions, compile programs, etc.
The display in Figure 1-1 also includes two other application windows: a clock (called xclock) and a calculator (xcalc).
The shaded area that fills the entire screen is called the root (or background) window. One of the strengths of a window system such as X is that you can have several processes going on at once in several different windows (perhaps on different machines). For example, in Figure 1-1, the user is Jogging in to a remote system in one xterm window and is editing a text file in each of the two other xterm windows. (As we’ll see in Chapter 4, The xterm Terminal Emulator, you can also cut and paste text between two windows.) Be aware, however, that you can only input to one window at a time.
Windows often overlap each other much like sheets of paper on your desk or a stack of cards. Note that overlapping docs not interfere with the process run in each window.
One of the main features of X is a type of program called a window manager. The window manager controls the general operation of the window system, allowing you to change the size and position of windows on the display. You can reshuffle windows in a window stack, make windows larger or smaller, move them to other locations on the screen, etc. In short, it is the window manager that controls the “look and feel” of the X Window System.
In Release 4, the X Consortium provides a window manager called twm. (twm originally stood for “Tom’s window manager,” in honor of its developer, Tom LaStrange. However, it has since been renamed the “tab window manager.” Earlier releases supported a window manager called uwm, “universal window manager.”) Notice that each window on our typical display has a horizontal bar that spans its top edge. This feature is known as a title bar, mainly because it contains a text description of the window. (Generally, this is the application name, but as we’ll see later, you can often specify an alternate title.) The titlebar is provided by twm and is one of this window manager’s hallmarks.
In addition to displaying title text, the titlebar provides some of the functionality of the twm window manager. Using the mouse or other pointer device, you can click on various parts of the titlebar to manipulate the window. Manipulating a window with the titlebar is described in detail in Chapter 3, Using the twm Window Manager.
If you are using another window manager, the X display may have a different look and feel. (Though you can run a window system such as X without a window manager, this severely limits the system’s power and flexibility, since there is no easy way to change the size and position of windows on the display.)
Also pictured in Figure 1-1 is an icon. An icon is a small symbol that represents a window in an inactive state. The window manager allows you to convert windows to icons and icons back to windows. You may want to convert a window to an icon to save space on the display or to prevent input to that window. Each icon has a label, generally the name of the program that created the window. The icon in Figure 1-1 represents a fourth xterm window on the display. Icons can be moved around on the display, just like regular windows.
The contents of a window are not visible when the window has been converted to an icon, but they are not lost In fact, a client continues to run when its window has been iconified; if you iconify a terminal emulator client, such as xterm, any programs running in the shell will also continue.
All X displays require you to have some sort of pointer, often a three-button mouse, with which you communicate information to the system. As you slide the pointer around on your desktop, a cursor symbol on the display follows the pointer’s movement. For our purposes, we will refer to both the pointer device (e.g., a mouse) and the symbol that represents its location on the screen as pointers. Depending on where the pointer is on the screen (in an xterm window, in another application window, on the root window, etc.), it is represented by a variety of cursor symbols. If the pointer is positioned on the root window, it is generally represented by an X-shaped cursor, as in Figure 1-1. If the pointer is in an xterm window, it looks like an “I” and is commonly called an I-beam cursor.*
A complete list of cursors is shown in Appendix D, Standard Cursors. Some of the most common cursor shapes are shown in Figure 1-2. As we’ll see later, some applications allow you to select the cursor to use.
You use the pointer to manipulate windows and icons, to make selections in menus, and to select the window in which you want to input. You can’t type in an xterm window unless you place the pointer in that window, as in Figure 1-3.
Directing input to a particular window is called focusing. You must be sure that the pointer rests in the desired window before you begin typing. The window border (if present) and text cursor are also highlighted when the pointer is in that window. The highlighting is a characteristic of xterm: other applications may not highlight display features.
The fact that input focus automatically follows the pointer is a default characteristic of the twm window manager. Other window managers require you to click on a window to focus input on that window. These two window manager focusing styles are commonly referred to as “real-estate-driven” (or “pointer focus") and “click-to-type.”
The most important thing to recognize is that the position of the pointer is very important to a real-estate-driven window manager like twm. If something doesn’t work the way you expect, make sure that the pointer is in the right place. After you use X for a while, awareness of pointer position will come naturally.
Be aware that it may take a moment for the input focus to catch up with the pointer, especially on slower machines. If you type right away, some keystrokes may end up in the window you left rather than in the new window. This is really a bug and happens because of the additional overhead involved in complex window managers like twm or mwm. It doesn’t happen if you are using a simpler window manager like uwm.
The pointer is also often used to display menus. Some X programs, notably twm and xterm, have menus that are displayed by keystrokes and/or pointer button motions. Unlike some window systems, which allow you to “pull down” menus from a menu bar that is always displayed, twm (and most X clients) support “pop-up” menus, which are displayed at the current pointer position. In addition to keyboard keys and pointer button motions, the location of the pointer also plays a role in displaying menus. For example, xterm menus can only be displayed when the pointer is within an xterm window. Figure 1-4 shows a twm menu called
Twm, which is displayed by placing the pointer on the root window and holding down the first pointer button.
You generally display this menu by moving the pointer to the root window and pressing and holding down the first pointer button. In Figure 1-4, the arrow next to the menu title represents the pointer. As you drag the pointer down the menu, each of the menu selections is highlighted. Regardless of the program, you generally select a menu item by dragging the pointer down the menu, highlighting the item you want, and releasing the pointer button.
With other programs, particularly several other window managers, you can display a menu simply by placing the pointer on a particular part of the window, e.g., a horizontal bar across the top.
A final note about the X display: in X, the terms display and screen are not equivalent. A display may consist of more than one screen. This feature might be implemented in several ways. There might be two physical monitors, linked to form a single display, as shown in Figure 1-5. Alternatively, two screens might be defined as different ways of using the same display. For example, on the Sun-3/110 color workstation, screen 0 is black and white, and screen 1 is color. By default, windows are always placed on screen 0, but you can “scroll” between the two screens with the mouse, or place a client window on screen 1 by specifying the screen number in the
-display option when starting the client. (See Chapter 8, Command Line Options, for more information on the
Most window systems are kernel-based: that is, they are closely tied to the operating system itself and can only run on a discrete system, such as a single workstation. The X Window System is not part of any operating system but is instead comprised entirely of “user-level” programs.
The architecture of the X Window System is based on what is known as a client-server model. The system is divided into two distinct parts: display servers that provide display capabilities and keep track of user input, and clients, application programs that perform specific tasks. On a more basic level, the server acts as an intermediary between client application programs and the local display hardware. The client programs make requests (for information, processes, etc.) that are communicated to the hardware display by the server.
This division within the X architecture allows the clients and the display server either to work together on the same machine or to reside on different machines (possibly of different types, with different operating systems, etc.) that are connected by a network. For example, you might use a relatively low-powered PC or workstation as a display server to interact with clients that are running on a more powerful remote system. Even though the client program is actually running on the more powerful system, all user input and displayed output occur on the PC or workstation server and are communicated a across the network using the X protocol Figure 1-6 shows a diagram of such a network.
There is another less obvious advantage to the client-server model: since the server is entirely responsible for interacting with the hardware, only the server program must be machine-specific. X client application programs can be ported easily from system to system.
The X display server is a program that keeps track of all input coming from input devices, such as the keyboard and mouse, and input from any other clients that are running. As the display server receives information from a client, it updates the appropriate window on your display. The display server may run on the same computer as a client or on an entirely different machine.
Servers are available for PCs, workstations, and even for special terminals, which may have the server downloaded from another machine or stored in ROM.
X allows you to run many clients simultaneously. For example, you could be editing a text file in one window, compiling a program source file in a second window, reading your mail in a third, all the while displaying the system load average in a fourth window.
While X clients may display their results and take input from a single display server, they may each be running on a different computer on the network. It is important to note that the same programs may not look and act the same on different servers since there is no standard user interface, since users can customize X clients differently on each server, and since the display hardware on each server may be different.
Several of the more frequently used client programs are discussed in the following paragraphs.
The way a kernel-based window system operates is inherent in the window system itself. By contrast, the X Window System concentrates control in a window manager, several of which are available. The window manager you use largely determines the look and feel of X on a particular system.
The window manager shipped with the standard release of X from MIT is called twm. As we’ve discussed, twm allows you to move and resize windows, rearrange the order of windows in the window stack, create additional windows, and convert windows into icons, etc. These functions are discussed more fully in Chapter 2, Getting Started, and Chapter 3, Using the twm Window Manager.
Prior to Release 4, the standard window manager shipped with X was uwm, the universal window manager. uwm has been superceded by twm because the latter has been made compliant with the X Consortium’s Inter-Client Communication Conventions Manual (ICCCM), introduced at Release 3.
The ICCCM contains standards for interaction with window managers and other clients. It defines basic policy intentionally omitted from X itself, such as the rules for transferring data between applications, for transferring keyboard focus, for installing colormaps, and so on. As long as applications and window managers follow the conventions outlined in the ICCCM, applications created with different toolkits will be able to coexist and work together on the same server.
Because uwm does not comply with the standards outlined in the ICCCM, it has been moved to a directory of user-contributed clients in Release 4, where it is still available for those who wish to use it. However, uwm is no longer officially supported by the X Consortium, and it should probably not be the window manager of choice. If you are still using uwm, Appendix B, The uwm Window Manager, discusses getting started with and customizing this window manager.
In this guide, we assume you are using twm. Several other window managers, such as mwm (the Motif™ window manager), awm (Ardent™ window manager), rtl (tiled window manager, developed at Siemens Research and Technology Laboratories, RTL), and olwm (the OPENLOOK™ window manager) are also widely used.
mwm is discussed in greater detail in Appendix C, The OSF/Motif Window Manager.
If the twm window manager has been customized at your site or you are using a different window manager, many of the concepts should still be the same. However, the actual procedures shown may well differ. See Chapter 10, Customizing the twm Window Manager, for a discussion of how to customize twm.
X11 itself is designed to support only bitmapped graphics displays. For this reason, one of the most important clients is a terminal emulator. The terminal emulator brings up a window that allows you to log in to a multiuser system and to run applications designed for use on a standard alphanumeric terminal. Anything you can do on a terminal, you can do in this window.
xterm is the most widely available terminal emulator. xterm emulates a DEC® VT102 terminal or a Tektronix® 4014 terminal. You can display both types of windows at the same time, but only one is active at a time.
Since you can bring up more than one xterm window at a time, you can run several programs at once. For example, you can have the system transfer files or process information while you focus your attention on a text-editing session. Multiple xterm processes allow you to display interactions in separate windows on your screen. See Chapter 2, Getting Started, and Chapter 4, The xterm Terminal Emulator, for additional information.
The display manager, xdm, is a client that is designed to start the X server automatically (from the UNIX /etc/rc system startup file) and to keep it running. (X can also be started manually, as described in Chapter 2.) In its most basic implementation, the display manager emulates the getty and login programs, which put up the login prompt on a standard terminal, keeping the server running, prompting for a user’s name and password, and managing a standard login session.
However, xdm has far more powerful and versatile capabilities. Users can design their own sessions, running several clients and setting personal resources (such as keyboard, pointer, and display characteristics). You can also customize special xdm files to manage several connected displays (both local and remote) and to set system-wide X resources (for example, client default features). Resources are discussed in Chapter 9, Setting Resources. See Appendix A, System Management, for a discussion of how to set up and customize the display manager.
The following is a brief list of some other clients commonly included with X.
For additional information on these and other clients, refer to Chapter 5, Font Specification, Chapter 6, Graphics Utilities, Chapter 7, Other Clients, Chapter 11, Setup Clients, and to the reference page for each client in Part Three of this guide. As more commercial and user-contributed software is developed, many more specialized programs will become available.
Most X clients are designed to be customized by the user. A multitude of command line options can be used to affect the operation of these clients. More conveniently, default values for each option can be stored in a file (generally called .Xresources or .Xdefaults) in your home directory. If you are running clients on multiple machines, a program called xrdb (X resource database manager) should be used to store your defaults in the server so that you don’t need to maintain an .Xdefaults file on each machine.
There is a separate customization file for the twm window manager, called .twmrc, which is also kept in your home directory.
Client customization is described in Part Two of this guide.
*Even though the actual image on the screen is called a cursor, throughout this guide we refer to “moving the pointer” to avoid confusion with the standard text cursor that can appear in an xterm window.