3. Introduction to the X Window System


About this Section

The School of Computing Science provides several types of computing environments for students: Unix Workstations, IBM VM/CMS, Macintoshes and PCs.

This section of the Sun User Guide describes how to begin using the Unix Workstations operated by the School of Computing Science. It focuses on the X-Window system - an interactive graphical computing environment that runs on these workstations. Also provided are references for more information and assistance.

Window Systems

A window on a workstation is a logical entity of interaction between the user and the workstation. For example, if you want to use a standard Unix shell (command interpreter) on the workstation, you might create a window in which you can type shell commands and in which the shell responses are displayed. lf you are a clock watcher, you may create another window which always displays the current date and time. If you are developing software, you may create several shell and editor windows side-by—side on the workstation screen to save time jumping from one point to another in your program. The typical application has a single rectangular window displayed on the screen. However, some applications open multiple windows and some window systems allow arbitrarily shaped windows (not just rectangles).

A window system is a collection of software that makes it easy for you to take full advantage of the graphics and capabilities of the workstation. The window system keeps track of all the application programs that you are using, what windows are associated with these programs and what the status of input/output to/from those applications is. Windows may overlap (or be totally obscured) by other windows; the window system manages all of this, making sure that the correct portions of the window are displayed and that windows are able to redisplay their contents when they become unobstructed. Most window systems provide an easy way of manipulating windows (e.g. moving them around the screen, resizing them, redrawing them, etc.). Since window systems run on computers with graphics capabilities, they usually use icons (pictorial representations of objects) to make the environment easier to use.

There are many variations on window systems — the environment that runs on the Macintosh is probably the best known system today. MS-windows is another system running on many microcomputers. Other window systems include several developed specifically for Sun workstations (such as SunView and NeWS), although these are not available for use on the Sun Workstations available to students.

The X Window System was developed at MIT and runs on a wide range of workstations, including Suns, DECs, Apple Macintosh IIs and Apollos. Because of this (and other reasons), “X" (as it is often called) is quite popular in both academia and industry.

Using the X Window System

Getting Started

There are a few points to remember when using the Sun workstations:

* The Suns are always on. They are never turned off. If you want to start using a Sun that appears to be turned off, jiggle the mouse and press the key. If this doesn’t cause the screen to tum on, then contact your friendly support staff (room 4/439) or the on-duty Programmers’ Society member. Do not EVER touch any On/Off switches on any Sun Workstation!!!

* The mouse pointer must be in your window. If you are typing, yet keystrokes are not being registered on the workstation screen, then one cause may be that your mouse pointer has strayed from your current window. Move the mouse so that the mouse pointer is inside the boundary of the window in which you wish to type.

To use the Sun workstations, you must be registered as a user. If you have not yet registered, please read the section Registering as a User and follow the instructions to become registered.

Find an available workstation with a screen that is displaying a window similar to figure 3.1. If the screen is blank, jiggle the mouse to turn it on.

Once you have located an available workstation (most workstations available for student use are on the fourth floor of Building Four) log in using your normal user—id and password combination (for first time users, these were assigned to you when you registered).

If you did not supply a valid user—id and password, then the workstation will respond with the message :

   “Username or Password invalid — Please re—try"

If this message appears, retype your user—id and your password. If this message is displayed again, please contact your friendly support staff (room 4/439) to ensure that you are indeed a registered user.

If the user-id and password you typed were correct, then the workstation will log you into your account and start an X window session for you. The X Window session may take anywhere from a few seconds to several minutes to start up, depending on how busy the network is. During this time you should observe the following:

* The screen is cleared to a grey background pattem. This is known as the root window - the basic background window on top of which all other windows are displayed. (the small window at the bottom of the screen will remain in place. It will display any system error messages).

* A window may appear in the middle of the screen with a "Message of the Day" in it. This is an important announcement or message and should be read carefully. When it has been read, click (press a mouse button) the "continue" box in the bottom right corner.

* The workstation will beep (this indicates that a Window Manager has been started)

* A large terminal emulator window will appear in the top left hand corner of the screen. This is your default Unix shell window.

Refer to the section Using Xterm Windows for more information about terminal emulator windows.

Getting Around in X

The mouse and the pointer. The most important way to interact with a Sun workstation is through the mouse device. Move the mouse around the desktop and watch the pointer move around the screen. Note that the mouse pointer changes shape as it moves in and out of different types of windows. It is an X over the root (background) window. It changes to a "Gumby" symbol while over the System Console window (the small window at the bottom), which indicates that this window performs no user interaction. The pointer changes shape to a thin vertical bar while over Terminal Emulator (xterm) windows to facilitate sensitive mouse positioning while trying to edit text. Other programs use different pointer shapes to suit their own purpose.

Typing. Use the mouse to move the pointer into the large xterm window in the top left-hand corner of the display. You do not need to press a mouse button before typing (as you would on a Macintosh): X has a "point and type" interface. Once the pointer is inside the xterm window boundaries, type a simple Unix command (e.g. ls or who (see the Programmers’ Society Little Green Unix Guide for more details of Unix operation)). Your command should appear in the window followed by the Unix response to it.

Getting Help. After you have logged·in, you can get help with any command and/or application by typing the help command. This will produce a graphical help window where you can select topics to be browsed. If help is required on a particular topic, you may type help topic instead of just help.

Mouse Buttons. The mouse on a Sun Workstation has three buttons: left, middle and right. If you press or release a button, that event is usually sent to whichever window the mouse pointer happens to be in. See the section Using the UWM Window Manager later in this document for examples of mouse button usage.

WARNING: X has no standards for button functionality. That is, each application may assign completely arbitrary meaning to the mouse buttons when the pointer is within the window’s boundaries. Therefore, you should be cautious; use the man command to read an application’s documentation before attempting to use the mouse buttons with it.

Leaving X. You can exit the X environment by moving the mouse pointer to the xterm window in the top left comer of the screen and typing exit to kill the Unix shell.

WARNING: All windows and their contents are irretrievably destroyed when you exit from the X environment. Be sure to save editor buffers and to log out of remote sessions before leaving X!

Using Xterm Windows

A terminal emulator window is a window that acts as though it was a separate terminal with a connection to a remote computer, such as the workstation you are using. In X, you can use the xterm program to create terminal emulator windows; these windows are usually called "xterm windows". When you first logged into your workstation, an xterm window was created for you automatically in the top left-hand corner of your display.

Xterm (pronounced "ex-term") windows typically run a standard Unix shell so that you can type Unix commands in them and get responses from the Unix system running on your workstation. The paragraph entitled Typing in the previous section describes how to enter commands in an xterm window. It is possible to open a session on a remote computer in an xterm window by using the rlogin and telnet commands. Type man rlogin or man telnet for more information about these programs.

Using a Window Manager in X

What is a Window Manager?

A window manager is an application program that helps you perform special functions in the window environment. These functions can be divided into three groups as described below:

Window Manipulation:

* move a window

* change a window’s size

* bring a window to the front of the display (unobscured by other windows) or send it to the back (possibly obscured by other windows)

* destroy a window

* iconify (hide) a window (reduce it to a small graphical representation to get it out of the way of other work) or de— iconify (show) a window

* focus all typing on a particular window (regardless of mouse location), etc.

Window Environment manipulation:

* redraw the screen

* lock the workstation while you are away

* change settings that affect the overall window environment

* exit the X environment, etc.

Customised Commands:

* create a local or remote xterm window

* start up a text or graphics editor

* start up some other program that you use a lot and would like to have easily accessible in a window manager menu.

Within the X Window System, you typically run one window manager at all times. Without any window manager, you can become ‘trapped’ in a situation in which it is difficult to do what you want to do because certain windows are in the way of others. You cannot run more than one window manager at a time.

Several window managers are available for student use on the Sun Workstations, including uwm, twm, awm and rtl. They all perform the essential window manager functions. They differ primarily in style and special features.

When you log into your account, the uwm window manager is started automatically by default. It is possible to define which window manager you wish to use (see section Customising Your X Window Environment). The next section describes how to use the default window manager, uwm.

Using the UWM Window Manager

The UWM window manager is the default window manager for all Sun workstations running X Windows in the School of Computing Science. It is possible to use another window manager if you wish (see the section Customising Your X Window Environment for more details).

After you have logged in (and possibly read the Message of the Day) the workstation will create an xtenn window in the top left corner of your display and . will beep. The beep signifies that uwm (which stands for Universal Window Manager) has started up properly.

uwm is a menu driven application. That is, all the functions that can be performed by uwm are usually selected from a menu. The uwm menu is associated with the root window and the middle mouse button. To see the uwm default menu, move the mouse so that the mouse pointer is over the root window (the root window is the grey background on your display) and hold down the middle mouse button. The uwm menu should appear and will remain visible while the middle mouse button is being held down. To select an item from this menu, (keeping the middle button held down) drag the mouse pointer down until the item that you wish to select has been highlighted, then release the middle mouse button. The workstation should then perform the function that you selected.

The default uwm menu contains the following functions:

* New Window: This function will produce an xterm window. Several seconds after this item has been selected, the mouse pointer will change into a right—angle, which is the top corner of a "ghost window" (a ghost window is one that has not yet been fully displayed - only its outline is visible). You may now use the middle button to drag the new window to the size you want or just press the left-hand button to accept the standard size.

* RefreshScreen : Will cause the entire screen to redraw. If selected, the screen will flash and redraw.

* Redraw: Performs the same function as RefreshScreen except it acts on a single window rather than the entire screen.

* Move: Allows the user to reposition windows. When this option is selected, the mouse pointer changes to a pointing hand shape. You may then use any mouse button to drag any window to a new position.

* Resize : This function allows the user to change the size of a window. When this option is selected, the mouse pointer changes to a pointing hand shape. You may then use any mouse button to drag any one corner of a window to a new size. For example in Figure 3.2 to change the window shown to a larger size, the user would drag the lower right corner to the new size.

* Lower: Will take a window and move it to the bottom of a stack of windows, if there are any windows stacked. For example, see figure 3.3a and figure 3.3b. In figure 3.3a, window A is lying on top of window B. After window A has been lowered, however, window B is on top. lf there was not a stack of windows (i.e. window A was all by itself with no other windows around) this function would have had no effect.

* Raise: Similar to Lower but will bring a window to the foreground, rather than send it to the background.

* CircUp: Circulate Up. Similar to Lower except that it works with a stack of more than two windows. The top window is taken and moved to the bottom of the stack, regardless of how many windows there are. If there are only two windows stacked then this function is identical to Lower. It has no effect on a single, unrelated window.

* CircDown: Circulate Down. This selection performs the opposite function to CircUp. It takes the rear most window in a stack and promotes it to the top regardless of how many windows there are in the stack.If there are only two windows in the stack then CircDown is identical to Raise. It has no effect on a single, unrelated window.

* AutoIconify, LowerIconify, NewIconify: What a horrendous corruption of the English language. Who invented that word Iconify? Anyway, these functions will change a window from its normal displayed state to an icon1 and vice versa.

* Focus: Causes all keyboard input to be sent to a particular window, regardless of whether the mouse pointer is inside its boundaries or not. To perform this operation, select Focus from the menu. The mouse pointer will become a hand shape. Move the mouse until the hand shape is inside the window that you wish to focus on and click any mouse button. Focusing can be turned off (i.e. "normal" point-and- type operation can be resumed) by Focusing on the root window (the grey background).

* Freeze: Will cause X windows to stop. Not a particularly useful function. All windows will be defocussed until the workstation is Unfreezed2.

* Unfreeze: ’Thaws’ out a workstation that was unfortunate enough to have been Freezed3

* Restart: Used to restart uwm, typically after you have reconfigured it for your own personal use. It saves having to log out and in again for the changes to take effect.

* KillWindow: Will terminate an application’s window (and therefore the application). When selected, the mouse pointer changes to a hand shape. Move the mouse pointer to the window that you wish to kill and click any mouse button. Some error messages may (or may not) be generated4.

* Exit: This function will cause uwm to terminate. This ain’t5 a good idea unless you are intending to start another window manager immediately, since things can get pretty awkward without one.

It is important to remember that uwm is fully configurable. That is, you can change options to make it do whatever you wish it to do. You may, for example, modify it to have three menus — one bound to each mouse button. However, it is preferable that you become completely familiar with the X Windows environment before attempting to modify it. If you wish to modify your uwm interface, please read the section in this manual entitled Customising Your X Window Environment.


1 An icon is a small (often graphical) representation of a window

2 Yes, yes I know the proper term is "unfrozen" or perhaps even "defrosted" but the function is called Unfreeze, okay?

3 Okay, smarty, you try writing a manual about something that has functions that have names without consistent past participles.

4 Ignore them, okay.

5 Since I ain’t being grammatical anyway.