Tuesday, October 27, 2009

UNIX Gets All GUI













UNIX Gets All GUI

The earliest UNIX systems didn’t have fancy, screen-oriented windowing systems. They didn’t have screens at all, in fact — they used loud, rattling terminals that printed on actual paper. (The historically minded can find these types of terminals in the Computer Museum in Boston and the Smithsonian Institution in Washington, D.C. Yes, really.) As the years went by, UNIX appeared on computers that did have screens (most notably Sun workstations), and various windowing systems appeared.








One thing about the UNIX community you’ve probably come to appreciate by now is that you can’t get everyone to agree on anything, except of course that UNIX is better than every other kind of system and that anyone who thinks otherwise is silly. So, not surprisingly, a variety of incompatible windowing systems arose, each different from the other in various, not particularly interesting, ways. Nearly all the windowing systems were proprietary (they belonged to one system vendor or another), and, of course, no vendor would dream of admitting that someone else’s window system was better than theirs.




X marks the window


Universities also had a bunch of window system projects. One of the more successful was the X Window project at MIT (alleged to be a successor to the W Window project at Stanford — as far as we know, no one created a V Window project). The X Window system had many virtues, not the least of which were that it worked adequately well and it was available for free to anyone who wanted it. So X became the window system everyone used.


Almost all UNIX systems that have any sort of GUI now use one based on the X Window system (frequently abbreviated to just X Windows, which has been known to drive UNIX purists crazy because it sounds too much like that other famous operating system from Redmond, Washington). Old Sun workstations used systems called SunView or NeWS; NeXT machines use NeXTStep (are tHoSE wOrDS cAPiTaLIzed corREctlY?); other than those exceptions, however, you almost certainly get X Windows.


X (which is an even shorter abbreviation for X Window system) has many advantages as a windowing system:




  • It runs on all sorts of computers, not just those that run UNIX.




  • It is policy independent: A program can make the screen look any way it wants; the screen is not constrained to a single style, as it is on the Macintosh or with Microsoft Windows. (As you may imagine, this capability is not an unmitigated blessing. Read more about this subject in “Just my look” later in this chapter.)




  • It uses a networked client-server architecture (love those buzzwords). You can run X on one computer, and the programs that display stuff on-screen can be on entirely different computers connected by a network.




  • MIT gives it away.




You can imagine which of these important advantages is the one that really made all the computer makers choose X. Even though MIT gives away the base version of X, unless you happen to be using the exact same kind of computer the guys at MIT use (or you feel like compiling and debugging a gazillion lines of C code), you don’t get it for free. You must buy a version tailored for the particular kind of screen and adapter on your computer. An exception is XFree86, a free version of X used by most PC-based UNIX systems, such as Linux, which is described in Chapter 3.


How your screen looks depends on which GUI you use. The first part of this chapter talks about things that are the same for all GUIs. Later, we talk about how to tell which GUI you are using and how to do things that work differently for each GUI.





“I’m not just a server — I’m also a client!”


X was designed from the beginning to work with computer networks. It makes a clear distinction between the server program, which handles the screen, keyboard, and mouse, and the client program, which does the actual computing. Although the two programs are running more often than not on the same computer, they don’t have to be. (Readers who saw John on The Internet Show on public TV a few years ago may recall one demonstration of an online subway map of Paris. That was an X application, with the X server running on a PC in the TV studio in Texas and the client program on a computer in France, connected by way of the Internet.)


The networkability (is that a word?) of X is most useful in two ways. One way is that you can be sitting at an X workstation attached to a local network and have windows attached to client programs running on computers all over the network, often on computers considerably more powerful than yours, particularly if you’re running on an old PC. X terminals, stripped down PCs, used to run only one program, the X server, but these days PCs have gotten so cheap that they cost less than any plausible X terminal. Should you find yourself using an X terminal, it works just like a UNIX workstation except, of course, that all of the programs you run have to be on other computers.

















Just my look


Most windowing systems on most kinds of computers make programs use a consistent style. All Macintosh programs, for example, look pretty much the same: They all use the same menu, the same little window when you want to select a file, and similar windows to turn options on and off. One Microsoft Windows program looks much like all the others: They all use similar sets of windows.


Do all X Windows programs have a consistent look? Of course not — that would be too easy. This situation is what the X crowd means by policy independence: X is utterly agnostic about what windows should look like on-screen, how keystrokes and mouse clicks should be interpreted, and pretty much anything else that affects a user. This lack of policy was part of the original appeal of X because no matter which window system you are used to, you can make X look just like that system. The good news is that X offers great flexibility. The bad news is that the word inconsistent barely scratches the surface of what you run into.



Makeup artists for your windows


One of the ways in which X avoids having any policy built in is that it foists much of the general window-management jobs onto a program called a window manager. (Catchy name, huh?) The window manager handles jobs such as creating borders around each application’s main windows; controlling how you move, resize, switch among, and iconify windows; and most of the other tasks that aren’t part of any particular application. It’s possible to run X without any window manager, although it’s rather unpleasant because, without one, you have no way to do some things, such as move a window.




A field guide to window managers


A bunch of competing window “looks” are on the UNIX market. To tell which one you’re stuck with . . . er, have the pleasure to use, look at the border around the windows on your screen. If they have 3-D–style borders with sharp corners, as shown in Figure 4-1, you’re using the Motif Window Manager (MWM); its free look-alike counterpart, FVWM; or DTWM, the Desktop Window Manager that comes with the Common Desktop Environment (CDE). If the borders have rounded corners, as shown in Figure 4-2, you’re using OpenLook. If they have a thin border around the sides and bottom and top borders like those shown in Figure 4-3, you’re probably using a program called TWM, which comes with the base version of X and is still sometimes used because it is simple and small.






Figure 4-1: A typical Motif window.





Figure 4-2: A typical OpenLook window.





Figure 4-3: A typical TWM window.

The Open Software Foundation, the same people who provide the OSF/1 version of UNIX, created Motif, based on some work done by their members Hewlett-Packard and Digital Equipment. Motif is much more complete than its competition (it has a provision for handling languages other than English, for example), and because DEC made it cheap for software vendors to use, it became the primary X Windows manager until KDE and GNOME came along.


People using the Common Desktop Environment (CDE) get the Desktop Window Manager, or DTWM. CDE comes with all kinds of nifty and zoomy programs, although underneath the glitz it’s just a version of Motif, so it looks pretty much the same.


Lots of other window managers exist, although the ones described in this section are the most common ones. After several years of window system warfare, Motif and its clone FVWM have emerged as the clear favorite window managers, so that’s what we concentrate on here. Even if you use a different window manager, it probably works about the same way that Motif does.






Considerably more than you want to know about window managers, toolkits, and X



�Technical Stuff��If you’re dying to know more about how the X Window system works, strap on your safety belts because we’re going to get a little technical. If you’re dying to know how to use your window manager and couldn’t care less about how it works, skip down to the section “Stupid Window Manager Tricks.” If you’re sticking with us, just don’t say that we didn’t warn you.








The X Window system divides the work of controlling what’s on-screen among three separate kinds of programs:





  • X server: Draws pictures on-screen and reads user input from the keyboard and mouse





  • Window manager: Controls where windows appear on-screen, draws borders around windows, and handles basic window operations, such as moving windows, shrinking windows to an icon (a little box representing that window), and expanding icons to windows





  • Clients: Programs that do some real work




For any particular screen, there’s one X server, usually (but not always) one window manager, and a bunch of clients. Every client communicates with �the server to tell it what to draw and to find out what you did; the server communicates with the window manager when the user asks for a window-management operation, such as changing the size of a window. Although the server, window manager, and clients usually run on the same computer, X Windows enables them to exist on separate machines connected by a network. It is not unusual to have a setup in which the server runs on an X terminal, the window manager runs on a nearby workstation, and the clients are on various machines scattered around the network.


The window manager is usually a regular UNIX program. You can stop one window manager and start another if you decide that you don’t like the way your windows look. Client programs can ask the X server to ask the window manager to do some specialized operations. A terminal program, for example, can ask the window manager to enable a user to change the size of the window only to a size that is a whole number of lines of text. (This kind of communication starts to resemble that in the ancient Roman Empire, in which proconsuls could officially speak only to procurators, who could speak to senators, and so on. Computers are like that.) If no window manager exists, no window-management operations are available.


Writing an X program is a great deal of work. To make life easier for programmers, a programmer can build on toolkits of program code that are already written. MIT sends out X Toolkit (immediately called Xt by the usual lazy typists). This toolkit provides a set of basic window functions that most programs use. Starting with Xt, different people have produced libraries of widgets, or screen elements a program can use. A menu or a file-selection panel is a widget, for example. The Motif widget set is for programs that want to look like Motif. The Athena widgets from MIT’s Project Athena aren’t particularly attractive, but many programs use them because (where have we heard this before?) they’re available for free. You can also find other toolkits for other window systems, including KDE and GNOME.














What all this means is that any particular X client uses one of the widget sets to control what that client’s window looks like. A program that uses the Motif toolkit, for example, is a Motif program. Because clients are separate from window managers, however, the Motif window manager (named mwm — the lazy typists strike again) can be running and draw a Motif border around the windows of clients using other toolkits.


Because of the constant danger that GUI systems could begin to make sense to users, UNIX people have learned to obfuscate things by using “Motif” to refer to both the Motif window manager and the Motif toolkit, which are, of course, completely separate entities. When people refer to “Motif,” therefore, they may be referring to the window manager or maybe to the toolkit. Or both. Often it’s difficult to tell. This confusion is all just part of the proud legacy of UNIX evolution.


One school of thought says that we all would be better off if X Windows had picked a window style and stuck with it so that we would have a single window manager and a single set of widgets — as every other window system does — although it’s much too late now for that.












No comments:

Post a Comment