next up previous
Next: The X Window Programming Up: X WIndow/Motif Programming Previous: Getting There

Environment -- The X Window System


What is the X Window system?


The X Window system  provides a way of writing device independent graphical and windowing software that can be easily ported from machine to machine. X is a network-based system and supports cross-platform communication -- we can get different machines to talk to each other.

At the highest level of X there are two basic features: The window manager  and the toolkit. The window manager (wm) controls GUI aspects such as appearance of windows and interaction with the user. The toolkits are C subroutine libraries where we describe how to contsruct the GUI and how to attach the GUI to the remainder of the application. Motif is one such toolkit. Motif is built on other toolkits in the X System: Xt Intrinsics , an intermediate level toolkit, and the low level X Library (Xlib) . The relevance of these will be made apparent in due course.

X Window Principles

All forms of displaying of information in X are bit-mapped which means that every pixel on the screen is individually controllable. Therefore we can draw pictures and use text. The requirement for bit-mapped graphics means that high quality monitors are necessary. However, most computer systems provide monitors of this type.

X, like most other windowing systems, divides the screen into various parts that control input and output. Each part is called a window . A window can have many uses. A window can display graphics, receive input from a mouse, act as a standard terminal (e.g. an Xterm -- a standard text based terminal emulation window) etc..

Not all applications need to consist of a single window. We can have many windows associated with different parts of application. Each subwindow is called a child and it usually remains under the control of it's parent window.

There is one special window, the background or root window. All other windows are children of the root .

The Window Manager


The window manager  is responsible for manipulating windows on the screen. The window manager performs the following operations:

Controlling the window environment is not easy and has many facets. For instance, there may be multiple applications running simultaneously and a conflict may arise for input:

Does a keyboard input go in a window where the mouse currently points or must a window be explicitly chosen?

The window manager is also predominantly responsible for the appearance and user interaction (the look and feel)  of the interface. Since the development of X, there have been a few different window managers. The look and feel varies a lot between each window manager. The Motif window manager   (mwm) is probably the window manager you are most familiar with as this comes with the Motif system. Other window managers include Sun's Open Look window manager ( olwm)   and the Tab or Tom's window manager (twm)  .

Most major Unix vendors now supply the CDE which by default runs the desktop window manager, dtwm  . The development of the common desktop will probably result in dtwm superseding mwm. The CDE default window manager can easily be altered to run the above altenative window managers if desired. Since the CDE is built on top of motif there are many similarities between dtwm and mwm (see Section 3.4 below).

The Motif look and feel , as defined by the Motif Style Guide, is basically enforced by mwm or dtwm. Consequently, interaction between applications and these window managers are eased if the applications obey standard Motif/CDE guidelines.

The Common Desktop Environment


Most major Unix vendors now provide the CDE as standard. Consequently, most users of the X Window system will now be exposed to the CDE. Indeed, continuing trends in the development of Motif and CDE will probably lead to a convergence of these technologies in the near future. This section highlights the key features of the CDE from a Users perspective.

Upon login, the user is presented with the CDE Desktop (Fig. 3.1). The desktop includes a front panel (Fig. 3.2) , multiple virtual workspaces, and window management. CDE supports the running of applications from a file manager, from an application manager and from the front panel. Each of the subcomponents of the desktop are described below.


Fig. 3.1 Sample CDE Desktop

The front panel


The front panel (Fig. 3.2) contains a set of icons and popup menus (more like roll-up menus) that appear at the bottom of the screen, by default (Fig. 3.1). The front panel contains the most regularly used applications and tools for managing the workspace. Users can drag-and-drop application icons from the file manager or application manager to the popups for addition of the application(s) to the associated menu. The user can also manipulate the default actions and icons for the popups. The front panel can be locked so that users can't change it. A user can configure several virtual workspaces -- each with different backgrounds and colors if desired. Each workspace can have any number of applications running in it. An application can be set to appear in one, more than one, or all workspaces simultaneously.


Fig. 3.2 CDE Front Panel

The file manager


CDE includes a standard file manager. The functionality is similar to that of the Microsoft Windows, Macintosh, or Sun Open Look file manager. Users can directly manipulate icons associated with UNIX files, drag-and-drop them, and launch associated applications.

The application manager


The user interaction with the application manager is similar to the file manager except that is is intended to be a list of executable modules available to a particular user. The user launches the application manager from an icon in the front panel. Users are notified when a new application is available on a server by additions (or deletions) to the list of icons in the application manager window. Programs and icons can be installed and pushed out to other workstations as an integral part of the installation process. The list of workstations that new software is installed on is configurable. The application manager comes preconfigured to include several utilities and programs.

The session manager


The session manager is responsible for the start up and shut down of a user session. In the CDE, applications that are made CDE aware are warned via an X Event when the X session is closing down. The application responds by returning a string that can be used by the session manager at the user's next login to restart the application. CDE can remember two sessions per user. One is the current session, where a snapshot of the currently running applications is saved. These applications can be automatically restarted at the user's next login. The other is the default login, which is analogous to starting an X session in the Motif window manager. The user can choose which of the two sessions to use at the next login.

Other CDE desktop tools


CDE 1.0 includes a set of applications that enable users to become productive immediately. Many of these are available directly from the front panel, others from the desktop or personal application managers. Common and productive desktop tools include:

Mail Tool
-- Used to compose, view, and manage electronic mail through a GUI. Allows the inclusion of attachments and communications with other applications through the messaging system.
Calendar Manager
-- Used to manage, schedule, and view appointments, create calendars, and interact with the Mail Tool.
-- A text editor with common functionality including data transfer with other applications via the clipboard, drag and drop, and primary and quick transfer.
Terminal Emulator
-- An xterm terminal emulator.
-- A standard calculator with scientific, financial, and logical modes.
Print Manager
-- A graphical print job manager for the scheduling and management of print jobs on any available printer.
Help System
-- A context-sensitive graphical help system based on Standard Generalized Markup Language (SGML).
Style Manager
-- A graphical interface that allows a user to interactively set their preferences, such as colors, backdrops, and fonts, for a session.
Icon Editor
-- This application is a fairly full featured graphical icon (pixmap) editor.

Application development tools


CDE[Add94g, Add94a, Add94e, Add94f, Add94c, Add94d, Add94b] includes two components for application development. The first is a shell command language interpreter that has built-in commands for most X Window system and CDE functions. The interpreter is based on ksh93[Add93b, Add93a], and should provide anyone familiar with shell scripts the ability to develop X, Motif, and CDE applications.

To support interactive user interface development, developers can use the Motif Application Builder. This is a GUI front end for building Motif applications that generates C source code. The source code is then compiled and linked with the X and Motif libraries to produce the executable binary.

Application integration


CDE provides a number of tools to ease integration. The overall model of the CDE session is intended to allow a straightforward integration for virtually all types of applications. Motif and other X toolkit applications usually require little integration.

The task of integrating in-house and third party applications into a desktop, often the most difficult aspect of a desktop installation, is simplified by CDE. The power and advantage of CDE functionality can be realized in most cases without recompiling applications.

For example, Open Look  applications can be integrated through the use of scripts that perform front-end execution of the application and scripts that perform pre- and post-session processing.

After the initial task of integrating applications so that they fit within session management, further integration can be done to increase their overall common look-and-feel  with the rest of the desktop and to take advantage of the full range of CDE functionality. Tools that ease this aspect of integration include an Icon Editor used to create colour and monochrome icons. Images can be copied from the desktop into an icon, or they can be drawn freehand.

The Action Creation Utility is used to create action entries in the action database. Actions allow applications to be launched using desktop icons, and they ease administration by removing an application's specific details from the user interface.

The Application Gather and Application Integrate routines are used to control and format the application manager. They simplify installations so that applications can be accessible from virtually anywhere on the network.

Windows and the Window Manager


From a user's perspective, one of the first distinguishing features of Motif's look and feel  is the window frame  (Fig. 3.3). Every application window is contained inside such a frame. The following items appear in the window frame:


Fig. 3.3 The Motif Window Frame

Title Bar
  -- This identifies the window by a text string. The string is usually the name of the application program. However, an application's resource controls the label (Chapter gif).
Window Menu
  -- Every window under the control of mwm has a window menu. The application has a certain amount of control over items that can be placed in the menu. The Motif Style Guide  insists that certain commands are always available in this menu and that they can be accessed from either mouse or keyboard selection. Keyboard selections are called mnemonics and allow routine actions (that may involve several mouse actions) to be called from the keyboard. The action from the keyboard usually involves pressing two keys at the same time: the Meta key gif and another key.

The default window menu items and mnemonics are listed below and illustrated in Fig. 3.4:


Fig. 3.4 The Window Menu

Minimize Button
-- another way to iconify a window .
Maximize Button
-- another way to make a window the size of the root window .

The window manager must also be able to manage multiple windows from multiple client applications. There are a few important issues that need to be resolved. When running several applications together, several windows may be displayed on the screen. As a result, the display may appear cluttered and hard to navigate. The window manager provides two mechanisms to help deal with such problems:

Active Window
-- Only one window can receive input at any time. If you are selecting a graphical object with a mouse, then it is relatively easy for the window manager to detect this and schedule appropriate actions related to the chosen object. It is not so easy when you enter data or make selections directly from the keyboard. To resolve this only one window at a time is allowed keyboard focus. This window is called the active window. The selection of the active window will depend on the system configuration which the user typically has control over. There are two common methods for selecting the active window:
Focus follows pointer
-- The active window is the window is the window underneath mouse pointer.
-- The active window is selected, by clicking on an area of the window, and remains active until another window is selected no matter where the mouse points.

When a window is made active its appearance will change slightly:

The exact appearance of the above may vary from system to system and may be controlled by the user by setting environment settings in the window manager.

Window tiling
-- Windows may be stacked on top of each other. The window manager tries to maintain a three-dimensional look and feel . Apart from the fact that buttons, dialog boxes appear to be elevated from the screen, windows are shaded and framed in a three-dimensional fashion. The top window (or currently active window) will have slightly different appearance for instance.

The window menu has a few options for controlling the tiling of a window. Also a window can be brought to the top of the stack, or raised by clicking a part of its frame.

   -- If a window is currently active and not required for input or displaying output then it may be iconified or minimised thus reducing the screen clutter. An icon (Fig. 3.5) is a small graphical symbol that represents the window (or application). It occupies a significantly less amount of screen area. Icons are usually arranged around the perimeter (typically bottom or left side) of the screen. The application will still be running and occupying computer memory. The window related to the icon may be reverted to by either double clicking on the icon, or selecting Restore or Maximise  from the icon's window menu.

Figure 3.5: Sample Icon from Xterm Application

The Root Menu

The Root Menu   is the main menu of the window manager. The root menu typically is used to control the whole display, for example starting up new windows and quitting the desktop. To display the Root menu:

The default Root Menu has the following The root menu can be customised to start up common applications for example. The root menu for the mwm (Fig. 3.6)  and dtwm (Fig. 3.7)   have slightly different appearance but have broadly similar actions, which are summarised below:


Fig. 3.6 The mwm Root Menu  

Fig. 3.7 The CDE dtwm Root Menu

(dtwm) -- A sub-menu is displayed that allows a variety of programs to be called from the desktop, for example to create a new window. The list of available programs can be customised from the desktop.
New Window
(mwm) -- Create a new window which is usually an Xterm window.
Shuffle Up
-- Move the bottom of the window stack to the top.
Shuffle Down
-- Move the top of the window stack to the bottom.
-- Refresh the current screen display.
-- Restart the Workspace.
  (dtwm) -- Quit the Window Manager.




next up previous
Next: The X Window Programming Up: X WIndow/Motif Programming Previous: Getting There