For speed this page has been mirrored locally from riceinfo.rice.edu. You may find the original or more up to date versions of this page at original riceinfo site.

Information Technology
  [back to RiceInfo]
1997.6.17

Introduction to the X Window System


This document helps new account holders familiarize themselves with the X Window System, Version 11 - simply called X - and maintains an emphasis on concepts and everyday use rather than highly technical details. This material includes an overview of X concepts and instructions for starting, conducting, and ending an X session. Also covered are the Tab Window Manager, or TWM, and the xterm terminal emulator, and other such topics such as remote processes.

Table of Contents

How to Use This Document

Many books and manuals on the X Window System exist, providing varying degrees of readability and usefulness. This document attempts to present the X Window System, Version 11, with an emphasis on concepts and everyday use rather than highly technical details. Throughout this document the X Window System, Version 11, will be referred to as "the X Window System" or simply "X."

The structure of this document and its exercises is intended to help you to become acquainted with X. When beginning to read this document, keep in mind the following advice: you may find it helpful to read through a section, and then go back and do the exercises.

Section 1 presents an overview of X and introduces some important terms.

Section 2 covers the basics required to start and end an X session and to use the mouse.

Section 3 explains the Tab Window Manager's (TWM) functions and its menus.

Section 4 gives a brief description of the terminal window, and it lists the various options available through it. The remainder of this document is not essential to working with X.

Section 5 discusses the advanced topic of remote processes. You may find it useful if you wish to display work from more than one computer at a time.

Appendix A lists other sources for more information on X and related software.

Although this document covers X in general, naturally many of the examples will be specific to the implementations of X on networks maintained by Information Systems (such as Owlnet and the Rice Advanced Visualization Lab).

Finally, this document includes several references to the UNIX (UNIX is a registered trademark of AT&T Bell Laboratories) operating system. For more information about UNIX, see the Information Systems document UNIX 1, Introduction to the UNIX Operating System.

Good luck!

The X Window System

This section describes X's features and limitations. Some of the details may seem tedious at first, but understanding the concepts presented here will facilitate learning more about X.

Background

Developed at the Massachusetts Institute of Technology in 1984, X provides a graphics- window system for computer networks. Every computer network requires a system that will allow users to communicate with it. X provides such a system and employs graphics windows as its foundation. Each graphics window represents a particular application, such as a text editor, a debugger, an electronic mail manager, or a terminal emulator. X lets you open multiple windows and run several applications simultaneously.

The activity within one window executes independently of the activity in the other windows. For example, you can compile a FORTRAN program in one window, read electronic mail in another, run a clock in a third, and run a text editing program in a fourth window. This feature makes X very powerful because you can access many different applications---even different computers---from a single terminal; you simply open new windows as needed.

First, and foremost, however, X is a windowing system, not a complete operating system. UNIX is an operating system. See the Information Systems document Introduction to the UNIX Operating System for more information on UNIX. X mediates the communication between individuals and a computer network. X creates windows that represent applications, but does not execute the applications itself. In the current Information Systems (IS hereafter) configuration, applications most often run on computers separate from an individual's computer terminal.

You can tailor X to suit your needs. For example, you can tell X to run certain applications automatically each time you start an X session. That saves you the trouble of starting them manually every time you log in.

Basic X Terms

As with most technical environments, X has its own special jargon. You should understand some basic terms. More detailed definitions of these terms can be found in the references listed at the end of this document.

Display Servers, Hosts, and Clients

As mentioned in the preceding section, applications do not necessarily run on the terminal where you are working. Your computer terminal is called a display server, and applications are called clients. The computers which actually execute your clients are called hosts (they are also known as compute servers).

As an example, the Owlnet Sun 3/50 workstations act purely as X display servers. In these cases, any clients you start are not executing on your computer. X directs your input to a host and directs output to your display server. On Owlnet, your clients actually execute on one of the Sun SPARCstations named arcadien, barred, boreal, elf, hawk, spotted, and so on.

If the term "client" causes confusion, you can substitute "application" if that makes X concepts easier to understand. Similarly, "terminal" can be substituted for "display server."

Screens and Displays

One common stumbling block arises because an X "screen" and "display" are not equivalent terms. A display corresponds most closely to the video monitor. A single monitor never has more than one display. It is possible for some displays to support more than one screen. When this occurs on a single monitor, moving the cursor past the right or left edge of the monitor will cause the second screen to appear on that monitor instead of the first. It is also possible to have two monitors serve as different screens for the same display, in which case moving the cursor off the right side of one monitor would have it appear on the left side of the other!

For example, one display might use two screens to display a very wide Mercator map of the world. This could be accomplished using one monitor or two. Some machines have a single physical video monitor (and a single display) but that display has two screens: a black-and-white screen and a separate color screen.

Windows and Icons

"Window" is probably a familiar term. A window is an enclosed area (usually a rectangle) that represents a particular client and displays your interaction with that client. Title bars and icons are functions of the Window Manager. For different clients, activity within each window proceeds independently of activity in other windows. Some clients have multiple windows that interact with each other. With the exception of some paginators, windows can be moved and resized without affecting the execution of their clients. Overlapping windows do not affect each other.

One special window is the root window, which forms the background of the display. Inside the root window you can perform window management functions rather than ordinary input and output with a window.

Windows can also be represented by icons. Icons are small rectangular symbols used to keep many clients from cluttering the screen. Generally, you cannot send input to a client's icon. First you must de-iconify the icon to convert the icon into a window; then you may send input to that client. After completing input, you can iconify the window to convert it into an icon. A client will continue to execute when in its iconic form. For example, you can open a window, enter the input to run a program, and iconify the window. At some later time you can de-iconify the icon to view the program's output.

Pointing Devices and Cursors

Usually you employ a pointing device like a mouse in X. The section "Using the Mouse" explains how to use a mouse, graphics tablet, or light pen to perform most window operations. These operations include opening windows, selecting text within windows, moving icons and windows, and viewing menus.

The cursor lets you know where the pointing device is pointing on the screen. The cursor may be an arrow, an `X,' or some other symbol. Depending on the pointing device's target, the mouse buttons may invoke different operations. The cursor symbol usually changes to indicate these changing targets. For example, in the body of most windows the cursor is an I-beam, on the title bar the cursor is an arrow, and on the root window the default cursor is an `X.'

Window Managers

To enable window operations, X runs a client called a window manager. The window manager handles local operations like moving, resizing, and iconifying windows. The window manager handles the appearance and manipulation of windows while X supervises communication between windows, applications, and input/output devices (like the monitor keyboardl).

The window manager is a special client of the X server. It is the only client with the ability to move, resize, map, unmap, iconify, and deiconify windows. The window manager normally has no windows itself, with the exception of the menu windows the user can summon. It is possible to run an X session without using a window manager, but parts of windows hidden under other windows would be inaccessible.

Several different window managers exist, and each user can choose his or her own window manager. However, you can only use one window manager at a time. For example, suppose there are two window managers available: the Tab and Motif Window Managers. Now when you log on, you may use either the Tab or the Motif Window Manager, but not both.

A later section discusses the Tab Window Manager in detail.

Part of customizing X is changing your default window manager behavior to produce a display that suits your own needs. (See the separate Information Systems Document Customizing X for information on altering the default X environment and customizing TWM.) Other window managers include the "Motif Window Manager" (mwm), the "OPEN LOOK Window Manager" (olwm), and the Silicon Graphics Window Manager (4Dwm) used on the SGIs in RAVL and Fondren Library.

Working in an X Session

Starting X

The X display server is responsible for displaying the information sent to it by X clients (applications) running on the hosts it is connected to. Sometimes, the same machine that is running the X server will also be running all of the application processes as well (this is the case for the Rice UNIX Facility), but more often the machine that functions as the X server is only responsible for displaying the graphics output---the applications it displays are run elsewhere (about half of Owlnet is configured this way).

Starting X from a Dedicated Display Server

Almost half of the UNIX machines administered by Information Systems serve as dedicated X display servers. Therefore you only need to enter your userid and password to begin an X session. When X is ready for you to begin a session, the display shows a large rectangle centered over a gray background. The rectangle looks like the figure below.

A blinking vertical line represents the text cursor. The cursor should stand to the right of the Login: prompt. If not, press RETURN until it does. (The "Login failed, please try again." message may appear but you can ignore it.) Type your userid, then press RETURN. The cursor moves to the Password: prompt. Type your password; it will not be displayed as you type to prevent other people from learning it. Then press RETURN.

If you have entered a valid userid and corresponding password, the display changes and brings up a system announcements dialog box. This box displays recent important systems notices, and it has a HELP button and a GO AWAY button.

For help on your system (be it Owlnet, the Rice UNIX Facility, or some other), move the cursor onto the HELP button, and click a mouse button. Otherwise, click on the GO AWAY button to make the system announcements box disappear and begin the X session.

If you mistyped your userid or password, the message "Login failed, please try again." appears. You can enter your userid and password again.

Sometimes you will find a Sun with a completely blank screen, displaying nothing. Three explanations for this condition exist.

  1. The screen saver is in effect. Move the mouse or start typing your userid, and the screen should change to the normal X startup display. (Note: A blank screen prevents phosphor burn-in. If a screen displays the same image for an extended period of time, that image may burn the phosphor coating on the inside of the monitor and leave a permanent "ghost" image on the monitor.)
  2. Someone has locked the screen. If you move the mouse or type, the following message will appear: "This screen has been locked by: userid."
  3. The display server is down. It may have been turned off due to a power failure, a network upgrade, or system maintenance. Regardless, Information Systems had a good reason to deactivate it. Do not try to turn on the display server.

Starting X from a Workstation

Many of the workstations administered by Information Systems are not dedicated X computers (such as the SPARCstations on Owlnet in Ryon 102). On these machines you need to start X yourself. When the machine is idle, it displays one of these two messages:

"Wahoo" is the name of the computer. Unless you are on the machine "wahoo," another name (the name of the machine you are on) will appear everywhere "wahoo" appears in this section.

If the computer displays the first message, type CTRL-C, (see the section, Special Keys, for information on the CTRL key) and the second message appears.

At the wahoo login: message, enter your userid, then password. The display changes to a text-only welcome message, and shortly the prompt wahoo% appears at the bottom of the display.

Enter startx to begin the X session. On these terminals, after you end the X session you will have the option to remain logged on by pressing CTRL-C within three seconds after exiting. If you press CTRL-C, the X windows and background vanish, returning you to a text-only display. At the prompt wahoo% (recall that "wahoo" is just a single computer name; your computer name may be different), enter exit to log out.

Exercise 1: Try logging in and starting an X session as explained in this section. Once you begin a session, you can try the other exercises throughout this document.

The Console Window

Once you have started an X session, a small window labelled "Console (exit me to quit X)" appears in the upper left-hand corner of the display. Normally you do not work in the window, but network notices and error messages appear here while you work. If your terminal freezes or beeps (signalling an error), you may find an explanation in the window. Observe that the window has a scroll bar so that you can review messages which have scrolled out of view. Typing exit in this window will terminate your X session.

Special Keys: SHIFT, CTRL, and META

Most computer keyboards have special keys in addition to the normal SHIFT key. Two such keys are the CTRL (or CONTROL) and META keys. The CTRL and META keys perform similarly to the SHIFT key, except that they generate different signals to your computer.

For example, to type `CTRL-C' you hold down the CTRL key and press C. While this action is analogous to typing `SHIFT-C' to generate a capital C, the computer interprets `CTRL-C' as an entirely different character than `C.'

Most keyboards have SHIFT and CTRL keys, but the META key may not be obvious. The table below lists the META key depending on your computer terminal.

TABLE 1: META Key Assignments


 
Terminal Type                       Keyboard Key(s)    
Sun 3/50, Sun 3/110                 "Left" or "Right"  
Sun SPARCstation                    Diamond () oρ EΣ×  
Silicon Graphics Indigos and Indys  Diamond () oρ EΣ×  
IBM XStation                        "Alt"  

Using the Mouse

Mouse Motion and the Display

Moving the mouse moves the cursor on the display. With most window managers, moving the cursor into a window's borders shifts the input focus to that window. However, with some managers (specifically, mwm) the default settings require you to click a mouse button in the new window in order to shift the input focus to that window. When the focus has been shifted, the window's border and title bar (if these features are present in that manager) become highlighted, and if the window contains a text cursor, the text cursor changes into a solid rectangle. Similarly, placing or clicking the cursor on an icon activates the icon.

You will observe that the shape of the cursor changes depending upon where the cursor lies. These shapes indicate that different functions have become available. The section, The Tab Window Manager, explains what the functions do and how to execute them. Some cursor examples follow; these are the defaults and the user may change them.

Mouse Buttons

Normally the mouse has one or more buttons that initiate different X and TWM functions. Most mice have three buttons---one each on the left, middle, and right. LEFT, MIDDLE, and RIGHT refer to the respective mouse buttons.

Clicking and Dragging

Some functions require that you select a window or icon. You move the cursor over the desired symbol, then press and release a mouse button. This action is called clicking. Other functions require that you specify a window's location or select a range of text. To move a window, you click on the window's title bar but continue to hold down the mouse button. Still holding down the mouse button, you move the mouse to move or shape the window. Similarly, you click on one end of the text you want, then move the mouse while holding down the mouse button. The action of moving the mouse while holding down a mouse button is called dragging.

Read the section, Window Operations without Menus, for a list of the mouse-selectable operations available.

Menu Item Selection

TWM has two standard menus (see the section, Standard Menus, for a description of the menus): a function menu and an application menu. You activate a menu by placing the cursor on the root window and pressing and holding the appropriate mouse button. A menu appears, and the cursor becomes a horizontal arrow, indicating that TWM is expecting you to select an item from the menu.

To select an item, move the cursor (you must hold down the mouse button) onto the menu and highlight the desired menu item. Releasing the mouse button with the cursor in place selects the item.

To drop the menu without selecting any item, move the cursor off the menu so that no menu items are highlighted. Release the mouse button, and the menu vanishes without selecting an item.

Exercise 2. For some of the next exercises, you will need to open a window using the text editor of your choice. Move the cursor onto the root window (the background), and the cursor shows an `X.'
Press and hold RIGHT. A menu titled "X Applications" appears, and the cursor becomes a horizontal arrow. Move the arrow onto the editor you want to use and it becomes highlighted.

Release the button to finish the menu selection. After a moment, a window frame appears. Position the window where you want it, then press LEFT or MIDDLE.

Exercise 3. Make another window, but this time suppose you want it to stretch to the bottom of the display. To do so, follow the same steps as in the previous window, but at the last step, press RIGHT instead of LEFT or MIDDLE. You have made a maximum height window.

Terminate one of the editor windows (your choice) by moving the cursor over its "Quit" button (or box). Click to terminate the window.

Selecting Text

Using the mouse, you can copy, paste, and delete segments of text. You can select text by character, by word, or by line. Notice that as soon as you select text, X automatically copies it to temporary storage. That is, with X the select and copy operations are one and the same. Two methods let you make a selection:

Selection of one character, word, or one line (clicking):

Selection of one character, word, or line (dragging):

Selection of a large area of text quickly, by character, word, or line:

Exercise 4. Before you can select text, you must have text to select. Go to your xterm window and enter (using a capital `X' as indicated):
This command will bring up pages and pages of information about X. After the first screenful appears, the paginator waits for you to press a key. Type q to discontinue the printout. Now you have some text with which to practice.
Exercise 5. Selecting by Character. Put the cursor at the start of the line "X Window System is a..." (near the middle of the xterm). Press and hold LEFT. Drag the mouse and observe that you can select text one character at a time. Release LEFT to finish the selection.

Now click LEFT inside the word "Consortium," move the mouse inside the word "following," and click RIGHT. Notice the new selection of the characters between the two clicks. Move the mouse again, click RIGHT, and observe how the character selection changes.

Exercise 6. Selecting by Word. Place the I-beam cursor over the word "portable," then click LEFT twice. Notice that the word "portable" becomes highlighted; you have selected a word.

Now put the cursor over "The" in the sentence "The X Window System..." Click LEFT twice, but continue to hold LEFT down after the second click. Move the cursor along the rest of the sentence, and observe that you select words as the cursor moves.

Finally, put the cursor over "developed" and click LEFT twice. Move the cursor to the word "machines" and click RIGHT to make your selection. Move the cursor to other parts of the xterm, click RIGHT and watch how the selection changes by word.

Exercise 7. Selecting by Line. Put the cursor on the line "X Window System is a..." and click LEFT three times in rapid succession. You select the entire line of text.

Move to the line "It should be relatively..." and again click LEFT three times, but hold LEFT down after the third click. Now slide the mouse up and down, selecting text by line. Release LEFT after making a selection. Go to the line "X Consortium..." and click LEFT three times. Now move to the line "X Window System..." and click RIGHT. Witness the selected lines. Try clicking RIGHT elsewhere in the window, and see how the selection of lines changes.

Exercise 8. Practice all three methods of text selection (by character, by word, and by line). Also practice using just LEFT to select the range, and using LEFT and RIGHT to select the range.

Copying, Pasting, and Cutting

When you select text, you automatically copy the text into temporary storage, which you can retrieve for pasting later. Note, however, that you can only retrieve the most recent selection.

For example, if you select the sentence "Six and nine are fifteen," then "Six and nine are fifteen" enters temporary storage. If you then select "How's the weather?" this new selection replaces "Six and nine are fifteen" in temporary storage. Now if you paste text, you will paste "How's the weather?"

Because of this feature, you need to be careful not to mistakenly select text. If you select the sentence "The dog ran quickly," but then accidentally press the mouse buttons and highlight other text, that other text replaces "The dog ran quickly" in temporary storage, and you must re-select "The dog ran quickly."

Once you have copied a selection, you can paste it elsewhere (including a different window). To paste the selection, move the cursor to the desired insertion point, then press MIDDLE.

Exercise 9. Copy and Paste. You should have a text editing window open already. If not, open one from the X Applications Menu. Now, inside the xterm, select the text between the sections headed "SYNOPSIS" and "DESCRIPTION." Go to the bottom text-entry area in the window and press MIDDLE. The selected text appears in the window. You have copied and pasted the text from the xterm to the text editing window.

Copy and Paste Again. Within the window, select the word "relatively." Place the cursor elsewhere in the text-entry area, and click LEFT once to mark the new insertion point. Now click MIDDLE and notice where "relatively" is pasted into the text.
Sometimes you will want to move or remove the selected text rather than copy it. To cut text, select it and then type CTRL-W. The highlighted text vanishes, but it has also been copied to temporary storage so that you can paste it if you like. Note, however, that not all X clients permit cutting.

Exercise 10. Cut and Paste. Inside the editor window, select the line "UNIX(tm) System V..." Then type CTRL-W to cut the line. Move the cursor to where you want to paste the line, click LEFT, and then click MIDDLE to paste it.

Now move to the xterm and select the line "Ultrix 3.1 (Digital)." Type CTRL-W, but notice that the client does not let you cut text. Go back to the window and click MIDDLE; the line "Ultrix 3.1(Digital)" appears. You copied the line by selecting it but were unable to cut it. Remember that selecting text automatically copies it into temporary storage, but not all clients support cutting.

Special Keys and the Mouse

Some functions require that you hold down one or two special keys as you press a mouse button. Recall that the special keys are the SHIFT, CTRL, and META keys. For example, to use the SHIFT- combination, hold down the SHIFT key and press the middle mouse button.

Exercise 11. Put the cursor over a window and press RIGHT. You may see X highlight a text selection, but ignore it.

Press META-RIGHT (while holding down the META key, press and hold RIGHT; you can then release the META key.) The TWM Window Manager Menu appears. You have just used a special key (META) with the mouse. Deactivate the menu by not highlighting any of its items, then releasing the mouse button.

The Scrollbar

When a window cannot display all the information it contains, a scrollbar lets you select a region of the information to inspect. The next exercises explain the scrollbar.

Exercise 12. Prepare the Scrollbar. Move to an xterm and enter the following (using a capital `X'):

Press the spacebar the next few times you see the message:
to let a few pages of text run through the window. Then type q to stop the printout. With the mouse on the X window, press CTRL-MIDDLE and select Enable Scrollbar from the VT Options Menu which will appear. A scrollbar materializes on the left side of the xterm.

Exercise 13. Use the Scrollbar. The scrollbar uses a gray rectangle (the "thumb") to indicate what part of the information is being displayed. Put the cursor over the scrollbar, and the cursor becomes a two-pointed arrow. Click RIGHT a few times and notice how the text and thumb scroll backward. Then click LEFT. Now place the two-pointed arrow anywhere on the scrollbar and click MIDDLE. Try pressing and holding MIDDLE, then dragging while holding down MIDDLE. The scroll area slides up and down as you drag the mouse.

Ending an X Session

When you finish working on a computer, you log out. The Information Systems X environment provides two ways to log out. To log out normally, you can:

You should always try to quit applications you have started during your session before exiting X, especially editors. This both reduces the chance of processes you have started continuing to run after you have logged out and also reduces the chance of losing data (due to unsaved files, etc.). Applications that cannot be easily quit (such as the clock and mailbox that come up in the default X session) can be left for the X server to clean up when it shuts down (or resets).

Important Note: If you used the startx command to start the X session (if you are working on a Sun workstation, for example), after you end the X session you will have the option to remain logged on by pressing CTRL-C within three seconds after exiting. Doing so will cause the X windows and background vanish, returning you to a text-only display. At the prompt wahoo% (recall that "wahoo" is just a single computer name; your computer name may be different), enter exit to log out.

If these methods do not work, consult the section Introduction to the UNIX Operating System in the Owlnet Notes, see the Information Systems Document Introduction to the UNIX Operating System, or speak to a consultant in the Consulting Center, 103 Mudd Lab, or call 527-4983.

For More Information: Manual Pages

This document does not provide a complete description of every X command, option, or feature. A group of on-line references provide further detail into these topics, albeit in a more technical vein. You may want to consult these references, called the manual pages (or simply "man pages"). While the Information Systems document Introduction to the Unix Operating System covers them in greater detail, general methods of reaching the manual pages appear below.

Go to an xterm and enter

man command

where command is the command you want to investigate (such as xcalc, xclock, etc.). UNIX will search for the appropriate manual pages and let you view them.

Alternatively, you can view formatted (text with italics, boldface, etc.) manual pages by selecting Manual pages from the X Applications Menu. After a moment, a small dialog box appears. Click on either of the oval command buttons labelled Manual Page or Help. Either button brings up a corresponding window. From the Manual Page window, you can click on the Options display button for a menu. Select Display Directory to see a list of the available commands. You can then use the scrollbar to view the commands, and click LEFT on a command you want to investigate.

Exit the formatted manual pages with the Quit button.

Call up the formatted manual pages from an xterm with:

xman &

This command is identical to selecting Manual pages from the X Applications Menu.

Exercise 14. Try calling up the regular manual pages. Go to an xterm and enter:

This command tells you more about the manual pages (you are referencing the manual pages on the man command). Press the spacebar to see the next page of information, press RETURN to see the next line, or press `q' (the `Q'-key) to stop the printout. If you like, try entering:
for more information (perhaps more than you want) on X and TWM.

Exercise 15. Call up the formatted manual pages from the X Applications Menu. Click on Help if you like. When ready to investigate some commands, click on Manual Page. Browse through the Directory and read about some commands (xterm or maze, for example). Use the Quit button when you have finished.

The Tab Window Manager (TWM)

As the section, Window Managers, explains, X may use a window manager, which controls functions like moving, resizing, and iconifying windows. Several different window managers exist, but recall that you can use only one window manager at a time. IS-administered machines use the Tab Window Manager, or TWM, almost exclusively, and this section describes TWM in its normal configuration. Hence, this section assumes you are running X and TWM, and it assumes that you have not customized X or TWM. For information on customizing X and TWM, see the separate IS document Customizing the X Window System.

TWM Elements

Windows

TWM's windows are rectangles, and each window has several regions which serve different functions. Not every window will have all the regions described here.

Body
The largest region of the window, the body is usually an area devoted to text or graphics. Interaction with the client occurs within the body of a window. Frequently text body will have a small text cursor to indicate where characters you type will appear.
Command Button
An area on the display that executes an operation when the mouse clicks over it. For example, the system announcements box has HELP and GO AWAY command buttons.
Root Window
The root window forms the background of the display. When the cursor does not lie within any icon, window, or title bar, the cursor lies within the root window.
Scroll Bar
A scroll bar rests along the left side or bottom edge of a window. If a window contains more information than the body can display, a scroll bar lets you select the area to be displayed.
Title Bar
Positioned across the top of a window, the title bar describes the window's client. For example, the console window has a title bar which reads, Console (exit me to quit X).
Title Bar Button
Some small boxes may appear inside the title bar; these boxes are title bar buttons. Note that title bar buttons are not physical buttons on the mouse or keyboard. Title bar buttons appear only on the display. Clicking on a title bar button executes a TWM function associated with it.

Icons

To prevent your display from becoming cluttered by many windows, a window can be converted into an icon. An icon is a small symbol which replaces the window. A client will continue to run in its icon form, but to send input to that client, you must convert the icon back to a window. You could run a program inside an xterm, iconify the xterm and de-iconify the icon later to see the program's output.

Cursors

TWM displays several different cursor pictures. Some cursors include the root window `X,' an arrow, and a pointing index finger. Individual X clients may also have different cursors. For example, the I-beam in an xterm and the up-down arrows when you are in the scrollbar area are functions of the client, not the window manager.

Standard Menus

This section introduces the two standard menus that the default implementation of TWM provides. Menus list X and TWM items in an easily accessible manner. You select an item from a menu as explained in the section, Menu Item Selection. Such items include:

The contents of the standard menus are listed below.

The TWM Window Manager Menu

From the TWM Window Manager Menu you can execute almost any window operation. To activate this menu,

or
Since many functions operate on windows and icons, the term symbol will refer to a window or an icon. The functions are described below.

Refresh
Redraws the entire display, including all icons and windows. When many windows are open, TWM may not update the display properly. The refresh function corrects most display errors.
Focus
Directs all input to the selected window, regardless of the cursor position. You can move the cursor off the window but still type to it.
Unfocus
This resets the input focus back to pointer-driven. The mouse must be over the window for it to be active.
(De)Iconify
Converts a window into an icon or converts an icon into a window. The cursor becomes a large dot. First you place the dot over the desired symbol, then click the mouse to execute the (de)iconify function.
Move
Moves a window or an icon. The cursor becomes a cross-arrow, and you should place the cursor over the desired symbol. Then by dragging the mouse, you will move the symbol to the desired location. Releasing the button completes the function.
Resize
Changes the rectangular area of a symbol. As with the move function, the cursor becomes a cross-arrow which you place over the desired symbol. Dragging specifies the new rectangle size, and releasing the button completes the resize function.
Bring to front
Given several overlapped symbols, brings the selected symbol to the front. With the large dot cursor, you click on the desired symbol.
Send to back
The opposite of the bring to front function.
Delete Window
Terminates the client---represented by a symbol. This is a relatively clean way to exit a client that doesn't take any keyboard input, such as the clock, or a graphics window of an application.
Kill window
Terminates the client represented by a symbol. This function provides an inelegant, messy way of exiting a client; first you should try to terminate the client normally. Usually you execute the Kill window function when a client freezes and remains unresponsive to any input. See the Information Systems document Introduction to the UNIX Operating System for more information on killing processes.
Lock screen
Brings up a blank screen and waits for you to enter your password before the X session continues. Clients continue running while the screen is locked. The lock screen function allows you to leave the display server for roughly twenty minutes; after this time the lock screen program automatically logs you out.
Source .twmrc
Instructs TWM to read the .twmrc configuration file. Normally you do not need this option unless you are testing a TWM customization. For information on customizing TWM, see the Information Systems document Customizing the X Window System. Executing it without changing .twmrc will refresh the display, though much more slowly than executing the refresh function.
Kill twm
Stops TWM. X and its windows continue to operate, but most window functions (like those in this menu) become unavailable. If you have badly customized TWM, you may want to stop it with this menu item. It is important that the console window be open and uncovered when this option is selected, otherwise it will be extremely difficult to exit the X session!
Exit X-windows
Terminates an X session and logs you out. Normally you should enter exit from your console instead of this function.
Exercise 1. Try using the Move and Resize functions. Move your xterm so that it overlaps your mailbox and analog clock (both in the upper-right corner of your display). Use Bring to front and Send to back on these three clients. Try (De)Iconify on the analog clock.

The X Applications Menu

The X Applications Menu lets you begin many X clients without having to type lengthy commands in a window. To call up the X Applications Menu, move the cursor onto the root window and press RIGHT.

Some applications---such as GNU Emacs, Matlab, or Mosaic---have separate documentation available. Check the Owlnet Notes or the Consulting Center for Information Systems documents. The applications are described very briefly below.

Text Editors

Engineering Apps
News Readers
Mail Readers
Utilities
Manual pages
On-line reference manual for network commands, programming languages, and other network features. The manual pages, or simply "man pages," are a reference and may not provide adequate help. If you need more help, visit the Consulting Center or send electronic mail to consult@rice.edu.
Preferences
This item activates a submenu (indicated by the box) with some local characteristics you can change: turn the computer bell (beep) on or off, and set mouse movement speed.
Mosaic
A graphically-oriented browser for the World Wide Web.
Owlnet Policy
A Mosaic screen with some notes on Polices for Owlnet Users.
Help
A Mosaic screen with helpful tips on some Owlnet programs.
Lock screen
Same as Lock screen from the TWM Window Manager Menu.

Window Operations without Menus

Several frequently-used TWM window functions can be executed without activating the TWM function menu. You execute these functions by moving the cursor to a window region (body, title bar, etc.) and then pressing the appropriate mouse/special key combination.

TABLE 2: Executing TWM Functions with the Mouse/Special Keys (Continued) 
--------------------------------------------------------------------------
Cursor                Special   Mouse Button                                
Location              Keys      LEFT            MIDDLE        RIGHT         
Root Window                     Circle up(a)    TWM Menu      X Appl.       
                                                              Menu          
Title Bar                       Bring to front  Move          Send to back  
Left Title Bar                  Iconify         Iconify       Iconify       
Button                                                                      
Right Title Bar                 Resize          Resize        Resize        
Button                                                                      
Title Bar or Win      META      Bring to front  Send to back  TWM Menu      
dow Body                                                                    
Icon                            De-iconify      Move          ---           
Title Bar, Icon, or   META-     ---             ---           Kill window   
Window Body           SHIFT(b)                                              
--------------------------------------------------------------------------
(a)
"Circle up" cycles through overlapping icons and windows. Each time you circle up, TWM brings the next occluded icon or window to the front.
(b)
Hold down the META and SHIFT keys, and press RIGHT.
Exercise 2. Try some of these menu-free functions. Move your xterm to overlap your mailbox and analog clock. Then execute the Circle up function a few times by clicking LEFT with the `X' cursor resting on the root window (the background).

The xterm Terminal Emulator

Background

The xterm terminal emulator is a particularly useful X client. As the name implies, a terminal emulator emulates, or simulates, a computer terminal display. Many different types of computer terminals exist, and each handles video information differently. These many terminals can create severe display incompatibilities because one computer's normal output may not fit another terminal's display protocol.

To overcome these potential problems, X offers xterm, which is available from the X Applications Menu. Xterm simulates two widely available industry-standard terminals: the VT102 and Tektronix 4010 terminals. Normally the VT102 displays text, and the Tektronix 4010 displays graphics. Only one of these modes is active at a time, though both may be mapped on the screen simultaneously.

VT102 (VT) Mode

The VT102, or VT, window treats its contents as text characters and its body as a terminal screen. These properties make it suitable for most work. Operations like backspacing, clearing the screen, and copying text with the mouse function properly. For these reasons, windows open in VT mode by default.

Tektronix 4010 (Tek) Mode

Because the Tektronix 4010, or Tek, window displays its contents as graphics, its display behaves differently from the VT window. The Tek window considers everything as a group of dots to be plotted. Thus, it treats text input and output as dots, not characters, and normal text operations do not function normally.

Backspacing does not erase characters on the screen (although the computer processes the backspace properly), and characters typed over one another simply print on top of each other, creating a messy jumble. Changing font size does not resize the window (as occurs with the VT window), but subsequent characters appear in the new size. Normal screen-clearing commands do not work, and you cannot select text with the mouse.

The Shell in xterm

Though powerful, xterm in VT102 mode is only a medium for the display of text output; it does not execute commands itself. Instead, xterm calls a shell, which is a program that does all the talking between the xterm and the operating system. It is the shell that makes a true terminal emulator---each shell is a separate command environment. When the shell is exited, xterm also exits. There are many shell varieties; the most popular are the C shell and the Bourne shell. On IS-administered machines, the C shell is exclusively the default. More information is available on shells in the Information Systems Document, Introduction to the UNIX Operating System.

xterm Window Menus

Four different xterm menus let you modify various characteristics of an xterm window. These characteristics include font size, scrollbars, and reverse video (white-on-black). To call up the appropriate menu, use the following table.

TABLE 3: Calling Up Xterm Window Menus 
--------------------------------------------------
xterm Menu    Mouse        Cursor Location          
--------------------------------------------------
Main Options  CTRL-LEFT    Over a VT or Tek window  
VT Options    CTRL-MIDDLE  Over a VT window         
VT Fonts      CTRL-RIGHT   Over a VT window         
Tek Options   CTRL-MIDDLE  Over a Tek window        
                                                    
--------------------------------------------------

Main Options

You can activate this menu from either a VT or a Tek window, but normally you will not need to use any of the options.

TABLE 4: Main Options Menu 
-------------------------------------------------------------------------------------
Menu Item                          Action                                              
-------------------------------------------------------------------------------------
Secure keyboard                    All keystrokes are sent to this xterm.              
Allow SendEvents                   Allows events to be sent to an xterm.               
Log to File                        Logs all input and output in the window to a file.  
Redraw Window                      Redraws the window contents.                        
Send STOP Signal                   Suspends the current process.                       
Send CONT Signal                   Continues a stopped process.                        
Send INT Signal                    Interrupts a process.                               
Send HUP Signal                    Hangs up the process and kills the xterm.           
Send TERM Signal                   Teminates the process without killing the xterm.    
Send KILL Signal                   Kills xterm and all processes running in xterm.     
Quit                               Kills the xterm.                                    
                                                                                       
-------------------------------------------------------------------------------------

VT Options

Available if a VT window is displayed, this menu contains three sections, separated by a horizontal line. The upper section lists the available VT display options. The middle section offers two window reset commands, and the lower section activates the Tek window.

From the upper section you can toggle (turn on or off) many window characteristics. If an option is in effect, a check mark appears next to it. You toggle an option by highlighting it with the mouse and releasing the mouse button (just like normal menu item selection). The different options are listed below, with explanations as appropriate.

TABLE 5: VT Options Menu (Continued) 
-----------------------------------------------------------------------------------------------
Menu Item                          Action                                                        
-----------------------------------------------------------------------------------------------
Enable Scrollbar                   Turns on the scrollbar.                                       
Enable Jump Scroll                 Makes the window move text several lines at a time            
                                   instead of one line at a time.                                
Enable ReverseVideo                Displays white on a black background rather than black-       
                                   on-white.                                                     
Enable Auto Wraparound             Wraps text which would run off the right margin onto          
                                   the next line.                                                
Enable Auto Linefeed               Adds a linefeed character after a carriage-return             
                                   (RETURN) character. UNIX terminals do not need this           
                                   toggle.                                                       
Enable Application Cursor          Activates cursor keys, but they may not perform as            
Keys                               expected if an application does not use them.                 
Enable Application Keypad          Activates keypad, but it may not perform as expected if       
                                   an application does not exist.                                
Scroll to Bottom on Key            Makes the window jump to the bottom when you type.            
Press                                                                                            
Scroll to Bottom on tty Out        Makes the window jump to the bottom when new output           
put                                appears.                                                      
Allow 80/132 Column                Permits some applications to switch between 80 and            
Switching                          132 character width.                                          
Enable Cursor Emulation            Corrects a VT bug that only affects some applications.        
                                   You probably do not need this option.                         
Enable Visual Bell                 Flashes the window once instead of sounding your ter          
                                   minal bell (beep).                                            
Enable Margin Bell                 Sounds bell (beeps) when typed input approaches the           
                                   right margin.                                                 
Show Alternate Screen              Indicates if you are looking at an alternate screen. You      
                                   cannot toggle it yourself.                                    
Do Soft Reset                      Corrects scrolling if a program failed to reset it properly.  
Do Full Reset                      Clears VT window, and returns VT Options to their             
                                   original settings.                                            
Reset and Clear Saved Lines        Clears lines saved in the scroll buffer and resets the        
                                   scrollbar thumb.                                              
Show Tek Window                    Makes the Tek window visible.                                 
Switch to Tek Mode                 Makes the Tek window active (input and output now             
                                   occur in the Tek window, not the VT window).                  
Hide VT Window                     Makes the VT window vanish, automatically switches            
                                   to the Tek window and Tek mode.                               
                                                                                                 
-----------------------------------------------------------------------------------------------
Exercise 1. Go to your xterm and activate the VT Options menu with CTRL-MIDDLE. Toggle the Enable Scrollbar Option. Then toggle the Enable Reverse Video Option. If you like, toggle them back (off).

VT Fonts

A VT window must be displayed before you can select the font size. Most options are self-explanatory, although the Default font makes the font return to the size specified when the window opened. Changing the font size changes the window size because the VT window alters its size to fit the font.

TABLE 6: VT Fonts Menu 
--------------------------------------------------------------------
Menu Item                       Action                                
--------------------------------------------------------------------
Default                         Selects the starting xterm font size  
Tiny                            Selects VT font size                  
Small                           Selects VT font size                  
Medium                          Selects VT font size                  
Large                           Selects VT font size                  
                                                                      
--------------------------------------------------------------------
Exercise 2. Call up the VT Fonts menu with CTRL-RIGHT. Select the font Small. Then select Large, then Tiny, and finally Default. Notice that each time you change fonts, the window size changes, and the window is redrawn.

Tek Options

The Tek Options menu only appears if you have a Tek window open. The menu contains three sections: font size, window commands, and Tek/VT selection.

TABLE 7: Tek Options Menu 
----------------------------------------------------------------------------------------
Menu Item                           Action                                                
----------------------------------------------------------------------------------------
Large Characters                    Selects Tek font size.                                
#2 Size Characters                  Selects Tek font size.                                
#3 Size Characters                  Selects Tek font size.                                
Small Characters                    Selects Tek font size.                                
PAGE                                Clears Tek Window.                                    
RESET                               Clears Tek Window.                                    
COPY                                Disabled. (Normally it writes a file of the Tek com   
                                    mands you have issued.)                               
Show VT Window                      Makes the VT window visible.                          
Switch to VT Mode                   Makes the VT window active (input and output now      
                                    occur in the VT window, not the Tek window).          
Hide Tek Window                     Makes the Tek window vanish, automatically switches   
                                    to the VT window and VT mode.                         
----------------------------------------------------------------------------------------

Remote Processes (Clients)

Recall that clients do not have to run on the same computer as your display server. Such clients are often called remote processes. Normally when you log in, X displays your windows on your terminal with no difficulty. In some cases, however, you need to tell X where it should display information.

The DISPLAY Environment Variable

This section explains how to tell X your display destination. UNIX maintains a group of system variables called the environment. A simplified explanation is that your environment includes items like your userid, your host computer, and other information that UNIX needs to coordinate your activities.

One environment variable, DISPLAY, indicates to clients where to connect to your X server. X looks for DISPLAY so it can direct graphics to you.

Each DISPLAY variable has the following form:

Hostserver is the name of your display server, and it usually has the suffix .rice.edu. Display number refers to all the monitors that share a common keyboard and pointer (usually a mouse). On machines administered by IS, workstations almost always have only one keyboard, and therefore have only one display. The display number is zero (0) in this case. Screen number distinguishes one screen buffer from another for the X server. This could happen with two separate monitors or with only one. Some display servers have hardware that supports two screens on a single monitor.

For example, consider a color display server named tuna. An xterm displayed on the monochrome page has a DISPLAY of tuna.rice.edu:0.1. A different xterm which resides on the color page, has a DISPLAY of tuna.rice.edu:0.0.

On machines with only one screen it is possible to omit the screen number in the DISPLAY environment variable. In that case, the screen number is assumed to be zero.

Exercise 3. Go to your console and enter:

If you are already at the display server wahoo, you will see:
That is your DISPLAY environment variable, which tells X where to send output for your console.

Multiple Environments

Every time you open a new xterm window, you create another shell (see the section, The Shell in xterm) and thus create a new command environment. Each of these environments contains its own separate set of environment variables; changing one environment does not affect the other ones. When a new xterm is created, it inherits these environment variables from the shell under which the command to create it was executed. These variables are set and used by the operating system, programs, and the X server. More information is available on this topic in the IS document Introduction to the UNIX Operating System.

Exercise 4. Go to your console and enter:

printenv DISPLAY

Then enter the same command inside your xterm. You should see identical DISPLAY values. Note the server (including the .rice.edu). Now, still in your xterm, enter:

setenv DISPLAY server:1.2

Remember that you substitute your display's name (i.e. wahoo.owlnet.rice.edu) for server. Again enter printenv DISPLAY in the console and the xterm. Notice that the DISPLAY values differ now. To complete the exercise, reset the altered xterm's DISPLAY by entering:

setenv DISPLAY server:0.0

The rlogin Command

You will likely use the UNIX command rlogin, which stands for "remote login." With rlogin you can login to accounts you have on other computers.

For example, suppose you have a project that requires a special computer which is not included on the same network as the computer account you are currently logged in to. First you obtain an account from the administrators of this computer (usually by filling out some forms). Rather than travelling to the special computer's physical location, you can rlogin from an IS terminal.

Exercise 5. Enter an xterm and enter:

hostname

The window will return hostname, the name of your current host (wahoo, for example.) Now enter

rlogin hostname

(rlogin great-gray, for example). The xterm should display the greeting text that you see when you first login. You have just conducted a remote login.

When you rlogin from an xterm, UNIX creates a new environment inside the xterm's existing environment. However, this new environment lacks the DISPLAY variable. The absence of DISPLAY within the new environment occurs because the new environment is created purely by the UNIX system and without X's input.

Exercise 6. Inside the xterm, enter:

printenv DISPLAY

The window should return nothing except a new UNIX prompt. This new environment does not have a DISPLAY value, so it prints nothing.

For most work inside the xterm you will not encounter problems. You can still perform operations like moving between directories, copying files, using the vi text editor, and compiling and running most programs.

However, any commands that start a new X client will fail. UNIX starts the new client, but X does not know where to send the graphics, so the client fails and terminates. This mishap occurs because does not exist.

Exercise 7. Still in the current xterm, enter:

puzzle &

Nothing happens, except that you receive an error message like the one below.

puzzle: unable to open display
[1] Exit 1 puzzle


Because the new environment created by your rlogin has no DISPLAY, X does not know where to send the puzzle graphics. Now, go to your console and enter:

puzzle &

This time you should get a little pocket-puzzle window. Since your console has a DISPLAY value, X can open a window for the puzzle.

To correct this missing DISPLAY problem, you can specify a display when you start a client, or you can add DISPLAY to the environment. The following exercises show you how.

Exercise 8. Delete the puzzle (use the TWM Menu item "Delete window"), then go to your console and enter:

printenv DISPLAY

to see your DISPLAY value (i.e., if you are working at wahoo, your-DISPLAY-value is wahoo.rice.edu:0.0). Return to the rlogin-ed xterm and enter:

puzzle -display your-DISPLAY-value &

The puzzle should appear normally because you specified DISPLAY when you started the client.

Exercise 9. Delete the puzzle again. In the rlogin-ed xterm, enter

setenv DISPLAY your-DISPLAY-value

By doing so you add DISPLAY to the new environment. Now start a puzzle by entering:

puzzle &

Start another puzzle with the same command.

In Exercise 8, you indicate DISPLAY by using the -display your-DISPLAY-value option. Since you normally use only one display server, you may not want to type the
-display your-DISPLAY-value every time you start a client. Instead you can use the setenv DISPLAY your-DISPLAY-value command, as in Exercise 9, to put your display server into the new environment.

Exercise 10. To end this group of exercises, delete the puzzles. Then go to the rlogin-ed xterm and enter:

exit

Notice that the xterm window does not disappear because you only exited the rlogin-ed shell, not the xterm's inherent shell.

The xhost Command

Besides using DISPLAY to direct graphics, X has a command which lets you specify which computers can and cannot display graphics on your display server. The xhost command limits access to your display.

xhost maintains a list of allowed hosts. Adding or removing hosts from the list determines display access. However, your changes only affect subsequent display attempts. If a host is displaying a window and you then remove that host from the list, the window continues to operate normally, but the host cannot create any new windows. In other words, changing xhost does not affect existing windows, but it does affect subsequent ones.

To see this list, enter:

xhost

A message indicating whether access control is enabled appears, followed by a list of hosts. Note that your initial host (the computer to which you logged in) does not appear on this list.

Usually, you only want to permit your host computer or computers to affect your display.

To prevent a host from displaying information on your display, enter

xhost -hostname

To enable a host to display information, enter

xhost +hostname

For More Information

Hopefully this document has helped you become familiar and comfortable with X. For more information about X, consult the Consulting Center or the following sources.

There are also many news groups that concern X, the most notable being:

Many of these groups have a monthly listing of frequently asked questions (FAQ) that are quite helpful to the new and experienced X user alike.


--User Services Publications Team (pubteam@rice.edu) 1996.07.17.