9.0 The X Window System

9.1 The X Desktop
9.1.1 Starting the X Server
9.1.2 The Menu Bar
9.1.2.1 The File Menu
9.1.2.2 The Window Menu
9.1.3 Automatic Launch of the X Server
9.1.4 Quitting the X Server
9.1.5 Running the X Server Without a Menu Bar
9.1.5.1 Menu Bar Shortcuts
9.2 Administering the X Window Software Environment
9.2.1 Starting Clients
9.2.1.1 The Start Up Script
9.2.1.2 Resources: X Application Preferences
Chapter 9.0 continues...


9.0 The X Window System


The X Window System®, or X, is a network transparent graphics window system originally developed at the Massachusetts Institute of Technology. X is based on a client/server model, where an application program (the client) communicates information to a display program (the server) which then outputs the information to a bitmapped display. The server directs user input, typically from a keyboard or mouse, to the client program for interpretation. The client and server communicate with one another using the X Protocol.

X allows multiple clients to run simultaneously, each displayed in a separate, overlapping window on the server. Using the mouse and keyboard, the user controls the size, appearance, and location of each window on the display, or X desktop.

The CodeBuilder X Window Software supports the X client/server model under CodeBuilder on a Macintosh. Using the CodeBuilder X Window Software, the Macintosh display is transformed into a high performance X server. CodeBuilder can be used to create and run X client programs. Simultaneous operation of Macintosh applications with X clients is also possible using MultiFinder to switch from the X server to the Macintosh program.

This chapter provides a user with the information necessary to operate and administer the CodeBuilder X Window Software. Related documentation on X is listed in section "APPENDIX C".

The following section introduces the X environment under CodeBuilder. It assumes a completed installation of CodeBuilder and the X Window Software software on your Macintosh. The software installation instructions are in section "2.0 A Roadmap to the CodeBuilder CD" and an overview of the X Window Software components appears in section "9.3 CodeBuilder X Window Software Overview".


9.1 The X Desktop

The CodeBuilder X Window Server runs entirely within a window in the CodeBuilder windows environment. For those unfamiliar this environment, refer to section "4.2 CodeBuilder Windows ". When started, the X server will create an X desktop similar in function to the Macintosh desktop on your display. The X desktop will coexist with CodeBuilder terminal windows, other Macintosh applications, and your Macintosh desktop, allowing you to conveniently switch among desktops and applications. X applications that you run and display on your Macintosh will appear on the X desktop, while CodeBuilder terminal and other Macintosh application windows will appear on the Macintosh desktop.


9.1.1 Starting the X Server

To launch the X server and create an X desktop, type the Apple key and the letter T simultaneously (<Command-T>). The X desktop appears below:

Figure 21. The X Desktop

The CodeBuilder wind(8) process MUST be running in order to start the X server. Use the command "ps -ax" to determine if wind is running (see Figure 19. Using ps to Manage Your Environment, page 65). To execute wind, type "wind" at the prompt. See also 9.1.3 Automatic Launch of the X Server.

The X server desktop window differs from a CodeBuilder terminal window in that the familiar Macintosh title bar, close box, zoom box, scroll bar, and size box are not present when the X server is running. The entire window area below the CodeBuilder menu is devoted to the X desktop, or root window. The X desktop size automatically conforms to the physical dimensions of your screen - larger monitors will provide more surface area for your X desktop.

X client applications appear in windows on the X desktop. In Figure 23, the xconsole, xterm and olvwm applications are running. X client start up is discussed in section "9.2.1 Starting Clients".


9.1.2 The Menu Bar

The CodeBuilder menu bar appears above the X server desktop (Figure 23) and controls the X server's visibility on the desktop relative to other CodeBuilder terminal windows and Macintosh applications you may be running. Unlike a CodeBuilder terminal window, Command key shortcut menu selections (the "hot" keys) are disabled when the X desktop is visible, since the Command key is meaningful as an X Meta key within the X environment.


9.1.2.1 The File Menu

The File menu lets you create CodeBuilder terminal windows within the CodeBuilder window environment. The File menu is also used to quit the X Window Server environment.

Figure 22. The File Menu

New Window
Create a new CodeBuilder terminal window. When a terminal window is created, the X server is hidden from view.
Close Window
Close the X server window. This option quits the X server, closing all X connections and terminating all processes associated with the X server.
Logout
Quit all CodeBuilder windows, including the X server, and return to the Login Console.
Quit
Quit the CodeBuilder application.


9.1.2.2 The Window Menu

The Window menu contains a hierarchical Order sub-menu item, a Save Window Environment item, and a list of CodeBuilder terminal windows including the X server. To access a sub-menu item, slide the mouse cursor over the item and to the right.

Figure 23. The Window Menu

Save Window Environment
Save a description of the sizes and locations of the current CodeBuilder windows environment to a named file. If the X server is running when the window environment is saved, the X server will be started automatically the next time you start up the CodeBuilder windows environment.
The Window List
Selecting a CodeBuilder terminal window makes the X desktop invisible and makes the terminal visible. Selecting X Server makes the X desktop visible. The active window is displayed in outline font.

The Positions item is disabled for all CodeBuilder windows when the X server is active.

The Order Sub-Menu.

Figure 24. The Order Sub-Menu

Hide "X Server"
Make the X server invisible. The X server can be made visible using the Show All command or by selecting Server from the window list.
Hide All
Make the X server and all CodeBuilder terminal windows invisible.
Show All
Make the X server visible.


9.1.3 Automatic Launch of the X Server

The X server may be started automatically the next time you log into the CodeBuilder windows environment by selecting the Save Window Environment item from the Window menu. This adds a single character lowercase 'x' appearing on a line by itself in your CodeBuilder Windows environment start up file (.windrc by default) that indicates the X server will start up when the CodeBuilder Windows environment is entered.

If you close all CodeBuilder terminal windows (using the File menu) leaving the X server desktop as the only window in the Window menu list prior to this step, the X server will run exclusive of any CodeBuilder terminal window in the new environment.


9.1.4 Quitting the X Server

To quit the X server and remove the X desktop, pull down the File menu and select Close Window.


9.1.5 Running the X Server Without a Menu Bar

You can configure the X server desktop to cover the entire screen, including the area normally occupied by the menu bar. When the menu bar is hidden, pull down menus from the menu bar remain accessible by the pressing the mouse button while dragging the cursor along the top edge of your X desktop.

Refer to the -fs X server start up option in section "9.2.3 The X Server Program" for more information on running the X server without a Macintosh menu bar.


9.1.5.1 Menu Bar Shortcuts

You can perform many of the menu bar functions described in this section using the CodeBuilder xtmenu(n) utility program. Xtmenu is particularly useful when you configure the X server to run without a menu bar.

Xtmenu is called from a shell command line under CodeBuilder. Run without options, xtmenu toggle switches the accessibility of Macintosh menu bar pull-down items on the X desktop when the menu bar is hidden.

Xtmenu also accepts the following options:

-h This option causes the visible X desktop to hide itself, exposing the Macintosh desktop. This is equivalent to selecting Hide from the Window Order menu.
-s When CodeBuilder is the foreground application and the X server is running but hidden from view, this option exposes the X desktop. This is equivalent to selecting the X Server item from the Window menu.
If the X server is not running, this option will start the X server, emulating the <Command-T> hot key server start up sequence.
-q When CodeBuilder is the foreground application, this option closes all X client connections, terminates the X server, and removes the X desktop from the CodeBuilder window list. This is equivalent to selecting Close Window from the File menu.

Window Manager Hot Keys. Xtmenu can be very useful when bound to a hot key sequence recognized by your favorite window manager. For example, you can hide the X desktop when running olvwm(n) using the Shift and Escape keys by modifying the $HOME/.olvwmrc file as follows:

Escape + Shift {
Execute: "/usr/bin/X11/xtmenu -h"
}
Window managers (with an emphasis on olvwm) are discussed in section "9.2.2 The Window Manager Client". Refer also to the olvwm(n), olvwmrc(n), afterstep(n), and twm(n) online manual pages for more information on the .olvwmrc, .steprc and .twmrc files.


9.2 Administering the X Window Software Environment

The CodeBuilder X Window Software is a very flexible software package that can be tailored to your individual requirements. This section describes how to install, configure and maintain the X software to create a working environment for you and your users.

If you are unfamiliar with UNIX system administration, review section "5.0 CodeBuilder Administration" before proceeding. An additional useful reference on administration of X is the X Window System Administrator's Guide, Volume 8, from O'Reilly & Associates, Inc.


9.2.1 Starting Clients

When you type <Command-T> or enter the command:
xtmenu -s
the xinit(n) X initialization program is launched by the CodeBuilder kernel. Xinit is responsible for starting XMachTen(n), the X server program, and a default set of X clients to display on your X desktop from a start up script.

xinit may only be run by the CodeBuilder kernel.


9.2.1.1 The Start Up Script

The initial X clients you choose to run on your X desktop are controlled by a shell script file in your CodeBuilder login directory called .xinitrc. If xinit cannot find a .xinitrc file in your home directory, the shell script /usr/lib/X11/xinit/xinitrc is run instead. You can copy this file to your home directory as .xinitrc and use it as the basis for creating your own customized X desktop. Commented lines in this file (those with a preceding pound (#) sign) are not executed by xinit.

The default X client start up script /usr/lib/X11/xinit/xinitrc is shown below:
#!/bin/sh

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/usr/X11/lib/X11/xinit/.Xresources
sysmodmap=/usr/X11/lib/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then
xrdb -merge $sysresources
fi

if [ -f $sysmodmap ]; then
xmodmap $sysmodmap
fi

if [ -f $userresources ]; then
xrdb -merge $userresources
fi

if [ -f $usermodmap ]; then
xmodmap $usermodmap
fi

# Set the root window background
xsetroot -grey

# Start a console terminal
xconsole -iconic &

# Start some programs
xterm -geometry 80x24+100+20 -ls -n `hostname` -T `hostname` &
#xclock -geometry 50x50+1-1 &

# Start a window manager
#twm
#afterstep
olvwm
The start up script begins by calling the xrdb(n) client which reads in any system-wide resources defined in the file /usr/X11/lib/X11/xinit/.Xresources, if present. Resources that you want available to all users and all clients displaying to the server should be defined in this file. Resources will be discussed in more detail in a subsequent section.

Next the script runs the xmodmap(n) client to load a custom keyboard mapping file from /usr/X11/lib/X11/xinit/.Xmodmap, if present. If you are using a U.S. keyboard, you will normally have no need to change your keyboard mapping, as the X server is launched by default with a U.S. keyboard mapping. If you operate the X server using a non-U.S. keyboard, the .Xmodmap file should be linked to one of the international keyboard map files in /usr/X11/lib/X11/xinit. Details on using the international keyboard map files are found in section "9.2.3.3 Keyboard Mapping".

The start up script runs xrdb and xmodmap again using .Xresources and .Xmodmap files from your home directory. These files can be maintained in individual user home directories to customize the default server resources or key map for that user.

The start up script uses xsetroot(n) to change the background, or root window, to a grey color. Choose any color from the list of colors in /usr/X11/lib/X11/rgb.txt.

Next, .xinitrc starts a console X window as an icon on the X desktop. CodeBuilder console output is redirected to the xconsole(n) window and is visible when the icon is de-iconified, or opened with a double-click of the mouse button.

Next, .xinitrc starts the X applications, by default an xterm(n) virtual terminal window. The window's geometry, title and icon name corresponding to the local host name are provided as command line parameters when starting the xterm client. You can add to the list of clients to be run at this point in the script. Note that the xclock(n) client is not run by default because of the comment ('#' sign) preceding the command. Also note that each application is placed in the background by the shell (using the '&' sign) to allow the entire client list to be processed.

Finally, the start up script launches a special X application known as the window manager that allows you to move, resize, and iconify your X application windows. By default, olvwm(n), the OpenLook Virtual Window Manager, is launched. Also available in the CodeBuilder X Window Software is afterstep(n), a window manager based on NeXTSTEPTM, and twm(n), the Tab Window Manager, from the MIT sources distributed with the X Window Software package. The operation of the OpenLook Virtual Window Manager is described in detail in section "9.2.2 The Window Manager Client".

The start up script you create in .xinitrc in your home directory takes precedence over the default system start up script.


9.2.1.2 Resources: X Application Preferences

Macintosh applications permit the setting of preferences to customize the application to the individual user's tastes, for example background color, window title, font size, etc. Preferences are set for the application and typically stored in a single file in the Macintosh Preferences folder.

Under X, preferences are set via application resources. Resources are specified as strings that are read in from multiple source files when an application is run. Application resources under X are inherently more flexible than Macintosh application preferences due to the client/server model under which X operates. As with Macintosh programs, preferences can be specified for the individual X application. In addition, since CodeBuilder allows multiple simultaneous users, X application preferences can also be specified for each individual user.

Resource Files. Resource files contain the default application resources and are commonly provided with the X application you are running. The resource file is named after the class name of the application. By convention, the class name of the application is the same as the program name, but with the first letter capitalized (for example Bitmap or Emacs) although some programs that begin with the letter 'x' also capitalize the second letter. Application class names can be discovered using the xprop(n) utility.

Resource Syntax. In their simplest form, resources have the following syntax:
name*variable:value
For example:
XTerm*background:beige
where name is either the class name or the instance name of the application. The default instance name is the name of the program, for example:
xterm*background:blue
Instance names may be changed using the -name command line option when you start the application. You can use the -name option to distinguish more than one instance of the same application in your resource file. As an example, suppose you want xterm windows for programming C to have a blue background and for Ada to have a red background. Your resource file may contain the following resources:
xterm-C*background:blue
xterm-Ada*background:red
When you start the xterm client for programming C or Ada, use the -name option to match the instance name used in the resource:
xterm -name xterm-C & (xterm started for C)
xterm -name xterm-Ada & (xterm started for Ada)
instance names take precedence over class names in resource specifications.

Applications written with the X Toolkit Intrinsics will have at least the following resource variables:

background
This resource specifies the color to use for the window background.
foreground
This resource specifies the color to use for the text and graphics within the window.
borderWidth
This resource specifies the width in pixels of the window border.
borderColor
This resource specifies the color to use for the window border.

Resource File Locations. Programs based on the X Toolkit Intrinsics obtain resources from the following sources. The sources are listed in the order of precedence from lowest to highest precedence. If the same resource specification is located in more than one place, the resource in the source with the higher precedence is used.

Application Level Resources.


User Level Resources.
The application default resource file may be copied to your home directory and customized according to your individual preferences. The file ~/XTerm will take precedence over /usr/X11/lib/X11/app-defaults/XTerm when xterm is started.
This is an environment variable you can set to an alternate search path for your application resource files. For example:
setenv XAPPLRESDIR /tmp/app-defaults
causes the X client to search for its resource file from an app-defaults subdirectory under the /tmp directory.
If the X server database (described in the next section) contains no resources, resources are read from a .Xdefaults file in your home directory when the application starts up. This file is not specific to an application and may contain resources from any number of different X clients.
X Server Level Resources.
Any global resources that should be available to all clients can be stored in a database residing on the X server using the xrdb(n) program. This is typically done when the server starts up in the .xinitrc file in the user's home directory. If the file /usr/X11/lib/X11/xinit/.Xresources containing server level resources is found, the resources are loaded into the X server and automatically become available to all client applications. The X server database is loaded using the command:
xrdb -merge <resource file>
If any resource is loaded into the X server database via xrdb (including non-conflicting resources), the $HOME/.Xdefaults file will not be read.
Host System Level Resources.
This file is associated with the host (from the hostname(1) command) on which you are executing the X application. It is useful when you share a single AppleShare mounted home directory among multiple hosts. It takes precedence over all application, user, and server level resources previously mentioned. It is not specific to an application and may contain resources for any number of different X applications.
If this environment variable is set to a named file, the file is read instead of the .Xdefaults-<hostname> file. It takes precedence over all other previously mentioned resource locations when starting an X application, for example:
setenv XENVIRONMENT ~/.Xdefaults-custom
The named file typically contains custom resources for all of the applications you run.
Command Line Resource Specification.
Resources can also be specified from the command line when starting your X application. The resourcestring is a single resource name, variable and value.
For example, the xterm default background color is overridden with a red background using the command:
xterm -xrm "XTerm*VT100.background: red"
Note that if the string contains characters interpreted by the shell (e.g., asterisk), they must be quoted. Any number of -xrm arguments may be given on the command line.
A command line option to the X application takes ultimate precedence over all other resource locations. An xterm's background will be blue regardless of all xterm background resource specifications in all locations when xterm is started with the command:
xterm -bg blue

Recommendations for Administering Resources
. Maintain unmodified copies of application resources in the /usr/X11/lib/X11/app-defaults directory. Customize these resources for individual users by copying the customized variables from each resource file to a .Xdefaults file in the user's home directory.

If in doubt as to which resources an X application will use when it is launched, use the appres(n) program to preview the application's resources.

For more information on the resource variables available to an application, refer to the online manual page for the application.



[ Top of Page ][ 9.2.2 The Window Manager Client ][ Table of Contents ]