2 Creating a window

The simplest way to create a window (in terms of understanding what is happening) is to use the xmake command and specify the properties that you want the window to have. There are other, more convenient, ways to create windows but they are easier to explain after describing the xmake command.

xmake name options

creates a window with the name name. Case matters in window names so mywindow, MYWINDOW and MyWindow are all different.

The following options, which can be abbreviated, are recognized:

-background colour
The background colour of the window; colour is the name of a colour recognized by X windows. Examples:
  xmake test -background black
  xmake test -background yellow

The default is Black.

-bg colours
The same as -background.
Specifies the width of the window border in pixels. The border width is ignored by many window managers but the value specified is used to calculate the window position so should match the actual border width used by the window manager. The default is 10 which is what the Motif window manager uses.

If the window appears to be incorrectly position when a geometry specification of -geometry -0-0 is used then changing the border width may correct the problem.

-colours number
The number of colour table entries to be allocated to the window; number should be an integer greater than or equal to 2.

On a server with a writable colour table, the requested number of colour table entries are reserved for the exclusive use of the window; if there are insufficient free entries in the default colour map, a private colour map is created and the entries allocated from that. On a server with a fixed colour table, entries can be shared between windows and any number up to the maximum supported by the server can be requested.


  xmake test -colours 2
  xmake test -col 127

The default depends on the properties of the X server.

-fg colours
The same as -foreground.
-foreground colour
The foreground colour of the window; colour is the name of a colour or RGB specification in X windows format. Case does not matter but colour names cannot be abbreviated. Examples:
  xmake test -foreground white
  xmake test -foreground SpringGreen
  xmake test -foreground #FF00FF}

The default is White.

-geometry specification
The size and position of the window; specification is a window geometry specification of the form:


(x is the letter “x” and +/- is either a plus sign or a minus sign.) All dimensions are in pixels and the origin is the position of the top left hand corner of the window relative to the top left hand corner of the screen if the origin specification is a positive number, or the position of the bottom right corner of the window relative to the bottom right of the screen if it is negative. All the components of the geometry specification are optional. Examples:

  xmake test -geometry 780x512
  xmake test -geom 600x400+300+300
  xmake test -geom +512+368

To position the window in the bottom right corner of the screen:

  xmake test -geom -0-0

To position the window in the top right corner:

  xmake test -geom -0+0

The default is 780x512 (this leaves it up to the window manager to decide where to place the window).

The geometry specification is only a hint to the window manager and may be ignored.

Create the window as an icon.
Allows the window size to be set interactively. When the window appears on the screen its size can be modified before the window creation is completed and the window size fixed. Resize the window with the facilities provided by the window manager that you are using and then click the mouse on the interior of the window to indicate that the desired size has been set.

This option is ignored if -iconic is specified.

The opposite of -interactive. This is the default.
Do not allocate an overlay plane. This option would be required if a default overlay colour had been set using the “X defaults” file (see below) but a window without an overlay plane was required.
-ovcolour colour
Set the colour of the overlay plane. If not specified the overlay plane is set to the foreground colour. Example:
  xmake test -ovcolour Green
Allocate an overlay plane There is no default for this option. The default is not to allocate an overlay plane. Note that overlay planes effectively consume half the available colours on the X server so an overlay should be specified only when required.
-title title
The window title that is displayed in the window’s title bar; title is a character string. If it contains spaces or other special characters it must be enclosed in quotes Example:
  xmake test -title Test\_Window

The default title is “GWM Window - window name

There are defaults for all these options but they are not necessarily appropriate. You can provide your own defaults by putting them in your “X defaults” file (˜/.Xdefaults) and to have different defaults for different window names. If you edit your X defaults file, the changes won’t have any effect until they have been loaded into the resource database in your X server. This is normally done by the window manager when you first log in to the server but can be done explicitly with the command:

  xrdb -merge \$HOME/.Xdefaults

Rather than attempting to explain in detail what is a powerful but quite complicated system here is an example that shows how to control the properties of GWM windows. Suppose your X defaults file contains the following:

  Gwm.mono*colours: 2
  Gwm*colours: 128

then a window created with the name “mono” will have 2 colours allocated to it and windows with any other names will have 128 colours allocated.

When a graphics package creates a window for you this is the only mechanism available for specifying the properties of the window. For example, GKS will create a window if it doesn’t already exist and each of the four available workstation types of X windows can be assigned different properties as follows:

  Gwm*foreground: Black
  Gwm*background: White
  Gwm.GKS\_3800*colours: 2
  Gwm.GKS\_3800*geometry: 512x380
  Gwm.GKS\_3801*colours: 8
  Gwm.GKS\_3801*geometry: 780x512
  Gwm.GKS\_3802*colours: 128
  Gwm.GKS\_3802*geometry: 780x512
  Gwm.GKS\_3803*colours: 128
  Gwm.GKS\_3803*interactive: True

This defines workstation type 3800 as being a small window with only two colours, suitable for black and white line plots, 3801 is a bit bigger and has 8 colours suitable for colour line plots, 3802 is the same size but with more colours for image display applications and 3803 is the same but the window size is set interactively.

A complete list of the resources used and their default values are shown in Table 1.

Table 1: GWM X resources

Resource name Default

background Black borderWidth 10 colours 0 foreground White geometry 780x512 overlay False overlayColour iconic False interactive False title