O'Reilly logo

X Window System User's Guide for X11 R3 and R4 of the X Window System by Tim O'Reilly, Valerie Quercia

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

C

The OSF/Motif Window Manager

Getting Started with mwm

The Motif window manager (mwm) is one of the more popular window managers available in the X market. Developed by Ellis Cohen of the Open Software Foundation, mwm is the window manager component of OSF/Motif, OSF’s graphical user interface (GUI). mwm allows you to perform all of the standard window manipulation functions. You can:

•   Create additional xterm windows.

•   Change the size of windows.

•   Move windows around the screen.

•   Raise windows (move them to the front of others).

•   Lower windows (move them to the back of others).

•   Convert windows to icons and icons to windows.

•   Refresh your screen.

•   Remove windows.

Like twm, the Motif window manager allows you to invoke window manipulation functions in a variety of ways:

•   Using the window “frame” and various features available on it: the Minimize (iconify) button, Maximize button, title area, Window Menu, etc.

•   Using the Root Menu.

•   Using keyboard keys, pointer buttons, and key and button combinations.

mwm attempts to create a three-dimensional appearance, which is somewhat more aesthetic than the look provided by many other window managers. You’ll probably notice that window frames, various command buttons, icons, etc., appear to be raised to varying heights above screen level. This illusion is created by subtle shading and gives many display features a “beveled” look, similar to the beveled style of some mirrors.

This appendix is intended primarily for those using the default version of mwm, Release 1.0. If mwm has been customized at your site or you are running a different version, the principles should be basically the same, but the window manipulation functions may be invoked in different ways. From time to time, we’ll mention how commands or functionality might vary, depending on your version of mwm.

If you have never used a window manager before, first read Chapter 1, An Introduction to the X Window System, for a conceptual overview of what a window manager does.

In this appendix, we’ll take a look at the standard window manipulation functions provided by mwm and the wide variety of methods for invoking them. Then we’ll consider how to customize various features of mwm. Perhaps the most useful customization that can be performed involves selecting a keyboard focus policy, either pointer focus or click-to-type (referred to as explicit) focus. (Keyboard focus is described in Chapter 1, An Introduction to the X Window System.) By default, mwm uses explicit (click-to-type) focus.

First, however, let’s start with some basics: how to start mwm; and how to select the window to receive input, also known as the active window. Then we’ll take a look at perhaps the most distinguishing feature of mwm: the frame it places around all windows on the display.

Starting mwm

As described in Chapter 2, Getting Started, you can start a window manager from the command line in an xterm window. The following command line starts mwm:

% mwm &

If xdm (the display manager) or another session manager is starting X on your system, mwm is probably started automatically when you log on. If mwm is already running, all windows will be surrounded by the characteristic window frame, pictured in Figure C-1.

If mwm is not running, start it using the command line above. While mwm is starting up, the root window pointer changes to an hour glass that appears to be filling up with sand. When the hour glass is full, all windows will become framed, indicating that mwm is running.

Selecting the Window to Receive Input

By default, you select the window to receive input (the active window) by clicking the first pointer button anywhere within the window. As we’ve said, this focus policy is called click-to-type, or explicit. Whether mwm is started automatically or you started it by typing in an xterm window, you must then click in a window in order to enter text.

Once you focus input to a window, all text typed appears in that window, regardless of where you move the pointer. In order to type in another window, you must transfer focus to that window by clicking the first pointer button within it Later in this appendix, we’ll describe how to make the keyboard focus follow pointer movement.

images

Figure C-1. mwm is running on the display

When you focus input on a window, the window frame changes color. Depending on the version of mwm you are running and the color resources specified for your system, the frame may change from black to white, from grey to white, etc. In any case, the active window’s frame will be a different color than the frames of all other windows on the display. (In some versions, be aware that the black window frame of non-active windows obscures the titlebar text, which also appears in black. Only the title of the active window is visible in these cases.)

Notice that if you are working with a stack of windows that overlap, selecting a window as the active window automatically raises that window to the top of the stack. (As we’ll see when we look at customization, this behavior is controlled by an mwm resource variable called autoFocusRaise, which is true by default.)

Manipulating Windows with the mwm Window Frame

Figure C-2 shows an xterm window “framed” by mwm. The window frame itself and several features of it are tools that allow you to manipulate the window using the pointer.

images

Figure C-2. An xterm window running with the OSF/Motif window manager

The following sections describe the features of the mwm window frame and the functions they perform. Later, we’ll take a look at menu items and keyboard shortcuts that also perform these functions.

Be aware that mwm also allows you to manipulate icons using simple pointer actions, menu items, and keyboard shortcuts. An icon is a small symbol that (generally) represents a window in an inactive state. (See Chapter 1, Introduction to the X Window System, for more information about icons.) After we learn the various window manipulation functions, we’ll look at the section “Manipulating Icons.”

Moving a Window: The Title Area

When you select a window as the focus window, the name of the application is displayed within the title area. The title area allows you to move the window, using the following steps:

1. Place the pointer within the title area. The pointer changes to the arrow cursor.

2. Press and hold down the first pointer button.

3. Move the window by dragging the pointer. Figure C-3 shows one being moved in this way. When you begin to move the window, the pointer changes to a cross arrow pointer and a window outline appears. This outline tracks the pointer’s movement. In the center of the screen, a small, rectangular box also appears, displaying the x and y coordinates of the window as you move it

4. Drag the cross arrow pointer with the window outline to the desired location on your screen.

5. Release the first pointer button. The window will move to the selected location.

images

Figure C-3. Moving a window by dragging the title area

The title area is the largest section of the horizontal bar that spans the top of the window frame. This horizontal bar is known as the titlebar. Notice that whenever you move the pointer into the title bar, the pointer changes to the arrow cursor.

In addition to the title area, the titlebar features three command buttons: one on the left and two on the right These command buttons are described in the following sections.

Minimizing (Iconifying) and Maximizing a Window

The two command buttons on the right side of the titlebar are the Minimize and Maximize buttons. The Minimize command button converts a window to an icon. As mentioned previously, an icon is a small symbol that represents a window in an inactive state.

The Maximize command button can be used to enlarge a window to the size of the root window, and once the window has been enlarged, to convert it back to its original size.

The Minimize Button

The Minimize command button immediately to the right of the title area, is identified by a tiny square in its center. This button allows you to convert the window to an icon (iconify it), using the following steps:

1. Place the pointer within the Minimize command button. The pointer simply has to rest within the button’s outer border, not within the tiny square identifying it.

2. Click the first pointer button. The window is iconified. Figure C-4 shows a window being converted to an icon in this way.

images

Figure C-4. Converting a window to an icon with the Minimize button

By default, icons are displayed in the bottom left comer of the root window. mwm can also be set up to place icons in another location, to allow you to place them interactively using the pointer, or to organize icons within a window known as an icon box. Later in this appendix, we’ll discuss the specifications necessary to set up an icon box.

If you’ve used other window managers, you may notice that icon symbols generated by mwm are larger and more decorated than those generated by many other window mangers. This is one of the aesthetic advantages of mwm. Figure C-5 shows an example.

images

Figure C-5. xterm window icon under mwm

To convert the icon back to a window (deiconify it), place the pointer on the icon and double click, using the first pointer button. The window is redisplayed in the position it appeared before it was iconfied. (See the section “Manipulating Icons” for a summary of functions.)

The Maximize Button

To the right of the Minimize command button (in the upper right comer of the window), the Maximize command button is identified by a larger square in its center. The Maximize button allows you to enlarge the window to the size of the root window, and once it has been enlarged, to convert it back to its original size.

To maximize a window, use the following steps:

1. Place the pointer within the Maximize command button. The pointer simply has to rest within the button’s outer border, not within the square identifying it.

2. Click the first pointer button. The window is maximized. Figure C-6 shows how it’s done.

images

Figure C-6. Maximizing a window

The large window should function in the same way it did before it was maximized. Theoretically, you can maximize an xterm window to have a single, very large terminal screen. However, be aware that certain programs you may run within an xterm, such as the vi text editor. do not always work properly within a window of this size (even if you’ve used the resize client, as described in Chapter 4, The xterm Terminal Emulator). The Maximize function is more safely used with an application that displays a graphic image or performs a simple function, such as xclock.

Also, some client programs that do not support resizing, such as the Release 3 version of xcalc, cannot be maximized correctly. In the case of xcalc, the frame surrounding the calculator application is maximized, but the actual calculator remains the same size.

The Maximize button is a toggle. To convert a maximized window back to its original size, click on the Maximize button again with the first pointer button.

Raising a Window

Windows often overlap on the screen. You can raise a window that is obscured by other windows to the top of the stack using the mwm frame. To raise a window:

1. Place the pointer on any part of the window frame, except the command buttons (Minimize, Maximize, and the button in the upper left comer of the title bar, which as we’ll see, brings up the Window Menu).

2. Click the first pointer button. The window is raised to the top of the stack.

When you are using explicit (click-to-type) focus and the other default mwm resources, this action also selects the window to receive input, i.e., makes the window the active window.

Resizing a Window

One of the most distinctive and useful features of the mwm window frame is not at all obvious. The entire frame (other than the title area and the command buttons) is designed to allow you to resize the window using the pointer. Notice that the frame is divided by small lines into eight sections: four long borders (two horizontal and two vertical) and four comers. Figure C-7 shows these sections of the window frame.

images

Figure C-7. The outer frame is divided into four long borders and four corners

If you place the pointer within a window and then move it into one of the long horizontal or vertical borders, you’ll notice the pointer changes to a new shape: an arrow (pointing toward the window border), with a short line perpendicular to it. This short line represents the window border. Try moving the pointer in this fashion in one of the windows on your display to get a better idea of what the pointer looks like. If you move the pointer from within a window into the outer border at one of the comers, the pointer will become an arrow pointing diagonally at a small comer symbol, as pictured in Figure C-8. Figure C-9 shows all of the possible resize pointers.

Once the pointer changes to one of these shapes, you can move the border (or comer) of the window. Resizing from one of the long borders only allows you to change one dimension of the window: a horizontal border can only be moved up or down, changing the height; a vertical border can only be moved left or right, changing the width.

images

Figure C-8. Window with resizing pointer

images

Figure C-9. Resizing pointer symbols

Resizing from a comer offers the most flexibility. You can move a comer in any direction you choose, changing both dimensions of the window if you want. For example, you can drag the lower right corner of a window down and to the right to enlarge the window in both dimensions.

You determine the size and shape of the window by choosing the border or comer you want to extend (or contract) and moving it the desired amount using the following steps:

1. Move the pointer from within the window to the border or comer you want to move. The pointer changes to one of the symbols pictured in Figure C-9.

2. Press and hold down the first pointer button and drag the window border or corner in the direction you want. As you resize the window, an image of the moving border(s) tracks the pointer movement. Also, in the center of the display, a small rectangular window shows the dimensions of the window as they change (in characters and lines for xterm windows, in pixels for most other clients).

3. Resize the window as desired.

4. Release the first pointer button. The window is redisplayed in the new shape. (The border image and window geometry tracking box disappear.)

Figure C-10 shows a window being “stretched” from the lower right comer.

images

Figure C-10. Dragging the corner to make a window larger

The Window Menu Button: Display a Menu or Close the Window

The command button on the left side of the titlebar is used to bring up the Window Menu, which provides seven items that manipulate the window and its icon. The following sections describe how to bring up the Window Menu and invoke its various functions.

This command button also has another function. Double-clicking the first pointer button on the Window Menu command button kills the client program and closes the window. Be aware that, like other methods of ‘killing’ a program (such as the xkill client), double-clicking on the Window menu item can adversely affect underlying processes. Refer to the section on xkill in Chapter 7, Other Clients, for a more complete discussion of the hazards of killing a client and a summary of alternatives.

You can customize mwm so that double-clicking performs no function by setting a resource variable, wMenuButtonClick2, to false. See the sections “Setting mwm Resources” and “mwm-Specific Appearance and Behavior Resources” later in this appendix, and the mwm reference page in your OSF/Motif documentation for details.

Manipulating Windows Using the Window Menu

The command button on the left side of the titlebar is used to display the Window Menu. The Window Menu can actually be displayed from a window or an icon. As we’ll see, certain menu functions apply only to one or the other. This section describes using the Window Menu to manipulate a window. (The section “Manipulating Icons;’ later in this appendix, describes the use of Window Menu items, pointer commands, and other shortcuts on icons.)

Six of the seven items on the Window Menu (all but Lower) allow you to perform functions that can also be performed by simple pointer actions on the mwm window frame. All of the items can also be requested using keyboard shortcuts, known as accelerators, because they facilitate the action.

Since manipulating a window using the frame is very simple and accessible, you will probably not use the Window Menu often. You may want to use the menu to Lower a window, since this function cannot be performed by a simple pointer action on the frame. (If you learn the keyboard shortcuts for this menu item, you may not need the Window Menu to manipulate windows at all.) You may find the menu more helpful in manipulating icons, as described later in this chapter. In any case, learning the functions of the Window Menu is helpful in orienting yourself within the Motif environment.

The Window Menu can be displayed either from a window or from its icon. The Window Menu command button is in the upper left corner of the window frame and is identified by a narrow rectangle in its center. You can display the Window Menu from a window by moving the pointer to the command button and either:

•   Clicking the first pointer button.

•   Pressing and holding down the first pointer button.

(You can also display the menu using keyboard shortcuts described at the end of this section.) The menu is displayed. If you’ve clicked the first pointer button to display the menu (the easier method), the first item that is available for selection is highlighted by a box. Figure C-11 shows the default Window Menu, which has been displayed by clicking the first pointer button in the menu command button.

images

Figure C-11. The Window Menu

Notice that the first item available for selection (indicated by the surrounding box) is Move. The first item on the menu, Restore, is used to change an icon back into a window or a maximized window back to its original size; therefore, it is not useful at this time. The fact that Restore is not selectable is also indicated by the fact that it appears in a lighter typeface.

Notice also that one letter of each menu item is underlined. This letter represents a unique abbreviation for the menu item, called a mnemonic, and is useful in selecting the item.

Once the menu is displayed, you can select an item in the following ways:

•   If you displayed the menu by pressing and holding down the first pointer button, drag the pointer down the menu to the desired item and release the first button.

•   If you displayed the menu by clicking the first pointer button, either:

—Move the pointer onto the item and click the first button.

—Type the unique abbreviation (the underlined letter). (Though several of the abbreviations are capital letters, you should type the lower-case equivalent.)

The following sections explain how each of the Window Menu items works.

To remove the menu without making a selection, move the pointer off of the menu and release or click the first pointer button, as appropriate.

Notice also that a keyboard shortcut follows each command. The keyboard shortcuts allow you to perform all of the functions without having to display the menu. All of the keyboard shortcuts for the menu items involve the Alt key and a function key. (Alt is a logical key-name that may be associated with a physical key of another name. If you cannot locate the Alt key on your keyboard, see Chapter 11, Setup Clients, for a discussion of the xmodmap client.)

There are also keyboard shortcuts to display the Window Menu. Once you place the pointer anywhere in the window, either of the following key combinations will cause the menu to be displayed: Shift-Escape or Meta-space. (Like Alt, Meta is a logical keyname recognized by X programs. There is no key marked “meta” on the keyboard. Rather another key, such as the Compose Character key on the DECstation 3100 keyboard, functions as Meta. See Chapter 11, Setup Clients, for more information about the Meta key.)

In the following sections, we assume you have displayed the Window Menu by clicking the first pointer button on the menu command button. (If you display the menu by pressing and holding down the first pointer button, instructions to click a pointer button can be roughly translated to mean release the button.)

Changing the Window Location: Move

To move a window:

1. Bring up the Window Menu.

2. Select the Move item by clicking on it with the first pointer button, or by typing the letter m. The menu disappears. The pointer changes to the cross arrow pointer and appears in the center of the window.

3. Move the window by dragging the pointer. When you begin to move the window, a window outline appears. This outline tracks the pointer’s movement. In the center of the screen, a small rectangular box also appears, displaying the x and y coordinates of the window as you move it.

4. Drag the cross arrow pointer with the window outline to the desired location on your screen.

5. Click the first pointer button. The window will move to the selected location.

To cancel the Move function, keep the pointer stationary and click the first button.

The Move function can also be invoked using the keyboard shortcut Alt-F7.

Resizing the Window: Size

To resize a window:

1. Bring up the Window Menu.

2. Select the Size item by clicking on it with the first pointer button, or by typing the letter s. The menu disappears. The pointer changes to the cross arrow pointer and appears in the center of the window.

3. Move the pointer from within the window to the border or comer you want to move. The pointer changes to one of the symbols pictured in Figure C-9.

4. Once the pointer has become one of the resize pointers, you can drag the window border or corner in the direction you want. As you resize the window, an image of the moving border(s) tracks the pointer movement. Also, in the center of the display, a small rectangular window shows the dimensions of the window as they change (in characters and lines for xterm windows, in pixels for most other clients).

5. Resize the window as desired.

6. Click the first pointer button. The window is redisplayed in the new shape. (The border image and window geometry tracking box disappear.)

The Size function can also be invoked using the keyboard shortcut Alt-F8.

To cancel the Size function, don’t move the pointer near any of the borders; just click the first pointer button.

Iconifying the Window: Minimize

To iconify a window:

1. Bring up the Window Menu.

2. Select the Minimize item by clicking on it with the first pointer button, or typing the letter n.

3. The window is converted to an icon.

The Minimize function can also be invoked using the keyboard shortcut Alt-F9.

The easiest way to convert an icon back to a window is to place the pointer on the icon and double click with the first button.

Changing to the Maximum Size: Maximize

To make a window as large as the root window:

1. Bring up the Window Menu.

2. Select the Maximize item by clicking on it with the first pointer button, or typing the letter X.

3. The window is enlarged to the size of the root window.

The Maximize function can also be invoked using the keyboard shortcut Alt-F10.

Moving a Window to the Bottom of the Stack: Lower

The Lower menu item allows you to send a window to the bottom of the window stack. This is the only Window Menu function that cannot be performed simply by clicking the pointer on the window frame. To lower a window:

1. Bring up the Window Menu.

2. Select the Lower item by clicking on it with the first pointer button, or typing the letter l.

3. The window is moved behind others on the display to the bottom of the window stack.

Though this function cannot be performed by clicking the pointer on the frame, it can be invoked using the keyboard shortcut Alt-F3.

Removing a Window: Close

The Close menu item terminates the client window and the window is removed from the display. This powerful command is separated from the other menu items by a horizontal line to prevent you from inadvertently closing a window.

Be aware that, like other methods of ‘killing’ a program (such as the xkill client), the Close menu item can adversely affect underlying processes. Most windows can be removed in ways that do not harm relevant processes. For example, you can generally remove an xterm window by typing the same command you use to log off the system. Refer to the section on xkill in Chapter 7, Other Clients, for a more complete discussion of the hazards of killing a client and a summary of alternatives.

Like xkill, Close is intended to be used primarily after more conventional methods to remove a window have failed.

To remove a stubborn window:

1. Bring up the Window Menu.

2. Select the Close item by clicking on it with the first pointer button, or typing the letter c.

3. The window is removed.

The Close function can also be invoked using the keyboard shortcut Alt-F4.

Restoring a Maximized Window or an Icon: Restore

The Restore menu item allows you to restore an icon to a window or a maximized window to its original size. To restore a maximized window:

1. Bring up the Window Menu.

2. Select the Restore item by clicking on it with the first pointer button, or by typing the letter r.

3. The window is restored to its original size.

The Restore function can also be invoked using the keyboard shortcut Alt-FS.

Restore can also be used to convert an icon back to a window, as described in the section “Manipulating Icons Using the Window Menu” below.

Manipulating Icons

In addition to manipulating windows, mwm provides several easy methods for manipulating icons. The following functions can be invoked using simple pointer button actions on an icon:

Move Hold down the first pointer button and drag the icon to the desired position. Then release the button.
Raise Click on the obscured icon with the first pointer button. The icon is raised to the top of the stack.
Restore (Deiconify) To convert an icon back to a window, double-click on the icon with the first pointer button.

Manipulating Icons Using the Window Menu

You can also display the Window Menu from an icon and invoke menu items that affect it. To display the menu, just place the pointer on the icon and click the first button. (You can also use either of these keyboard shortcuts: Shift-Escape or Meta-space.)

The Window Menu displayed from an icon is virtually identical to the menu displayed from a window; it contains all of the same items, but only five of the seven are selectable. (When displayed from a window, six of the seven items are selectable.) The five selectable items are: Restore, Move, Maximize, Lower, and Close. These items perform manipulations on an icon analogous to those performed on a window (see “Manipulating Windows Using the Window Menu” earlier in this appendix).

Two menu items, Size and Minimize, appear in a lighter typeface, indicating they are not available for selection. Size cannot be selected because, unlike a window, an icon cannot be resized. Obviously, Minimize cannot be used to iconify an icon.

Table C-1 summarizes the Window Menu functions when invoked from an icon. For instructions on selecting an item and performing the various functions, read “Manipulating Windows Using the Window Menu” earlier in this appendix. Note that the keyboard shortcuts (accelerators) for the commands are also the same as those described for windows.

Table C-1. Window Menu Actions on an Icon

images

Later in this appendix, we’ll discuss using mwm resources to set up an icon box, a window for organizing icons on the display. Using an icon box changes the way you work with the Window Menu from an icon and introduces another menu item, PackIcons, which reorganizes icons in the icon box. See “Using an Icon Box” later in this chapter for details.

The Root Menu

The Root Menu is mwm’s main menu. It provides commands that can be thought of as affecting the entire display and is analogous to the Twm menu describe in Chapter 3. To display the Root Menu, move the pointer to the root window and press and hold down the first pointer button. The default Root Menu appears in Figure C-12.

images

Figure C-12. The mwm Root Menu

When you display the Root Menu, the pointer changes to the arrow pointer. As you can see, the default Root Menu offers only five items. To select an item, use the following steps:

1. As you continue to hold down the first pointer button, move the pointer onto the the desired item name. (If you accidentally move the pointer off the menu, it will still remain displayed, as long as you continue to hold the first button down.) As you move the pointer onto an item, notice that a rectangular box is displayed around the item to highlight it

2. Once the pointer is positioned on the item you want, release pointer button one. The action is performed.

The functions performed by the default Root Menu are described below.

New Window By default, this command runs an xterm window on the display specified by the DISPLAY environment variable, generally the local display. When you create a new window (by using the menu or typing the command in an xterm), the new window automatically becomes the active window.
Shuffle Up If windows and/or icons are stacked on your display, this command moves the bottom window or icon in the stack to the top (raises it).
Shuffle Down If windows and/or icons are stacked on your display, this command moves the top window or icon in the stack to the bottom (lowers it).
Refresh This command is used to refresh the display screen, that is, redraw its contents. Refresh is useful if system messages appear on the screen, overlaying its contents. (The xrefresh client can be used to perform the same function. Simply type xrefresh on an xterm command line.)
Restart... Stops and restarts mwm. This is useful when you’ve edited the .mwmrc configuration file, which specifies certain mwm features, and want to activate the changes. Since this function is potentially more dangerous than the other Root Menu options, it is separated from the other options by a horizontal line.
When you select Restart, a dialog box appears in the center of the screen with command buttons asking you to either Restart mwm or Cancel the request Click on the appropriate command button using the first pointer button.
If you select Restart mwm, the window manager process is stopped. The screen will momentarily go blank. The new mwm process will be started immediately. While the new mwm process is starting, an hourglass symbol is displayed in the center of the otherwise blank screen. The hourglass appears to be filling up with sand until the window manager is running and the windows again are displayed on the screen.

Keep in mind that you can add, change, or remove menu items using the mwm configuration file, .mwmrc, in your home directory. We’ll discuss customizing the Root Menu later in this appendix.

Customizing mwm

The Motif window manager is one of the more flexible window managers available in the X market today. As we’ve seen, mwm provides a wide variety of methods for manipulating windows. In addition, virtually every feature of mwm can be customized. You can change the appearance of window frames, icons, and menus, the functions available on the Root Menu and the Window Menu, the keyboard focus policy, how icons are arranged on the display, as well as the appearance of client applications running under OSF/Motif. As we’ll see, you can also create additional menus, displayed from the root window, to perform manipulations on the display as a whole.

Customization of mwm is controlled in two ways:

•   Through a special file, called .mwmrc, in your home directory.

•   Through mwm resources you can enter in your .Xresources file.

The default operation of mwm is largely controlled by a system-wide file, called system.mwmrc, which establishes the contents of the Root Menu and Window Menu, how menu functions are invoked, and what key and button combinations can be used to manipulate windows. To modify the behavior of mwm, you can edit a copy of this file in your home directory. The version of this file in your home directory should be called .mwmrc. We’ll take a look at the system.mwmrc and ways to edit your own .mwmrc file to make the window manager work more effectively for you.

In addition to the flexibility provided by the .mwmrc file, mwm provides dozens of application resources that you can set! It’s neither practical or necessary to discuss all of those resources here. (You could spend quite a long time customizing mwm, if you had the time and inclination.) We’ll just consider some basic categories into which mwm resources can be divided and also look at some of the more useful resources. See Chapter 9, Setting Resources, for syntax rules and information about loading resources into the server so that they will be accessible to client programs. See the mwm reference page in your OSF/Motif documentation for descriptions of all available resources.

In the remainder of this appendix, we’re going to demonstrate the basics of customizing mwm and suggest what we think are helpful modifications. (This is still quite a lot to absorb.) To illustrate, we’ll discuss how to customize the following features of mwm:

•   The menus and how menu functions are invoked.

•   The keyboard focus policy.

•   How icons are organized (namely, how to set up a window known as an icon box, in which icons on the display can be organized).

Before we can customize the mwm menus or the ways in which their functions are invoked, we need to take a closer look at the system.mwmrc file. First, however, let’s consider an important topic: how to make the window manager aware of customizations.

Activating Changes to the Window Manager

Be aware that if you edit your .mwmrc or .Xresources file to change the way mwm works, the changes will not take effect automatically. Whether you change resource settings, edit your .mwmrc file, or both, you must restart mwm for the changes to take effect.

If you edit your resources file, you must first make the server aware of the new resource specifications by using the xrdb client. Generally, you will enter the following command at the prompt in an xterm window:

% xrdb -load .Xresources

The settings in the current version of your .Xresources file will replace the resource settings previously stored in the resource database. You can merely append new settings to the old ones using the xrdb -merge option. See Chapter 9, Setting Resources, for more information.

Once you’ve loaded the new resource settings, you can restart mwm. This can be done using the Restart item of the Root Menu, as described earlier in this appendix. When mwm has been restarted, it should reflect any changes made to the .mwmrc and .Xresources files.

The system.mwmrc File

The following example shows the system.mwmrc file shipped with OSF/Motif Release 1.0. If you’ve used other window managers, this file may seem a bit more complicated than other configuration files, but the complexity is deceptive.

If you wish to change the operation of mwm, you shouldn’t change the system.mwmrc file. Instead, copy it to your home directory, under the name .mwmrc, and make changes to that copy.

Example C-1. The system.mwmrc file, Release 1.0

#
# DEFAULT mwm RESOURCE DESCRIPTION FILE (system.mwmrc)
#

#
# menu pane descriptions
#
# Root Menu Description
Menu RootMenu
{
    "Root Menu"          f.title
    No-label             f.separator
    "New Window"         f.exec "xterm &"
    "Shuffle Up"         f.circle_up
    "Shuffle Down"       f.circle_down
    "Refresh"            f.refresh
    no-label             f.separator
    "Restart..."         f.restart
}

# Default Window Menu Description

Menu DefaultWindowMenu MwmWindowMenu
{
    "Restore"        _R        Alt<Key>F5        f.normalize
    "Move"           _M        Alt<Key>F7        f.move
    "Size"           _S        Alt<Key>F8        f.resize
    "Minimize"       _n        Alt<Key>F9        f.minimize
    "Maximize"       _x        Alt<Key>F10       f.maximize
    "Lower"          _L        Alt<Key>F3        f.lower
    no-label                                     f.separator
    "Close"          _C        Alt<Key>F4        f.kill
}

#
# key binding descriptions
#

Keys DefaultKeyBindings
{
  Shift<Key>Escape             icon|window         f.post_wmenu
  Meta<Key>space               icon|window         f.post_wmenu
  Meta<Key>Tab                 root|icon|window    f.next_key
  Meta Shift<Key>Tab           root|icon|window    f.prev_key
  Meta<Key>Escape              root|icon|window    f.next_key
  Meta Shift<Key>Escape        root|icon|window    f.prev_key
  Meta Ctrl Shift<Key>exclam   root|icon|window    f.set_behavior
  Meta<Key>F6                  window              f.next_key transient
# Meta<Key>Down                root|icon|window    f.circle_down
# Meta<Key>Up                  root|icon|window    f.circle_up
}

#
# button binding descriptions
#
Buttons DefaultButtonBindings
{
    <Btn1Down>           frame|icon       f.raise
    <Btn2Down>           frame|icon       f.post_wmenu
    <Btn1Down>           root             f.menu     RootMenu
    Meta<Btn1Down>       window|icon      f.lower
    Meta<Btn2Down>       window|icon      f.resize
    Meta<Btn3Down>       window|icon      f.move
}
Buttons ExplicitButtonBindings
{
    <Btn1Down>           frame|icon       f.raise
    <Btn2Down>           frame|icon       f.post_wmenu
    <Btn3Down>           frame|icon       f.lower
    <Btn1Down>           root             f.menu     RootMenu
    Meta<Btn1Down>       window|icon      f.lower
    Meta<Btn2Down>       window|icon      f.resize
    Meta<Btn3Down>       window|icon      f.move
}
Buttons PointerButtonBindings
{
    <Btn1Down>           frame|icon       f.raise
    <Btn2Down>           frame|icon       f.post_wmenu
    <Btn3Down>           frame|icon       f.lower
    <Btn1Down>           root             f.menu     Rootmenu
# If (Mwm*passButtons == False)
    Meta<BtnlDown>       window|icon      f.raise
# Else
#   <Btn1Down>           window           f.raise
#   Meta<Btn1Down>       window|icon      f.lower
    Meta<Btn2Down>       window|icon      f.resize
    Meta<Btn3Down>       window|icon      f.move
}
#
# END OF mwm RESOURCE DESCRIPTION FILE
#

The system.mwmrc file can be divided into three sections:

•   Menu specifications.

•   Key bindings.

•   Button bindings.

Comment lines are introduced by the number sign (#).

The menu section of the system.mwmrc file defines the contents of the Root Menu and the Window Menu. Menu item labels are paired with predefined mwm functions.

A binding is a mapping between a user action (such as a keystroke) and a function, in this case a window manager function. The key bindings section specifies keyboard keys that can be used to invoke some of the pre-defined window manager functions. The button bindings section specifies pointer buttons or key/button combinations that can be used to invoke various functions.

Each section of the system.mwmrc file matches the following basic template:

Section_Type   Section_Title
{

definitions
}

For example, the basic syntax of a menu specification is as follows:

Menu menu_name...
{

menu items defined
}

Menu is the Section_Type. The other possible section types are Keys and Buttons. The Section_Title is somewhat arbitrary. In this case, it corresponds to the title of a menu. In the key and button sections, it is simply a title assigned to a group of bindings.

However, the Section_Title can be very significant. As we’ll see, a section title can be used as the value of a resource variable in your .Xresources file. Menu titles are often referenced elsewhere in the .mwmrc file. The menu_name is generally paired with a pointer button action (in the button bindings section of the .mwmrc file) to allow you to use a particular button to display the menu.

The syntax of the actual menu items, key bindings, and button bindings requires further explanation. But first, let’s take a look at some of the predefined window manager functions.

mwm Functions

mwm has a number of predefined functions. Each of these functions has a name beginning with “f.”. Several functions appear in the system.mwmrc file, paired with the method by which the function can be invoked: by menu item, pointer button action, keystroke(s), or key and pointer button combinations.

The meaning of most of these functions should be fairly obvious to you from the name, if not from your experience using the window manager. For example, f.resize is used to resize a window, f.move to move a window, or f.minimize to change a window to an icon.

Others are less obvious. The function f.post_wmenu is used to display (or post) the Window Menu. Notice the function f.separator, which appears in the menu definition coupled with the instruction no-label rather than with a menu item. This line in the .mwmrc creates a divider line on a menu. For example, such a divider line is used to isolate the Restart... item from the other items on the Root Menu.

As we’ll see, the function f.menu is used to associate a menu with the key or button binding that is used to display it The f.menu function takes a required argument: the menu name. This function can also be used to define a submenu.

Each of the functions is described in detail on the reference page for mwm in your OSF/Motif documentation.

Menu Specifications

The first section of the system.mwmrc file contains specifications for the Root Menu and Window Menu. As we’ve said, the basic syntax of a menu specification is as follows:

Menu menu_name...
{
menu items defined
}

Menu items are defined in slightly different ways for the Root Menu and the Window Menu. The following text in the system.mwmrc file creates the Root Menu:

# Root Menu Description
Menu RootMenu
{
    "Root Menu"        f.title
    No-label           f.separator
    "New Window"       f.exec "xterm &"
    "Shuffle Up"       f.circle_up
    "Shuffle Down"     f.circle_down
    "Refresh"          f.refresh
    no-label           f.separator
    "Restart..."       f.restart
}

The syntax for defining Root Menu items is very simple. Each item is defined by a line of this format:

"label"    function

When you pair a label with a menu function, that label appears as a menu item. You can invoke the function by selecting the item from the menu using the pointer. For example, the line:

"Refresh"    f.refresh

sets up the Refresh menu item, which can be selected from the Root Menu as discussed earlier in this appendix. (Again, the function performed is obvious from the function name.) As we’ll see later, it’s easy to add items to the Root Menu by adding lines of label/function pairs.

Because Window Menu items can be invoked in a variety of ways, the syntax for defining items is more complicated. The following text defines the Window Menu:

# Default Window Menu Description
Menu DefaultWindowMenu MwmWindowMenu
{
   "Restore"       _R        Alt<Key>F5       f.normalize
   "Move"          _M        Alt<Key>F7       f.move
   "Size"          _S        Alt<Key>F8       f.resize
   "Minimize"      _n        Alt<Key>F9       f.minimize
   "Maximize"      _x        Alt<Key>F10      f.maximize
   "Lower"         _L        Alt<Key>F3       f.lower
   no-label                                   f.separator
   "Close"         _C        Alt<Key>F4       f.kill
}

The syntax of each menu item is as follows:

"label"            mnemonic            accelerator            function

(The mnemonic and accelerator fields are optional.) Like the Root Menu, each item on the Window Menu can be invoked by selecting its label with the pointer. In addition, there are two shortcuts defined for invoking the function, a mnemonic and an accelerator. As you may recall, a mnemonic is a unique letter abbreviation for the menu item label. On the menu, mnemonic abbreviations are underlined; thus an underscore precedes each mnemonic definition in the system.mwmrc file. Once the Window Menu is displayed, you can select an item by typing its mnemonic abbreviation. Similarly, you can invoke the function without displaying the menu, simply by typing the accelerator keys (by default, the Alt key plus a function key).

Now let’s see how one of the Window Menu definition lines fits this template:

"Move"   _M   Alt<Key>F7   f.move

The menu item label is Move. Selecting the item invokes the f.move function. The mnemonic “m” or the accelerator key combination Alt-F7 can also be used to invoke the function.

Key Bindings

The second section of the system.mwmrc file binds keystroke combinations to window manager functions.

Like the menu definintion section, the key bindings section of the file is titled and bracketed:

Keys Section_Title
{
key bindings defined
}

The section type is Keys. The section title in the system.mwmrc file is DefaultKey-Bindings. This title can also be specified as the value of the mwm resource key-Bindings in your .Xresources file. However, since these bindings are used by default, this is not necessary.

Using the section title as a resource becomes significant when you want to create an alternative set of bindings. Hypothetically, you could add another set of bindings with a different title to your .mwmrc file. Then specify this title as the value of the keyBindings resource in your .Xresources file. If you add the following resource specification to your .Xresources file, MyButtonBindings replace DefaultButtonBindings for all client applications running with mwm:

Mwm*keyBindings:   MyButtonBindings

If you want to use different sets of bindings for different applications, you can add an application name between the parts of the resource specification. For example, if you want My-ButtonBindings to apply only to xterm windows running with mwm, you could enter the following resource line:

Mwm*xterm*keyBindings:   MyButtonBindings

Then DefaultButtonBindings would still apply to all applications other than xterm.

A non-obvious principle behind a key/function (or button/function) binding is that in order for the keys (or buttons) to invoke the function, the pointer must be in a certain location. This location is known as the context. For mwm, the most commonly used contexts are: root, frame, window, and icon. The window context refers to the entire window, including the frame. (There are a few more specific contexts, such as border, but they are not used in the system.mwmrc file. See the mwm reference page in your OSF/Motif documentation for details.)

Some functions can be invoked if the pointer is in more than one context. For example, as we’ve seen, you can display the Window Menu from either a window or an icon using the keyboard shortcuts Meta-space or Shift-Escape. The action involved is f.post_wmenu and the window and the icon are the pointer contexts from which this action can be performed. These keyboard shortcuts are defined in the key bindings section of the system.mwmrc file as follows:

Shift<Key>Escape   icon|window   f.post_wmenu
Meta<Key>space     icon|window   f.post_wmenu

Upon examining these lines, we can discern the template for a key binding:

[modifier_keys]<Key>key_name      context      function

Each binding can have one or more modifier keys (modifiers are optional) and must have a single primary key (signaled by the word <Key> in angle brackets) to invoke the function. In the first specification, Shift is the modifier and Escape is the primary key. In the second specification, Meta is the modifier and space is the primary key. Both specifications have two acceptable pointer contexts: either a window or an icon. And both bindings are mapped to the same action, f.post_wmenu, which displays the Window Menu.

Button Bindings

The key bindings section of the file is also titled and bracketed:

Buttons Section_Title
{

button bindings defined
}

The section type is Buttons. The system.mwmrc file contains three sets of button bindings with the section titles:

DefaultButtonBindings
ExplicitButtonBindings
PointerButtonBindings

Button bindings clearly illustrate the need to coordinate your .Xresources and .mwmrc files. The three sets of button bindings correspond to three possible settings for the resource buttonBindings. The default setting for the resource is:

Mwm*buttonBindings:   DefaultButtonBindings

specifying that the DefaultButtonBindings are used.

You can specify that one of the other sets of button bindings is to be used by setting this resource in your .Xresources file. For example, if you add the following specification to your resource file:

Mwm*buttonBindings:   ExplicitButtonBindings

mwm will use those bindings that come under the heading ExplicitButtonBindings in the .mwmrc file.

Be aware that if you do specify different button bindings, the value of the resource must exactly match the title associated with the bindings, or the bindings will not take effect.

The syntax for a button binding specification is very similar to that of a key binding:

[modifier_key]<button_event>         context         function

Each binding can have one or more modifier keys (modifiers are optional) and must have a single button event (enclosed in angle brackets) to invoke the function. The motion that comprises each button event should be fairly obvious. (A list of acceptable button events appears on the mwm reference page in your OSF/Motif documentation.)

Now let’s see how the button binding syntax relates to the default button bindings in the system.mwmrc file:

Buttons DefaultButtonBindings
{
    <Btn1Down>         frame|icon       f.raise
    <Btn2Down>         frame|icon       f.post_wmenu
    <Btn1Down>         root             f.menu    RootMenu
    Meta<Btn1Down>     window|icon      f.lower
    Meta<Btn2Down>     window|icon      f.resize
    Meta<Btn3Down>     window|icon      f.move
}

The first specification is familiar. It indicates that the event of pressing down the first pointer button while the pointer is in a window frame or an icon performs the action of raising the window or icon, respectively.

Most of the other default button bindings reveal ways to perform mwm functions that were not covered in the first half of this appendix. Upon closer examination, you should be able to figure out these bindings and what they do. The second binding reveals still another way to display the Window Menu, by pressing the second pointer button on a window frame or an icon.

The third binding is also familiar. and illustrates the use of the f.menu function. As previously mentioned, the f.menu function is used to associate a menu with the key or button binding that is used to display it The following binding specifies that the Root Menu is displayed by pressing and holding down the first pointer button on the root window:

<Btn1Down>      root      f.menu      RootMenu

Notice that the function requires an argument, the menu name (RootMenu), which also appears in the first line of the menu definition. This correspondence is required—f.menu needs to know which menu to display.

The other default button bindings perform useful (though not obvious) functions. Each specifies holding down the Meta key and simultaneously pressing a different pointer button while the pointer is on a window or icon. Holding down the Meta key and pressing the first pointer button on a window or icon lowers the window or icon to the bottom of the stack. Holding down the Meta key and pressing the second or third pointer button enables you to resize or move the object, respectively.

Customizing the Root Menu

You can add items to the Root Menu simply by adding lines of the format:

"label"      function

within the menu definition section of your .mwmrc file.

The f.exec function allows you to execute system commands from a menu. In the default Root Menu, the New Window command uses the f.exec function to execute the system command xterm &.

# Root Menu Description
Menu RootMenu
{
   "Root Menu"         f.title
   No-label            f.separator
   "New Window"        f.exec "xterm &"
   "Shuffle Up"        f.circle_up
   "Shuffle Down"      f.circle_down
   "Refresh"           f.refresh
   no-label            f.separator
   "Restart..."        f.restart
}

To create a menu item labeled Clock that opens an xclock window on your display, simply add a line to your .mwmrc file, as shown here:

# Root Menu Description
Menu RootMenu
{
   "Root Menu"        f.title
   No-label           f.separator
   "New Window"       f.exec "xterm &"
   "Clock"            f.exec "xclock &"
   "Shuffle Up"       f.circle_up
   "Shuffle Down"     f.circle_down
   "Refresh"          f.refresh
   no-label           f.separator
   "Restart..."       f.restart
}

You can also edit (or remove) existing menu items. For example, if you want to run a terminal emulator program other than xterm, you can edit the menu item definition in your .mwmrc file. Say you want to run the hpterm terminal emulator (developed by Hewlett-Packard), you would edit your menu specification to look like this:

# Root Menu Description
Menu RootMenu
{
   "Root Menu"        f. title
   No-label           f.separator
   "New Window"       f.exec "hpterm &"
   "Shuffle Up"       f.circle_up
   "Shuffle Down"     f.circle_down
   "Refresh"          f.refresh
   no-label           f.separator
   "Restart..."       f.restart
}
Creating New Menus

Keep in mind that mwm also allows you to specify entirely new menus in your .mwmrc file. A new menu can be separate from all existing menus, or it can be a submenu of an existing menu. (Submenus are described in the following section, “Cascading Menus.”)

If you want to create a new, independent menu, it must conform to the menu specification syntax discussed earlier. Items must invoke predefined window manager functions.

The .mwmrc file must also specify how the menu will be displayed and in what context. This involves associating a key or button with the f.menu function. Say you’ve specified a new menu, titled GamesMenu, that runs various game programs, each in its own window. (The f.exec function would be used to define each item.) The following button binding specifies that pressing the second pointer button on the root window causes the Games Menu to be displayed:

<Btn2Down>     root     f.menu     GamesMenu
Cascading Menus

mwm also allows you to create submenus, generally known as cascading menus because they are displayed to the right side of (and slightly lower than) another menu. You define a submenu just as you would any other, using the syntax rules discussed earlier. The following lines create a Utilities Menu that invokes several “desktop” clients and one game:

Menu UtilitiesMenu
{
   "Utilities Menu"       f.title
   No-label               f.separator
   "Clock"                f.exec "xclock &"
   "System Load"          f.exec "xload &"
   "Calculator"           f.exec "xcalc &"
   "Manpage Browser"      f.exec "xman &"
   "Tetris"               f.exec "xtetris &"
}

In order to make this a submenu of the Root Menu, you need to add an f.menu function to the Root Menu. This f.menu function must be coupled with the correct submenu title:

# Root Menu Description
Menu RootMenu
{
   "Root Menu"            f.title
   No-label               f.separator
   "New Window"           f.exec "xterm &"
   "Shuffle Up"           f.circle_up
   "Shuffle Down"         f.circle_down
   "Refresh"              f.refresh
   "Utilities"            f.menu        UtilitiesMenu
   no-label               f.separator
   "Restart..."           f.restart
}

After you specify the preceding menus in your .mwmrc file (and restart mwm), display the Root Menu. It will feature a new item, labeled Utilities. Since this item is actually a pointer to a submenu, it will be followed by an arrow pointing to the right, as in Figure C-13.

images

Figure C-13. An arrow pointing to the right indicates a submenu

If you drag the pointer down the Root Menu to the Utilities item, the submenu will appear to cascade to the right. Figure C-14 shows it appearing.

If you release the pointer button, both menus will remain displayed and the Utilities item and the first item on the Utilities Menu will be highlighted by a box. You can then select an item from the Utilities Menu by moving the pointer to the item and clicking the first button.

images

Figure C-14. Utilities submenu of the Root Menu

Keep in mind that you can create several submenus beneath a single menu and that menus can cascade several levels, though such complexity is not necessarily desirable.

Setting mwm Resources

The Motif window manager provides dozens of resources that control the appearance and functionality of the window manager, its component features, and other clients running with it mwm resources should be entered in your .Xresources file and take effect when the resources have been loaded into the server and mwm has been started or restarted. See Chapter 9, Setting Resources, for syntax information and instructions on how to load resources using the xrdb client. See “Activating Changes to the Window Manager” for information about running mwm with the new resource settings.

mwm resources are considered to fall into three categories:

1. mwm component appearance resources. These resources set the characteristics of mwm’S component features, such as the window frame, menus, and icons.

2. mwm-specific appearance and behavior resources. These resources set characteristics of the window manager client, such as focus policy, key and button bindings, and so forth.

3. Client-specific resources. These mwm resources can be used to set the appearance and behavior of a particular client or class of clients.

Under these categories fall dozens of mwm resources. The sheer number of resources makes it impractical for all of them to be discussed here. (You could spend quite a long time customizing mwm in this way, if you had the time and inclination!) In the following sections, we discuss the three categories of resources in somewhat greater detail. We’ll then take a look at two of the more powerful and useful resources, keyboardFocusPolicy and use-IconBox, which set the focus policy and set up mwm to use an icon box, respectively. For a comprehensive list of available resources, see the mwm reference page in your OSF/Motif documentation.

Component Appearance Resources

The Motif window manager can be considered to be made up of components: client window frames, menus, icons, and what are known as feedback boxes. An example of a feedback box is the box that appears so that you can confirm or cancel a Restart command from the Root Menu. (See “The Root Menu” earlier in this appendix.)

Certain resources allow you to specify the appearance of one or all of these mwm component features. In specifying the resource setting, you can use the name of one of the features as part of the resource name. For example, one of the most useful component appearance resources is background, which, as we know from Chapter 8, specifies the background color. You can specify a resource that sets the background color of any of the mwm components. The following resource specification sets the background color of all client window frames to light blue:

Mwm*client*background:   lightblue

Table C-2 summarizes the resource name that corresponds to each of the mwm components:

Table C-2. Resource Names Corresponding to mwm Components

images

Thus, to set the background color of feedback boxes to sea green, you’d use the following resource:

Mwm*feedback*foreground:   seagreen

Of course, if you omit any specific component from the resource specification, it applies to all components. Thus, the following specification sets the background color of all window frames, feedback boxes, icons, and menus to light grey:

Mwm*foreground:   lightgrey

mwm-Specific Appearance and Behavior Resources

The mwm-specific resources control aspects of what you probably think of as the window manager application itself, features such as the focus policy, whether windows are placed on the display automatically or interactively, which set(s) of button and key bindings are used, whether an icon box is used, and so forth.

The syntax of mwm-specific resource specifications is very simple: the mwm class name connected by a loose binding to the resource variable name,* shown here:

Mwm*clientAutoPlace:   false

This resource establishes the behavior that the user will interactively place client windows on the display. (The default is true, meaning mwm places them automatically.)

Two of the mwm-specific resources bring up an issue of coordination between the .Xresources and .mwmrc files. Remember, the default .mwmrc file contains three sets of button bindings:

DefaultButtonBindings
ExplicitButtonBindings
PointerButtonBindings

These three sets of button bindings correspond to three possible settings for the resource variable buttonBindings. If your resource file contains the following setting:

Mwm*buttonBindings:   ExplicitButtonBindings

mwm will use those bindings that come under the heading ExplicitButtonBindings in the .mwmrc file.

Similarly, the resource variable keyBindings should be coordinated to match the key bindings in the .mwmrc file. Since the default .mwmrc file has only one set of key bindings, named DefaultKeyBindings, and the keyBindings resource also sets this by default, coordination should not be an issue unless you create a new set of key bindings with a different name.

Two of the most useful and powerful mwm-specific resources set the keyboard focus policy and specify that icons be stored in an icon box. We’ll discuss the use and advantages of these resources later in this appendix.

Client-Specific Resources

Some mwm resources can be set to apply to certain client applications or classes of applications. These resources generally have the form:

Mwm*application*resource_variable:

where application can be an instance name or a class name. Be aware that the application name is optional. If you omit an application name, the resource applies to all clients.

Many of the client-specific resources provide what might be considered advanced customization. For example, a combination of resources allows you to specify your own bitmap as the image for a client icon. The average user will probably not need most of these resources.

One client-specific resource users might be interested in is called focusAutoRaise. This resource, true by default, causes the active window (the window receiving input focus) to be raised to the top of the stack. If you are using explicit (click-to-type) focus (also the default), this behavior is clearly very desirable. However, if you change the focus policy to pointer focus (as we’ll describe in the following section), having focusAutoRaise on can make the display seem chaotic.

When pointer focus is active, as you move the pointer across the display. the focus changes from window to window based on the location of the pointer, often a desirable feature. However, if focusAutoRaise is still true, each time the pointer moves into a window, the window will be moved to the front of the display. Simply moving the pointer across a screenful of windows can create a distracting shuffling effect! If you set the focus policy to pointer, we suggest you also set focusAutoRaise to false, as in the following example:

Mwm*focusAutoRaise:   false

Since an application name is omitted from this resource specification, it applies to all clients. To change the behavior only for the class of xterm windows, you could specify:

Mwm*XTerm*focusAutoRaise:   false

Of course, suppressing focusAutoRaise with pointer focus is just our preference. You may want to experiment a while to see how you like working with it.

Setting the Focus Policy

The most common resource users will probably want to set controls mwm’s keyboard focus policy. By default, mwm has explicit (or click-to-type) focus, which is set using the following resource:

Mwm*keyboardFocusPolicy:   explicit

To change the keyboard focus policy from explicit to pointer focus (that is, focus follows the movement of the pointer), enter the following line in your .Xresources file:

Mwm*keyboardFocusPolicy:   pointer
Using an Icon Box

One of the most interesting (and desirable) features mwm can provide is a window in which icons can be organized on the display. This window is known as an icon box, and is pictured in Figure C-15 below.

images

Figure C-15. An icon box

As we’ll see, in addition to organizing icons neatly on the display, the icon box also provides a few window manipulation functions.

You can set up mwm to provide an icon box automatically by specifying the following resource in your .Xresources file:

Mwm*useIconBox:   true

If this resource is included in your .Xresources file (and the resources have been loaded as described in Chapter 9, Setting Resources), mwm will provide an icon box when it is started (or restarted). Other resources can be used to customize the size, appearance and location of the icon box, as well as the window’s title. By default, the icon box is six icons wide by one icon high (the size of individual icons depends on other mwm resources) and is located in the lower left hand comer of the display.

The horizontal and vertical scrollbars within the icon box suggest a significant, albeit non- obvious, feature. Icons can extend beyond the visible bounds of the icon box. If more than six icons are present in the default size box, you can view them using the scrollbars. (See Chapter 4, The xterm Terminal Emulator, for instructions on using scrollbars.) Keep in mind that if icons do extend beyond the visible bounds of the box, the appearance of the scrollbars will indicate it.

The presence of an icon box changes the way icons are used on the display. If you are using mwm without an icon box, only those windows that have been iconified are represented by icons on the display. If you are using mwm with an icon box, all windows on the display are represented by icons that are stored in the box, whether or not the windows are in an iconfied state.

When a client window is started, the window appears on the display and a corresponding icon appears in the icon box. However, an icon that represents a window currently visible on the display has a different appearance than an actual icon (that is, an iconified window). An icon corresponding to a window currently on the display appears flatter and less defined than the image of an iconified window. The former probably has fewer lines in its outer border. If you set up mwm to use an icon box, the differing appearance of these two types of icons should be obvious.

Somewhat similar to a menu item in a lighter typeface, the flatter, less defined icon suggests that it is not available to be chosen. In a sense, this is true. Since the flat icon is not an iconified window, but merely an image, it is not available to be converted back to a window. The icon box in Figure C-15 contains two iconified windows (xclock and the first xterm) and four icons representing windows currently visible on the display.

You can perform some manipulations by clicking on icons in the icon box. If you double click on an iconified window using the first pointer button, the icon is converted back to a window. If you double click on an icon representing an active window on the display, the corresponding window is raised to the front of the display.

However, an icon box limits the way you can work with the Window Menu. (It also changes one of the menu’s options.) If you are using an icon box, you cannot display the Window Menu from an individual icon and manipulate that icon.* Instead, when you display the menu from the icon box, the menu commands apply to the box itself (which is actually a window). You can display the menu from the icon box using any of the methods described in the section “Manipulating Windows Using the Window Menu” earlier in this appendix. For example, if you use the keyboard shortcut Meta-space, the menu is displayed above the Window Menu command button in the upper left hand corner of the icon box frame.

When displayed from the icon box, the Window Menu Close item is replaced by an item called PackIcons (mnemonic “p”, accelerator Alt+F12). PackIcons rearranges the icons in the box to fill in empty slots. This is useful when icons are removed from the box or the box is resized.

When you remove a window, the corresponding icon is removed from the box, leaving an empty slot. PackIcons will move any icons that are to the right of the slot one space to the left to fill the hole. If you resize the icon box, PackIcons will arrange the icons to fit the new window in an optimal way. For instance, say we resize the icon box in Figure C-15 so that it is only three icons wide, but twice as high, as in Figure C-16. The first three icons from the box appear; the second three are obscured.††

images

Figure C-16. In the resized icon box, only three icons are visible

Notice the horizontal scrollbar at the bottom of the window, indicating that the other three icons are still to the right of these and thus not viewable in the resized box. If you place the pointer on the scrollbar, hold down the first button and drag the scrollbar to the right, the hidden icons will be revealed.

In order to rearrange the icons to better fill the new shape box, use the PackIcons menu item. Figure C-17 shows the icon box after you’ve selected PackIcons.

images

Figure C-17. PackIcons menu item rearranges icons in resized box

If you want to reorganize icons in the box yourself, without PackIcons, this is also possible. You can actually move icons into adjacent empty slots using the pointer. Just hold down the first pointer button on the icon and drag it into the next slot If you first make the icon box larger, so that there are several empty spaces, you’ll find you can radically reorganize icons. Once you’ve arranged them as you like, you resize the box to fit the icons—or perhaps make it even smaller and view the obscured icons using the scrollbars.

______________
*Loose and tight bindings are described in Chapter 9. Setting Resources.

†Instance and class names are described in Chapter 9, Setting Resources.

*mwm is documented to display the Window Menu from an icon if you press the third pointer button. However, this does not seem to work according to the specifications. The 1.1 version of mwm, scheduled for release in June of 1990, may provide this functionality.

†Obviously, if your keyboard has only ten function keys, you cannot use the Alt+F12 accelerator.

††When you resize the icon box, you’ll notice the resize action has a tendency to jump the width or height of an icon at a time. The box must be resized exactly to fit a number of icons wide and a number high, though there are no obvious limitations as to the numbers. Basically, you can have an icon box of any size, even one icon high and wid and display the other icons using the scrollbars.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required