The X Window System

Graphics for Linux and Unix Systems


Fonts, window managers, controlling window decorations, resources in Motif, and Open Look.

Listing Available Fonts

The X Window system comes with a huge set of fonts. To see a listing of the fonts available on your system, try a program called xlsfonts:

xlsfonts | more

This lists out many fonts, such as:

-adobe-courier-bold-r-normal--12-120-75-75-m-70-iso8859-1 -adobe-new century schoolbook-medium-r-normal--34-240-100-100-p-181-iso8859-1 -daewoo-gothic-medium-r-normal--16-120-100-100-c-160-ksc5601.1987-0 -misc-fixed-medium-r-normal--14-130-75-75-c-140-jisx0208.1983-0 lucidasans-bold-14 cursor

Decoding Long Font Names

Some of the multi-part names are quite long. These names follow a standard called X Logical Font Description, or XLFD.

Each part of an XLFD name is separated by a hyphen. If a part is missing, you'll see two hyphens in a row. You can also use wildcards, such as * for fields you don't care about.

Going in order, from left to right, the fields follow:

Field Example Description
Foundry adobe,b&h The company that created the font
Font family times, lucidasans Basic font family name
Weight bold, medium How thick the letters are
Slant i, r Italic, roman, oblique, etc.
   
Code Meaning
i Italic
o Oblique
r Roman
ri Reverse Italic
ro Reverse Oblique
ot Other
number Scaled font (R6)
Set-width name normal, condensed Width of characters
Additional style sans Extra info to describe font
Pixel size 26, 20 Height, in pixels, of characters
Point size 190, 140 Ten times height of characters in points
Dots-per-inch 100-100, 75-75 Dots per inch in X and Y directions. You can generally ignore this.
Spacing m, p, c Spacing
   
Spacing Meaning
c Character-cell/monospaced
m Monospaced
p Proportional
number Scaled font (R6)
Average width 94, 159 Ten times the average width in pixels
Charset registry iso8859-1 Character set encoding in the font, some examples:
   
Character Set Meaning
iso8859-1 Western Europe
hp-roman8 Western Europe (Hewlett-Packard only)
iso8859-2 Eastern Europe
ksc5601.1987-0 Korean
jisx0208.1983-0 Japanese

For more information on XLFD fonts, see chapter 7 in The UNIX System Administrator's Guide to X.

Window Managers

One of the main things that distinguish X from most other windowing systems, such as Windows or Macintosh, is that X separates the window manager from the windowing system. X allows you to run any window manager you want, and it is the window manager that controls the title bar and other "decorations" around your windows' client areas.

Major desktop environments, such as GNOME and KDE, come pre-built with one or more window managers that help provide a consistent desktop.

The window manager controls the initial placement of windows on your screen. It also controls the title bar. (The title bar is actually a window that the window manager creates.) The window manager is in charge of how you go about resizing and moving windows. And, some window managers provide a set of virtual screens, which allow you to organize your windows (and applications) across a number of virtual screens, each of which looks like the full screen you have.

This is all quite a lot different from Windows or Macintosh systems, where the window manager comes built-in and you don't have a lot of control over how it acts. In X, you can simply run a different window manager. Also in X, the title bar is a separate window, owned and managed by the window manager program. In the Windows and Macintosh environments, the title bar is part of your application's window and your application draws into the client area of the window. In X, all you have is the client area. The window manager controls the rest.

Controlling Window Decorations

Because the window manager is in charge of so much, you'll oftentimes want your programs to communicate with the window managers to request various features, such as the title to display in the title bar and so on. The X Window method to do this is by following the Inter-Client Communications Conventions Manual, or ICCCM. (X defines application programs as clients.)

Unfortunately, the ICCCM does not define all you'll normally want for communicating with the window manager. The problem is that the two main window managers, Motif and Open Look, each use proprietary extensions to the ICCCM to control things like whether the window title bar has resize handles and so on. Therefore, the ICCCM is no good for dealing with this. Instead, you need to program to the proprietary extensions used by both the Motif and Open Look window managers (luckily, these extensions don't overlap).

The following charts, extracted from Power Programming Motif, may help.

Window Manager Resources in Motif

If you're programming with Motif, you can use traditional Xt resources to control many aspects of the window manager, with special emphasis on the Motif window manager, mwm. If the current window manager is compatible with Motif conventions, then the following will also apply.

Resource Type Default Use
baseHeight int dynamic Base size
baseWidth int dynamic Base size
deleteResponse unsigned char XmDESTROY Action to take on wm Close
height Dimension dynamic Widget height
heightInc int dynamic Increment for resizing
iconic Boolean False Start as icon?
iconMask Pixmap NULL Mask for icon
iconName String NULL Name for icon
iconNameEncoding Atom STRING Char set
iconPixmap Pixmap NULL Icon bitmap
iconWindow Window NULL Icon window, if used
iconX int -1 Icon location
iconY int -1 Icon location
initialState int NormalState One of NormalState, IconicState or WithdrawnState
input Boolean True Want keyboard input?
inputMethod String NULL Locale modifier
keyboardFocusPolicy unsigned char XmEXPLICIT Click to type
maxAspectX int dynamic Max aspect ratio
maxAspectY int dynamic Max aspect ratio
maxHeight int dynamic Max size
maxWidth int dynamic Max size
minAspectX int dynamic Min aspect ratio
minAspectY int dynamic Min aspect ratio
minHeight int dynamic Min size
minWidth int dynamic Min size
mwmDecorations int -1 Mwm window decoration flags
mwmFunctions int -1 Mwm window function flags
mwmInputMode int -1 Sets if modal
mwmMenu String NULL Additional wm menu choices
overrideRedirect Boolean False Override wm?
preeditType String dynamic Implementation dependent for input method
title String dynamic Window title
titleEncoding Atom dynamic Title char set
transient Boolean False Transient? (i.e., dialog)
transientFor Widget NULL Set to main app if this widget is a dialog
useAsyncGeometry Boolean False Wait for wm on geometry?
waitForWm Boolean True Wait for wm?
width Dimension dynamic Widget width
widthInc int dynamic Increment for resizing
windowGroup Window dynamic Holds group leader
winGravity int dynamic Controls how things move inside when window gets resized
wmTimeout int 5000 (ms) Timeout

Open Look Window Manager

The Open Look window manager, olwm, uses a different set of X window properties than mwm for controlling its behavior. The bad part about this is that you have to set both types of properties to make your application robust in a number of different window manager environments. The good part, though, is that the Motif and Open Look properties don't conflict, so you can safely set both types for all your application's top-level windows.

Since the designers of Motif assumed you'd only run the Motif window manager, there are no nice resources for the Open Look window manager, at least not from within Motif applications. Instead, you need to set X properties on your top-level windows.

To control olwm title bar decorations, the first step is to set the _OL_WIN_ATTR property, which contains five 32-bit numbers:

  • flags
  • window type
  • window manager menu information
  • pushpin state information
  • limited menu information

You don't have to fill in all the fields. Instead, you set the flags to a bit-mask specifying which fields are actually filled in:

Value Usage
0x0001 Window-type information field is filled in
0x0002 Window menu information field is filled in
0x0004 Pushpin state information field is filled in
0x0008 Limited menu field is filled in

The window types include the following:

Atom Usage
_OL_WT_BASE Base window
_OL_WT_CMD Command window
_OL_WT_HELP Help window
_OL_WT_NOTICE Notice (dialog) window
_OL_WT_OTHER No default olwm decorations

To change window decorations, I normally use a type of _OL_WT_OTHER.

To add window decorations, fill in the _OL_DECOR_ADD property with the Atom IDs of the decorations you want to add to the default set.

To remove decorations, fill in the _OL_DECOR_DEL property with the Atom IDs of the decorations you want to remove.

Both properties contain any of the following Atoms:

Atom Usage
_OL_DECOR_CLOSE Close (iconify) button
_OL_DECOR_HEADER Title bar
_OL_DECOR_PIN Pushpin
_OL_DECOR_RESIZE Resize handles