You walk into a department store to buy a new suit. This store only sells one style of suit: a three piece polyester item with matching tie. You get your choice of colors, but there is only one size.
Just down the block there's another store with both suits and separates. It offers a diversity of colors,sizes, styles, and fabrics from all kinds of manufacturers. You can buy any tie you want. Even better, most of the clothes in this store are free. Tailoring isn't included, but they'll provide you with everything you need to make the suit yourself or hire a tailor.
Where do you shop?
If you are like me, you might complain a bit, just because it takes more time to make up your mind with all of these choices. But you'll shop in the second store every time. Now, instead of clothes, think of the graphics on your desktop, and you'll be on your way to understanding the windowing supermarket that makes up Linux's X Window System.
X Marks the Spot
Most graphical user interfaces are all-in-one systems. Often, with Windows and MacOS for example, they are integrated right into the operating system. This makes things nice and consistent for the user, but this consistency comes at the expense of choice.
Linux, like most forms of Unix, takes a different approach. It uses the X Window System. The X Window System (also called X11, or simply X) de-couples the graphics system from the OS, and splits it into two components: One component, called the X server, draws the dots and lines on your monitor; a second component, called the client, tells the server what to draw and keeps track of what's going on within the various windows on your desktop. In fact, these two components can even reside on different computers and communicate across a network. The X server has to run on your desktop, but it can be controlled by a client a continent away, if you choose.
A standardized protocol, called (surprise, surprise!) X, lets all this communication take place. The X protocol has been implemented on a wide variety of systems, including all flavors of Unix, Windows, and MacOS. It is important to note that in X terminology, the application talking to the X server is always called a client, even if this "client" is, in reality, a server application. Your company's billing system may run on a centralized server, but it's a client as far as X is concerned; it's a client to the X server on your desktop. This seems to be the reverse of normal client-server nomenclature, but it makes sense if you really think about it.
The window manager is another important part of the X Window System. The window manager is a client to the X server that runs alongside other clients, handling a lot of the management work of manipulating and displaying the windows on your desktop. You can run only one window manager at a time, and they enjoy special privileges. For example, when an application requests a new window on your screen, the X server won't create it until the window manager says where it should be placed.
 |
Figure 1: The relationship between the various elements of the X Window System. |
All of this choice can make for interesting combinations. You can have the X server displaying graphics on your Macintosh in San Francisco, with its window manager running on a Solaris box in Taiwan, and these can be hooked up with some kind of supercomputer application running on a Cray in France. Just as easily, the Linux machine on your desktop can be running all three components -- the X server, the window manager, and the application -- itself.
Figure 1 shows how all of these components interact with Linux. The X server handles the display management and the window manager takes care of managing all of the application windows.
If you want, your Linux machine can run more than one X server. And if you really want, one X server can handle the graphics display for several monitors. But let's keep things simple for now.
The X Server
The X server is what actually draws the graphics you see on your screen. It communicates with your video card, either directly or via the kernel's device drivers, depending on the X server and card you're using. It takes requests from applications and renders whatever text, windows, or images the client application asks it to display. The X server also lets these applications know about what-ever key-presses or mouse movements the person using the application may be making.
The X server is the only component of the X Window System that has to run on your local machine. Typically, a client application will ask the X server to draw a line or write a word on the screen. The client will say what font to use and where the drawing should take place. The X server then decides how to draw the line. It may hand this task off to your graphics accelerator, if the card is advanced enough. Otherwise the X server will do the work itself.
If it's being asked to render text, the X server will either parse the font file itself, or communicate with a font server to figure out how to render the font. In either case, the X server will then copy the rendered text to your video card's RAM.
By far, the most popular X server for Linux is the XFree86 server, but others are available from vendors like Metro Link and Xi Graphics. SuSE and Red Hat distribute the XFree86 server, but with extra drivers included.
You can usually fire up the X server by typing X at the shell prompt. When you do this, you should be rewarded with a screen full of a strange grayish pattern, (known as the "root weave") with an "X" at the center. The X will move around in response to your mouse, but otherwise nothing will happen. Your X server is waiting for a client.