# Eterm Technical Reference

This document covers the technical aspects of Eterm, including escape sequences it supports, "under-the-hood" descriptions of certain Eterm features, etc. Portions of this document were taken from the XTerm documentation.

## Table of Contents

1. Document Conventions
2. Symbols
3. Escape Sequences
   - Escape Codes Eterm Knows
   - Image Escape Sequences
   - Mouse Reporting
4. Key Sequences
5. Eterm Extensions, Standards, and Implementations
   - Eterm Proprietary Escape Sequences
   - Transparency

## Document Conventions

Convention | Meaning
`c` | A literal. It should be typed as shown.
`SYM` | A symbol. Replace with the proper character. See the symbol table below for a listing of the symbols used and their meanings.
text | A parameter. Replace the italicized text with a parameter. The text itself generally describes the type of parameter needed.
[ ... ] | Items enclosed in brackets are optional.
{ ... | ... } | Items inclosed in braces and separated by pipes indicate that exactly one of the items should be chosen.

## Symbols

Symbol | Meaning
`BEL` | Bell (Ctrl-G)
`BS` | Backspace (Ctrl-H)
`CR` | Carriage Return (Ctrl-M)
`ENQ` | Enquiry (Ctrl-E), Send Device Attributes (DA). Eterm ignores ENQ if NO_ENQ_ANS is defined, which it is by default in `src/feature.h`.
`ESC` | Escape (Ctrl-[)
`FF` or `NP` | Form Feed or New Page(Ctrl-L)
`LF` or `NL` | Line Feed or New Line (Ctrl-J)
`SO` | Shift Out (Ctrl-N), invokes the G1 (alternate) character set
`SI` | Shift In (Ctrl-O), invokes the G0 (default) character set
`SPC` | Space
`TAB` or `HT` | Horizontal Tab (Ctrl-I)
`VT` | Vertical Tab (Ctrl-K)

## Escape Sequences

Sequence | Function
`ESC { ( | ) | * | + | $ } { 0 | A | B }` | Select ISO 2022 character sets. `(` sets the G0 character set `)` sets the G1 character set `*` sets the G2 character set `+` sets the G3 character set `$` sets the Kanji character set `0` uses the DEC Special Character and Line Drawing set `A` uses the United Kingdom (UK) character set `B` uses the United States (USASCII) character set
`ESC 7` | Save cursor (SC)
`ESC 8` | Restore cursor (RC)
`ESC =` | Application Keypad (SMKX)
`ESC >` | Numeric Keypad (RMKX)
`ESC @` | Discards the subsequent character
`ESC D` | Index (IND)
`ESC E` | Next Line (NEL)
`ESC G` | Graphics (an rxvt extension). Eterm replies to `ESC G Q` (query graphics) with `ESC G 0` (no graphics available) and ignores all other graphics sequences.
`ESC H` | Tab Set (HTS)
`ESC M` | Reverse Index (RI)
`ESC Z` | Obselete form of Send Device Attributes (DA), which is `ESC [ c`
`ESC [ [ n ] @` | Insert n blank Characters (ICH). Default for n is 1.
`ESC [ [ n ] A` | Cursor Up n times (CUU), default 1
`ESC [ [ n ] B` | Cursor Down n times (CUD), default 1
`ESC [ [ n ] C` | Cursor Forward n times (CUF), default 1
`ESC [ [ n ] D` | Cursor Backward n times (CUB), default 1
`ESC [ [ n ] E` | Cursor Down n times and to first column, default 1
`ESC [ [ n ] F` | Cursor Up n times and to first column, default 1
`ESC [ [ n ] G` | Cursor to Column n (HPA)
`ESC [ [ r ; c ] H` | Cursor Position [row;column] (CUP), default 1;1
`ESC [ [ n ] I` | Move forward n tab stops, default 1
`ESC [ [ n ] J` | Erase in Display (ED) n == 0: Clear Below (default) n == 1: Clear Above n == 2: Clear All
`ESC [ [ n ] K` | Erase in Line (EL) n == 0: Clear to Right (default) n == 1: Clear to Left (EL1) n == 2: Clear All
`ESC [ [ n ] L` | Insert n lines (IL), default 1
`ESC [ [ n ] M` | Delete n lines (DL), default 1
`ESC [ [ n ] P` | Delete n characters (DCH), default 1
`ESC [ [ n ] W` | Tabulator functions n == 0: Tab Set (HTS) n == 2: Tab Clear (TBC), clear current column n == 5: Tab Clear (TBC), clear all
`ESC [ [ n ] X` | Erase n characters (ECH), default 1
`ESC [ [ n ] Z` | Move backward n tabstops, default 1
`ESC [ [ n ] `` | Same as `ESC [ n G (HPA)`
`ESC [ [ n ] a` | Same as `ESC [ n C (CUF)`
`ESC [ [ n ] c` | Send Device Attributes (DA), default of 0 returns "`ESC[?1;2c`" indicating a VT100 with advanced video option
`ESC [ [ n ] d` | Cursor to line n (VPA)
`ESC [ [ n ] e` | Same as `ESC [ n A (CUU)`
`ESC [ [ r ; c ] f` | Horizontal and Vertical Position (HVP), default 1;1
`ESC [ [ n ] g` | Tab Clear n == 0: Tab Clear (TBC), clear current column (default) n == 3: Tab Clear (TBC), clear all
`ESC [ [ n ] i` | Printing n == 4: Disable transparent print mode (MC4) n == 5: Enable transparent print mode (MC5)
`ESC [ n [ ; n ... ] { h | l }` | h: Set Mode (SM) l: Reset Mode (RM) n == 4: Insert Mode (SMIR)/Replace Mode (RMIR) n == 20: Automatic Newline/Normal Linefeed (LNM)
`ESC [ n [ ; n ... ] m` | Character Attributes (SGR) n == 0: Normal (default) n == 1/22: Turn bold (bright fg) on/off n == 4/24: Turn underline on/off n == 5/25: Turn "blink" (bright bg) on/off n == 7/27: Turn inverse on/off n == 30/40: foreground/background black n == 31/41: foreground/background red n == 32/42: foreground/background green n == 33/43: foreground/background yellow n == 34/44: foreground/background blue n == 35/45: foreground/background magenta n == 36/46: foreground/background cyan n == 37/47: foreground/background white n == 39/49: foreground/background default
`ESC [ [ n ] n` | Device Status Report (DSR) n == 5: Status Report, returns "`ESC[0n`" ("OK") n == 6: Report Cursor Position (CPR) as "`ESC[r;cR`" n == 7: Request display name (ignored by default for security reasons) n == 8: Request version number in window title n == 9: Display pixmap/transparency status in window title (See below.)
`ESC [ [ t ; b ] r` | Set Scrolling Region (CSR), where t is the top row and b is the bottom row, defaults to the full screen
`ESC [ ? n [ ; n ... ] { h | l | s | r | t }` | DEC Private Modes (shown as set/reset) h: Set Private Mode (DECSET) l: Reset Private Mode (DECRST) s: Save all DEC Private Mode values r: Restore previously-saved DEC Private Mode values t: Toggle Private Mode (rxvt/Eterm extension) n == 1: Application/Normal cursor keys (DECCKM) n == 3: 132/80 column mode (DECCOLM) n == 4: Smooth/Jump scrolling (DECSCLM) [not yet implemented] n == 5: Reverse/Normal video (DECSCNM) n == 6: Origin/Normal cursor mode (DECOM) n == 7: Wraparound mode on/off (DECAWM) n == 9: (X10 Xterm mouse reporting) Do/Don't send mouse coords on button press (see below) n == 25: Visible/invisible cursor n == 30: Toggle scrollbar on/off (rxvt/Eterm extension) n == 35: Allow/Disallow xterm shift+key sequences (rxvt/Eterm extension) n == 40: Allow/Disallow 80 <--> 132 mode n == 47: Use Alternate/Normal screen buffer n == 66: Application/Normal keypad (DECPAM) n == 67: Backspace key sends BS/DEL (DECBKM) n == 1000: (X11 Xterm mouse reporting) Do/Don't send mouse coords on button press and release (see below) n == 1010: Scroll to bottom on tty output n == 1012: Scroll to bottom on tty input
`ESC [ n [ ; n [ ... ] ] t` | Window Operations n == 1: Un-iconify window n == 2: Iconify window n == 3: Move window. Must by followed by `;x;y` n == 4: Resize window. Must by followed by `;height;width` n == 5: Raise window n == 6: Lower window n == 7: Refresh window n == 8: Resize text area. Must by followed by `;height;width`, with height and width given in characters. n == 11: Report icon state. (not implemented) n == 13: Report window position as `ESC[3;x;yt` n == 14: Report window size in pixels as `ESC[4;height;widtht` n == 18: Report text area size in characters as `ESC[4;height;widtht` n == 20: Report icon name as `ESC]LnameESC\` n == 21: Report window title as `ESC]ltitleESC\`
`ESC ] n ; string BEL` | Set X Terminal Parameters n == 0: Change icon name and window title to string n == 1: Change icon name to string n == 2: Change window title to string n == 3: Set text property string (format: var=value) n == 5: Steal input focus and raise window (See below.) n == 6: Eterm-specific escape sequences (See below.) n == 20: Image commands (see below) n == 30: Dump contents of scrollback to file string n == 39: Set the default foreground color to string n == 49: Set the default background color to string n == 50: Set font to string. rxvt/Eterm extensions: string == "#+n": Change font up by n, default 1 string == "#-n": Change font down by n, default 1 string empty: Change to font 0 string == "#n": Change to font n
`ESC ] { l | L | I } string ESC \` | `l`: Change window title to string `L`: Change icon name to string `I`: Read new icon image from file whose path is string
`ESC ] P n rr gg bb` | Changes terminal color n ('0' through 'f') to the color represented by the RGB values rr, gg, and bb. (Compatible with Linux console.)
`ESC ] R` | Restores the original palette. (Compatible with Linux console.)
`ESC c` | Full Reset (RIS)
`ESC n` | Invoke the G2 character set (LS2)
`ESC o` | Invoke the G3 character set (LS3)

## Escape Codes Eterm Knows

Escaped String | Meaning
Backslash-Escaped Characters (case is ignored)
`\a` | `BEL` (Alert)
`\b` | `BS`
`\cX` | Interpreted as Ctrl-X. Analogous to `^X`.
`\e` | `ESC`
`\f` | `FF`
`\n` | `LF`
`\r` | `CR`
`\t` | `TAB`
`\v` | `VT`
`\nnn` | nnn is interpreted as an octal number, and the corresponding character is inserted.
Convenience Shortcuts
`^X` | Interpreted as Ctrl-X. X can be any character between `@` and `_`. Case is ignored.
`C-X` | Interpreted as Ctrl-X. Analogous to `^X`.
`M-X` | Interpreted as `ESC` followed by X. Analogous to `\eX`. If the string begins with `M-`, a `CR` is automatically appended to the end of the string if not already present.

### Image Escape Sequences

The string supplied to the image escape sequence (above) consists of a filename (which can be empty) followed by a semicolon, then one or more geometry strings. Each geometry string contains zero or one scale/position adjustment and may optionally be followed by a colon and one or more colon-delimited pixmap operations. The following table shows the valid geometry strings and their affects on the background image:

String | Function
Adjusting scaling and position
`WxH+X+Y` | Set scaling to W% by H%, and position to X% by Y%. W and H are percentages of the terminal window size. X and Y are also percentages; e.g., +50+50 centers the image in the window.
`WxH+X` | Assumes Y == X
`WxH` | Assumes Y == X == 50 (centers the image)
`W+X+Y` | Assumes H == W
`W+X` | Assumes H == W and Y == X
`W` | Assumes H == W and Y == X == 50
Adjusting position only
`=+X+Y` | Set position to X% by Y% (absolute).
`=+X` | Set position to X% by X%.
`+X+Y` | Adjust position horizontally X% and vertically Y% from current position (relative).
`+X+X` | Adjust position horizontally X% and vertically X% from current position.
Adjusting scale only
`Wx0` | Multiply horizontal scaling factor by W%
`0xH` | Multiply vertical scaling factor by H%
`0x0` | No scaling (show image at normal size).
Pixmap Operations
`tile` | Tile image. Scaling/position modifiers above will affect the tile size and origin.
`propscale` | When scaling, scale proportionally. That is, maintain the proper aspect ratio for the image. Any portion of the background not covered by the image is filled with the current background color.

Examples:

- "`\e]20;Dragon.jpg\007`" -- Set background image to "Dragon.jpg"
- "`\e]20;Canyon.jpg;200\007`" -- Set background image to "Canyon.jpg", scaling to 200% by 200%, and center it.
- "`\e]20;;100\007`" -- Set scaling back to 100%
- "`\e]20;blackstone.png;0x0\007`" -- Set background image to "blackstone.png", centered and at original size
- "`\e]20;;:tile\007`" -- Tile current image instead of scaling

### Mouse Reporting

When Eterm receives a mouse reporting request (and if mouse reporting is currently enabled), it replies with the sequence "`ESC[Mbxy`". The values for b, x, and y are as follows (subtract the value of space ' ' first):

- Button status: The lower 2 bits of b indicate the button status, with 00 indicating Button1 down, 01 indicating Button2 down, 10 indicating Button3 down, and 11 indicating the button was released. (`button = b & 0x3 - ' '`)
- Modifier status: The upper bits of b are used to flag which modifiers were active when the button was pressed. The low bit is the Shift flag, the middle is Meta, and the high bit is Control. (`mod = b & 0x1c - ' '`)
- Coordinates: x and y are the column and row, respectively. (`c = x - ' '; r = y - ' '`)

## Key Sequences

Cursor Keys
Key Pressed | What Eterm Sends
Normal | Shift | Control | Application
Up | `ESC [ A` | `ESC [ a` | `ESC O a` | `ESC O A`
Down | `ESC [ B` | `ESC [ b` | `ESC O b` | `ESC O B`
Right | `ESC [ C` | `ESC [ c` | `ESC O c` | `ESC O C`
Left | `ESC [ D` | `ESC [ d` | `ESC O d` | `ESC O D`
Special Keys
Key Pressed | Normal | Shift | Control | Control+Shift
Tab | `^I` | `ESC [ Z` | `^I` |
Backspace | `^H` | `^?` | `^?` |
Home (Find) | `ESC [ 1 ~` | `ESC [ 1 $` | `ESC [ 1 ^` | `ESC [ 1 @`
End (Select) | `ESC [ 4 ~` | `ESC [ 4 $` | `ESC [ 4 ^` | `ESC [ 4 @`
Insert | `ESC [ 2 ~` | `Paste mouse selection` | `ESC [ 2 ^` | `ESC [ 2 @`
Delete (Execute) | `ESC [ 3 ~` | `ESC [ 3 $` | `ESC [ 3 ^` | `ESC [ 3 @`
PageUp (Prior) | `ESC [ 5 ~` | `Scroll up one page` | `ESC [ 5 ^` | `ESC [ 5 @`
PageDown (Next) | `ESC [ 6 ~` | `Scroll down one page` | `ESC [ 6 ^` | `ESC [ 6 @`
Function Keys (Note: Shift-F1 through F10 sends F11-F20)
Key Pressed | Normal | Shift | Control | Control+Shift
F1 | `ESC [ 11 ~` | `ESC [ 23 ~` | `ESC [ 11 ^` | `ESC [ 23 ^`
F2 | `ESC [ 12 ~` | `ESC [ 24 ~` | `ESC [ 12 ^` | `ESC [ 24 ^`
F3 | `ESC [ 13 ~` | `ESC [ 25 ~` | `ESC [ 13 ^` | `ESC [ 25 ^`
F4 | `ESC [ 14 ~` | `ESC [ 26 ~` | `ESC [ 14 ^` | `ESC [ 26 ^`
F5 | `ESC [ 15 ~` | `ESC [ 28 ~` | `ESC [ 15 ^` | `ESC [ 28 ^`
F6 | `ESC [ 17 ~` | `ESC [ 29 ~` | `ESC [ 17 ^` | `ESC [ 29 ^`
F7 | `ESC [ 18 ~` | `ESC [ 31 ~` | `ESC [ 18 ^` | `ESC [ 31 ^`
F8 | `ESC [ 19 ~` | `ESC [ 32 ~` | `ESC [ 19 ^` | `ESC [ 32 ^`
F9 | `ESC [ 20 ~` | `ESC [ 33 ~` | `ESC [ 20 ^` | `ESC [ 33 ^`
F10 | `ESC [ 21 ~` | `ESC [ 34 ~` | `ESC [ 21 ^` | `ESC [ 34 ^`
F11 | `ESC [ 23 ~` | `ESC [ 23 $` | `ESC [ 23 ^` | `ESC [ 23 @`
F12 | `ESC [ 24 ~` | `ESC [ 24 $` | `ESC [ 24 ^` | `ESC [ 24 @`
F13 | `ESC [ 25 ~` | `ESC [ 25 $` | `ESC [ 25 ^` | `ESC [ 25 @`
F14 | `ESC [ 26 ~` | `ESC [ 26 $` | `ESC [ 26 ^` | `ESC [ 26 @`
F15 (Help) | `ESC [ 28 ~` | `ESC [ 28 $` | `ESC [ 28 ^` | `ESC [ 28 @`
F16 (Menu) | `ESC [ 29 ~` | `ESC [ 29 $` | `ESC [ 29 ^` | `ESC [ 29 @`
F17 | `ESC [ 31 ~` | `ESC [ 31 $` | `ESC [ 31 ^` | `ESC [ 31 @`
F18 | `ESC [ 32 ~` | `ESC [ 32 $` | `ESC [ 32 ^` | `ESC [ 32 @`
F19 | `ESC [ 33 ~` | `ESC [ 33 $` | `ESC [ 33 ^` | `ESC [ 33 @`
F20 | `ESC [ 34 ~` | `ESC [ 34 $` | `ESC [ 34 ^` | `ESC [ 34 @`
Keypad
Key Pressed | Normal | Application
KP_Enter | `^M` | `ESC O M`
KP_F1 | `ESC O P` | `ESC O P`
KP_F2 | `ESC O Q` | `ESC O Q`
KP_F3 | `ESC O R` | `ESC O R`
KP_F4 | `ESC O S` | `ESC O S`
XK_KP_Multiply | `*` | `ESC O j`
XK_KP_Add | `+` | `ESC O k`
XK_KP_Separator | `,` | `ESC O l`
XK_KP_Subtract | `-` | `ESC O m`
XK_KP_Decimal | `.` | `ESC O n`
XK_KP_Divide | `/` | `ESC O o`
XK_KP_0 | `0` | `ESC O p`
XK_KP_1 | `1` | `ESC O q`
XK_KP_2 | `2` | `ESC O r`
XK_KP_3 | `3` | `ESC O s`
XK_KP_4 | `4` | `ESC O t`
XK_KP_5 | `5` | `ESC O u`
XK_KP_6 | `6` | `ESC O v`
XK_KP_7 | `7` | `ESC O w`
XK_KP_8 | `8` | `ESC O x`
XK_KP_9 | `9` | `ESC O y`

## Eterm Extensions, Standards, and Implementations

### Eterm Proprietary Escape Sequences

The table below contains a listing of all the Eterm-specific escape sequences that Eterm supports. These sequences were created by the Eterm authors. Please note the following conventions used in this table:

When an escape sequence is said to "set/toggle" an option, this means that the boolean parameter of the sequence is optional. If given, it will either set or unset the option. If omitted, the current state of that option will be reversed (i.e., turned off if on, or on if off). Acceptable values for "true" are: `1`, `on`, `yes`, or (of course) `true`. Likewise, acceptable values for "false" are: `0`, `off`, `no`, or `false`.

Sequence | Function
`ESC [ 9 n` | Titlebar Status. This places Eterm's current status in the titlebar. The status information includes the application name and version number, as well as the shading/tinting state if transparent, the path to the background image if there is one, or "No Pixmap" if neither of these is true.
`ESC ] 5 ; BEL` | Steal Focus. Eterm will raise itself to the top and steal keyboard/mouse focus. This is useful in case your window manager dies or has trouble starting up. By default, this is activated by holding the Ctrl key and clicking on the Eterm window with the left mouse button (Button1).
`ESC ] 6 ; 0 [ ; boolean ] BEL` | Set/toggle transparency state. This affects all images for which transparency is an allowed mode.
`ESC ] 6 ; 1 ; [ class ; ] color ; attribute ; value BEL` | Adjusts a color modifier. class determines which image class will have its color modifier altered: bg (background, the default), up (up arrow), down (down arrow), sb (scrollbar trough), sa (scrollbar anchor), st (scrollbar thumb), menu (popup menu background), menuitem (popup menu items), submenu (menu items which represent submenus), button (buttons on the buttonbar), or bbar (buttonbar). Next comes the color which determines how pixels are modified. This is either image, red, green, or blue. attribute is one of brightness, contrast, or gamma, and value is the actual integer value (>= 0). As stated in the man page, 256 (0x100) is 100%.
`ESC ] 6 ; 2 ; { shade | tint } [ class ; ] value BEL` | Shade/tint the specified class (see above). For shading, value is the shade percentage. For tinting, it is the tint color or mask.
`ESC ] 6 ; 3 ; BEL` | Force an update the of transparency background.
`ESC ] 6 ; 10 ; [ type ] [ ; width ] BEL` | Set scrollbar style to type and scrollbar width to width. If specified, type must be one of `motif`, `xterm`, or `next`. If you omit the type parameter and only wish to set the width, take care not to omit the extra semicolon. width is an integer. Its value is fairly wide-open, but should be something reasonable.
`ESC ] 6 ; 11 [ ; boolean ] BEL` | Set/toggle right-side scrollbar.
`ESC ] 6 ; 12 [ ; boolean ] BEL` | Set/toggle floating scrollbar (i.e., one with no trough).
`ESC ] 6 ; 13 [ ; boolean ] BEL` | Set/toggle popup scrollbar (i.e., one that appears when the window has focus and disappears when it does not).
`ESC ] 6 ; 14 [ ; boolean ] BEL` | Set/toggle display of buttonbars.
`ESC ] 6 ; 20 [ ; boolean ] BEL` | Set/toggle visual bell.
`ESC ] 6 ; 21 [ ; boolean ] BEL` | Set/toggle map alert.
`ESC ] 6 ; 22 [ ; boolean ] BEL` | Set/toggle xterm's cutchar selection behavior.
`ESC ] 6 ; 23 [ ; boolean ] BEL` | Set/toggle selection of the whole line by triple-click.
`ESC ] 6 ; 24 [ ; boolean ] BEL` | Set/toggle viewport mode for all images that have allowed viewport mode.
`ESC ] 6 ; 25 [ ; boolean ] BEL` | Set/toggle selection trailing spaces.
`ESC ] 6 ; 26 [ ; boolean ] BEL` | Set/toggle reporting as keysyms. See the man page for details.
`ESC ] 6 ; 27 [ ; boolean ] BEL` | Set/toggle the refusal of keyboard input and focus.
`ESC ] 6 ; 50 ; desktop BEL` | Move Eterm to desktop desktop and make it the current desktop. This requires a GNOME-compliant Window Manager, such as Enlightenment.
`ESC ] 6 ; 72 [ ; string ] BEL` | Search for and highlight any occurances of string in the scrollback buffer.
`ESC ] 6 ; 80 ; level BEL` | Set the debugging level to level.

### Transparency

The standard for implementing transparency was a mutual effort between myself, Carsten Haitzler <raster@rasterman.com>, Gerald Britton <gbritton@mit.edu>, and Nat Friedman <nat@nat.org>, based off of an original idea by Nat. First I'll define the standard, then I'll discuss its justification.

There are two separate procedures for setting the transparency property (the _XROOTPMAP_ID atom in X). The first is for persistent X clients such as window managers. These clients should proceed through their normal mechanism for setting the desktop image. Once the finalized pixmap has been created, the _XROOTPMAP_ID property should be set on the desktop window (the same window which will receive the pixmap...note that this is not necessarily the root window), and its value should be set to the Pixmap ID. The following sample code (taken from Enlightenment) demonstrates this:

    /* disp is the Display, win is the desktop Window, pmap is the pixmap */
    static Atom prop = 0;

    if (!prop) {
      prop = XInternAtom(disp, "_XROOTPMAP_ID", False);
    }
    XChangeProperty(disp, win, prop, XA_PIXMAP, 32, PropModeReplace,
                    (unsigned char *)&pmap, 1);
    XSetWindowBackgroundPixmap(disp, win, pmap);
    XClearWindow(disp, win);

The second procedure is for temporary clients; i.e., clients who set the desktop pixmap and then exit. An example of this type of client would be Esetroot, the transparency utility provided with Eterm. These clients should set the _XROOTPMAP_ID property just like the persistent client does. They should also set a companion property as well, ESETROOT_PMAP_ID. Both are set to the same pixmap ID. When a temporary client runs, it checks to see if _XROOTPMAP_ID and ESETROOT_PMAP_ID have the same value. If so, the client knows that it can safely do an XKillClient() on the pixmap ID. This will save memory, as the old pixmap can be removed. If they are not equal, however, calling XKillClient() would kill the persistent client which did set it, most likely the user's window manager. This would be a Bad Ideatm. The following code fragment (taken from Esetroot) illustrates this process:

    /* disp is the Display, win is the desktop Window, pmap is the pixmap */
    Atom prop_root, prop_esetroot, type;
    int format;
    unsigned long length, after;
    unsigned char *data_root, *data_esetroot;

    /* First check to see if the properties already exist, and if they are equal */
    prop_root = XInternAtom(disp, "_XROOTPMAP_ID", True);
    prop_esetroot = XInternAtom(disp, "ESETROOT_PMAP_ID", True);

    if (prop_root != None && prop_esetroot != None) {
      XGetWindowProperty(disp, win, prop_root, 0L, 1L, False, AnyPropertyType,
                         &type, &format, &length, &after, &data_root);
      if (type == XA_PIXMAP) {
        XGetWindowProperty(disp, win, prop_esetroot, 0L, 1L, False, AnyPropertyType,
                           &type, &format, &length, &after, &data_esetroot);
        if (data_root && data_esetroot && type == XA_PIXMAP && *((Pixmap *) data_root) == *((Pixmap *) data_esetroot)) {
          /* It's safe.  Kill the pixmap. */
          XKillClient(disp, *((Pixmap *) data_root));
        }
      }
    }

    /* This will locate the property, creating it if it doesn't exist */
    prop_root = XInternAtom(disp, "_XROOTPMAP_ID", False);
    prop_esetroot = XInternAtom(disp, "ESETROOT_PMAP_ID", False);

    /* The call above should have created it.  If that failed, we can't continue. */
    if (prop_root == None || prop_esetroot == None) {
      fprintf(stderr, "Error:  Creation of pixmap property failed.\n");
      exit(1);
    }
    XChangeProperty(disp, win, prop_root, XA_PIXMAP, 32, PropModeReplace,
                    (unsigned char *) &pmap, 1);
    XChangeProperty(disp, win, prop_esetroot, XA_PIXMAP, 32, PropModeReplace,
                    (unsigned char *) &pmap, 1);
    XSetCloseDownMode(disp, RetainPermanent);

When the client runs, it looks for the _XROOTPMAP_ID property on the desktop window. (The client searches through all its parent windows until it either finds one with this property set, or hits the root window without finding it.) If the client finds this property, it can then use the pixmap directly, or make a copy of the pixmap in order to perform additional operations on it (such as brightening, shading, tinting, etc.).

So why use this technique? Why require such support from the window manager and other external applications? Why not simply set the background to `ParentRelative` and be done with it? let X handle everything? This seems to be a point of great confusion lately. Those who have taken the time to put the other terminal emulators who have chosen the latter route through their paces already know the answer: Power. Very simply, you have *much* greater power and flexibility with this technique than any other. X only permits a limited amount of flexibility when copying the background directly (basically just bitwise logical operations). The above technique allows programs to tint, shade, brighten, or otherwise manipulate the image in *any* way they see fit. Want a 10% shade? A 30% shade? Maybe a light cyan tint? Or perhaps you prefer a midnight blue tint.... With this technique, you can have it *your* way, not their way.