Chapter 1. Introducing Motif

Motif is a software system that provides you with a great deal of control over the appearance of your computer's visual display. This introductory chapter provides information on the following topics:

The X Window System and Motif

As computer video screens became larger, particularly on engineering workstations, they were able to accommodate more visual information. To organize this information, the display was logically divided into multiple rectangular areas called windows. The X Window System, commonly called X, was developed at the Massachusetts Institute of Technology to establish an industry standard for displaying windows with text and graphics. The X Window System is designed to be independent of any particular computer hardware.

The X Window System consists of an X server, which manages a visual display, and client application programs. Client application programs can perform a variety of tasks, such as processing electronic mail, managing a database, or simply displaying the current time. Each application appears in its own window or in a family of associated windows. The server conveys user input information, such as a click of the mouse or a keystroke, to the appropriate client application. Client applications communicate their needs for display actions to the server. The X server and client applications can reside on the same computer or on different computers connected by a network.

Without specifying exactly how applications should appear or behave, the X Window System provides the programmer with a general system that supports any number of different user interfaces. Without added programming enhancements, windows in X are simple rectangles with plain borders. Motif implements a flexible software system layered on top of X to create individual visual components, such as ScrollBars and Menus. Programmers combine these components to create user interfaces that facilitate your interaction with application programs.

If you would like additional information specifically about the X Window System, refer to the X Window System User's Guide: Volume 3, Motif Edition, 1991, published by O'Reilly and Associates, Inc.

Understanding Windows

The organization of windows on the display is often compared to the organization of pieces of paper on the surface of a desk. You can arrange papers on a desktop in any number of ways, including stacking papers one on top of another so that one paper obscures the visibility of all, or portions, of other papers. You can also file papers, discard them, or add new papers to the collection.

Unlike the pieces of paper on a desk, however, you can change the contents, size, and other attributes of windows. Windows conceptually can extend beyond the screen, which means that portions of the window will not be visible. The number and content of windows on your screen will vary, depending on what applications are running at any given moment.

Window Hierarchy

Windows are organized into a hierarchy. The entire screen, analogous to the desktop, is covered by the root window, which cannot be removed. Other windows appear within the root window and are known as its children. Every window except the root window has a parent. Windows that have the same parent are considered siblings.

In Motif applications, there are three basic types of windows:

  • Primary windows

  • Secondary windows

  • Menu windows

Primary windows organize the contents of the application. Primary windows serve as parent windows for other windows in an application. They usually are children of the root window.

Motif applications use secondary windows for conveying information to or requesting information from the user. A secondary window always has a parent window, either a primary window or another secondary window.

Menu windows, or simply Menus, display temporary lists of choices. A menu window always relates to a parent window, either a primary window, a secondary window, or another menu.

Window Geometry

The position and size of a window on a display is referred to as the window geometry. The height and width of a window are usually expressed in pixels (from picture elements). However, an application may use units that make sense for that application, such as the number of characters or lines.

Like the points on a graph, each window has its own coordinates. The window's horizontal position is expressed as x. The window's vertical position is expressed as y. The x,y coordinate position of each window's upper left corner, or origin, is (0, 0). The x coordinate increases as you move to the right within the window, and the y coordinate increases as you move down within the window. Figure 1-1 illustrates the system of window coordinates.

Figure 1-1. Window Coordinates

Relative to the Root Window, Window A's origin (upper left corner) is placed at coordinate (50, 100). Relative to Window A, however, this is coordinate (0, 0). Chapter 5 describes how to specify these coordinates for windows in Motif applications.

Interacting with Windows

Using a client program called a window manager, you can move windows around, remove them from view, change their sizes, and rearrange their stacking order. Motif includes its own window manager, the Motif Window Manager (mwm). You can interact with client applications programs, including the window manager, with either a pointing device such as a mouse or the keyboard. There are keystrokes that correspond to mouse button actions. Chapter 2 describes mwm in detail.

The Look and Feel of Motif

The most apparent distinguishing characteristic of Motif is its 3-dimensional appearance. The 3-dimensional appearance is achieved through the use of shading, which makes the edges of Motif visual components appear as if they were beveled. Figure 1-2 depicts a typical Motif display.

Figure 1-2. A Typical Motif Display

In addition to its 3-D appearance, Motif is characterized by its rich set of user-interface components, called widgets. Motif widgets provide functionality for the following visual components:

  • Buttons

  • Menus

  • DialogBoxes

  • PanedWindows and ScrolledWindows

  • ScrollBars/Navigators

  • Lists

  • Text

These components and your interaction with them are described in Chapter 3.

Motif allows you to modify the appearance and behavior of Motif applications. For example, you can change the colors and fonts of your own client applications, add menus to the Motif Window Manager, and select the initial window layout at startup. Chapters 4 through 7 describe how to modify the appearance and behavior of your Motif environment.

This guide explains Motif applications, including mwm, in terms of their compliance with the guidelines described in the Motif Style Guide. This approach allows you to be comfortable with using any Motif Style Guide compliant application.

Starting X and the Motif Window Manager

Because different computer systems have different ways of starting X and Motif, you should consult with your system administrator to learn how to get started. Usually, X and mwm are started from a shell script that executes automatically when you log in. You may, however, find that you need to start X or mwm or both.

If you log in and find that your display is functioning as a single terminal, with no windows displayed, you can start X by issuing the following command:

% xinit

If this command does not start X, check with your system administrator to ensure that the X11 directory containing executable programs is in your search path. The appropriate path may differ from one system to another.

If you log in and find one or more windows without frames, you can start mwm with the following command:

% mwm &

Before entering this command, make sure that the pointer rests within a window that has a system prompt.

Restoring Default Behavior

Because Motif permits a great deal of customization both by programmers writing Motif applications and by users, you may find that mouse buttons or other functions do not operate as you might expect from reading this guide. You can reset your Motif environment to the default behavior by pressing these four keys simultaneously:

Alt Ctrl Shift !

You can return to the customized behavior by pressing these keys again. If your system does not permit this combination of keystrokes, you can also restore default behavior from the default Root Menu (see Chapter 2).