Debian X Window System Frequently Asked Questions (FAQ) List

Copyright 1998, 1999 Branden Robinson.  This document is licensed under the
GNU General Public License (see /usr/doc/copyright/GPL).

This document isn't complete yet.  If your question is not answered here,
try /usr/doc/<packagename>/README.Debian (and other files in the package's
doc directory), manual pages, and the debian-user mailing list.  See
http://www.debian.org/ for more information about the Debian mailing lists.

CONTENTS

General Questions
*) What is the X Window System?
*) What is XFree86?
*) What are X servers and X clients?
*) Why is the X usage of "server" and "client" backwards from everyone else's?
*) What is an X session?
*) What is the root window?
*) What is a window manager?
*) What is a session manager?
*) What is window focus?
*) What are X resources?

How-To Questions
*) How do I customize my X session?
*) How do I change what appears in the root window?
*) How do I change the color depth of my X server?
*) How do I run more than one X local server simultaneously?
*) How do I set up the mouse buttons for left-handed use?

GENERAL QUESTIONS

*) What is the X Window System?

In the words of its primary manual page, X(1), it is a "portable,
network-transparent window system".  Its primary distinction from other
well-known window systems like Microsft Windows and Apple's MacOS is that it
was designed with the local area network in mind.  You can run programs on
one machine and display them on another.

Historically, the X Window System was initially conceived in 1984, at the
Massachusetts Institute of Technology as a joint project between their
Laboratory for Computer Science and the Digital Equipment Corporation.
This joint effort was called "Project Athena", and was headed by Bob
Scheifler.  The first version of the X Window System to be widely deployed
was Version 10 (X10).  It was shortly superseded by Version 11 (X11),
however, in 1987.

In 1988, a non-profit group called the (MIT) X Consortium was formed to
direct future development of X standards in an atmosphere inclusive of many
commercial and educational interests.  The X Consortium produced several
significant revisions to X11, concluding with Release 6 in 1994 (X11R6).

The X Consortium dissolved at the end of 1996, producing a final, small
revision to X11R6 called X11R6.3.  Ownership of X then passed to the Open
Group.  In early 1998, the Open Group released a further revision to X11R6,
called X11R6.4 -- a departure from the traditional licensing terms,
however, prevented adoption of this version of the X Window System by many
vendors, including the XFree86 Project, Inc. (see below).  In late 1998,
the Open Group relicensed X11R6.4 under terms identical with the
traditional license, and support for X11R6.4 is expected soon.

*) What is XFree86?

Strictly speaking, the various groups that have developed the X Window
System over the years have been standardization groups, not software
developers.  However, they have also developed a reference implementation of
the standards, and this source code is what is popularly called the X Window
System.  The license on this source code freely permits modification and
redistribution, and this what many software vendors have done.

The XFree86 Project, Inc., is a not-for-profit group whose original,
self-determined charter was to develop X servers that would work on the
wide variety of video hardware available for Intel x86-based machines
(hence the "86" in "XFree86").  They also decided to release their X
servers under licensing terms identical to that of the freely available
X sources, hence the "Free" in the "XFree86".  By keeping with the
licensing terms of the original X source distribution, XFree86 has enjoyed
immense popularity, and they no longer confine their activities to merely
producing X servers for IBM PC-compatible video hardware.

XFree86 is thus the superset of the X Window System that is used by the
Debian GNU/Linux system.

*) What are X servers and X clients?

This is the most important, and probably the first, concept a newcomer to
the X Window System should learn.

X achieves its success by separating the details of display and input
hardware from the programs that use them.  When a program that uses the X
Window System needs to, for instance, draw on the screen, or know what keys
on the keyboard have just been pressed, it does not communicate directly
with the hardware.  Instead, it communicates with a single program, called
the X server, whose job it is to deal with a computer's video card (and
thus monitor), keyboard, and mouse (or other pointing device).  The
programs, then, that wish to use the windowing system to interact with the
user are thus called X clients.  The program that actually "delivers the
goods", both to the user in the form of displayed graphics, and to the
program in the form of information about pressed keys or a moving mouse, is
the X server.

Commonly, an individual machine like a workstation or X terminal, only runs
one X server, to which many X clients "connect" and perform their tasks.
In fact, however, on a Linux machine, more than one X server can be running
at one time.

*) Why is the X usage of "server" and "client" backwards from everyone else's?

People who have worked in LAN-type environments are easily confused by the
X notions of client and server.  In such a scenario, one might have dozens
of "client" machines, each running an X server which uses the network to
connect to X clients (application programs) running on the "server" in the
machine room.

However, X's client/server terminology makes perfect sense if one thinks
about what resources are in demand, and what program's job it is to service
requests.  On the computer where a human being is actually sitting down and
working, the resources in demand are the video display, keyboard, and mouse
(or other pointing device).  All of the running programs can't monoplize these
resources at once, or we lose the benefits of multitasking that a windowing
system gives us.  Furthermore, why should each and every piece of software,
like a mail reader, a clock application, and so forth, have to worry about
things like how many buttons the mouse has, or how many colors the display
can show at once?  The X server centralizes this information and manages
the hardware resources, which it serves to the X clients.

*) What is an X session?

An X session is the set of X clients running that correspond to a single
server process, which typically corresponds to one user's login.

In other words, when I start X from the command line with "startx", or if a
display manager like xdm is running and presents me with a graphical login
screen and I type my username and password, what happens next is my X
session.  People generally customize their X sessions to start a set of
familiar, desirable applications, like a clock, a graphical "biff" program
that tells them when they have new email, one or more terminal sessions on
various other computers, and so forth.  The X session is terminated by
"killing" the X server.  The X server may be killed by the
<CTRL-ALT-BACKSPACE> key sequence, or by stopping a particular program
(like the window manager), which is "tied" to the X server.  When that
particular program ends, the X server automatically exits.  (The X server
may also terminate if some abnormal condition happens, like one of its X
clients causes it to coredump.)  If no display manager is running, the
system returns to the command line prompt.  If a display manager is
running, the X server is restarted with no one logged in -- a graphical
prompt for a username and password is displayed instead.

Like Unix shell login sessions, which are customized by a file like
.login or .profile in the user's home directory, X sessions can be
customized on a per-user basis as well.  In the Debian GNU/Linux system,
creating and editing the .xsession file in the user's home directory is
the preferred method of customizing an X session.  See
/usr/doc/xfree86-common/examples/xsession for more information.

*) What is the root window?

Like the Unix filesystem, windows in X are laid out like a tree with a
single "root".  The root window is the window that is "behind" all others,
and covers the entire screen from corner to corner (in fact, if the virtual
desktop feature of the XFree86 X servers is used, the root window can
actually be larger than the screen).  People often place an image of some
sort in the root window ("wallpaper"), or run a program which draws
something interesting and/or pleasing in the root window.

*) What is a window manager?

In other window systems like Microsoft Windows or MacOS, the concept of
"window manager" is not obviously distinct from the rest of the window
system.  X, however, was designed from the beginning to maximize
customizability, and to impose as little on the user as possible.

The window manager is what copes with the fact that in a windowing system,
one generally has more than window on the screen (if this were not the
case, one might wonder why a windowing system were being used at all).

Fundamentally, the window manager is in charge of window placement.
In practice, X window managers over the years have acquired more and
more features.  The typical window manager in use today draws borders
around the windows which can be used to resize the window by grabbing,
determines the focus policy, and presents menus which permit the
iconification ("minimizing") or easy killing of X clients.

Some window managers go farther and do some tasks of session management as
well.

*) What is a session manager?

Rather than having a static list of X clients to be launched each time the
X Window System starts, as is often the case in a user's .xsession file, it
is possible to have a special X client run whose job it is to keep track of
the other X clients, and "remember" the state of these programs between X
sessions.  Needless to say, an X client has to support the saving of its
state between sessions, because when the X server dies, the clients that
are connected to it die as well.  When a session manager is run with X
clients that support session management, a user can end his X session, and
when he comes next starts it, he will be greeted with a screen that looks
just the one he had when he left -- windows in the same locations,
applications with the same files open, etc.

*) What is window focus?

The keyboard can only be used to "type into" one X client at a time.  The
mouse is used to determine which client has "focus", or recives keyboard
events.  There are two major kinds of focus, "pointer" and "explicit".

Pointer focus, also known as "focus-follows-mouse", means that wherever
the mouse cursor is, that window has focus.  Explicit focus, or
"click-to-type", means that a mouse button (usually the first, or
leftmost on a right-handed mouse) must be clicked on a window with the
mouse pointer over it for focus to change to that window.

The focus policies available are determined by the window manager.
Traditionally, pointer focus, or something very similar, is used in the X
Window System -- but there is no reason explicit focus cannot be used, and
X clients work equally well with either focus policy.

*) What are X resources?

X clients are typically customizable in their appearance and behavior in a
very large number of ways.  It would be very cumbersome to require X
clients to be called with command-line arguments specifying each of the
configurable parameters.  Therefore, the X server maintains a database of X
resources.  When an X client connects to an X server, it inherits a set of
properties from the X server that correspond to it.

The strength of X resources is at the same what makes them intimidating;
they are hierarchical and can be as general or as specific as is desired.
Almost all X clients, for example, recognize resources called "foreground"
and "background", and if the X server contains an appropriately general
resource for these properties, every X client that recognizes them will use
them.

[much more remains to be written here]

HOW-TO QUESTIONS

*) How do I customize my X session?

On a Debian GNU/Linux system, the file $HOME/.xsession is used (if present)
to setup the user's X session.  The file
/usr/doc/xfree86-common/examples/xsession is an example file that may be
used directly and contains a great deal of explicit instruction on
customization.

*) How do I change what appears in the root window?

There are many X clients that can draw on the root window.  xsetroot, which
comes with the basic X distribution, is one.  It is found in the
xbase-clients package, and can be used to set the root window to a solid
color, a plaid pattern in two colors, or tile it with a monochrome bitmap.

*) How do I change the color depth of my X server?

The best way to change the default color depth of the X server is to add a
"DefaultColorDepth" line to the "Screen" section that corresponds to the X
server you use.  Here is one example:

Section "Screen"
   Driver          "Accel"
   Device          "ATI Xpert@Play"
   Monitor         "Sony 200sf"
   BlankTime       0
   DefaultColorDepth 32
   SubSection "Display"
      Depth        8
      Modes        "1152x864" "1024x768" "800x600" "640x480" "512x384" 
   EndSubSection
   SubSection "Display"
      Depth        16
      Modes        "1152x864" "1024x768" "800x600" "640x480" "512x384" 
   EndSubSection
   SubSection "Display"
      Depth        32
      Modes        "1152x864" "1024x768" "800x600" "640x480" "512x384" 
   EndSubSection
EndSection

See XF86Config(5) for more information.

To change the color depth on a per-invocation basis with startx, send the
appropriate command line argument to the X server:

startx -- -bpp 16

See Xserver(1), XFree86(1), and startx(1) for more information.

With xdm, the /etc/X11/xdm/Xservers file must be edited; there is not a way
to change the color depth on a per-session basis.  One alternative is to
have xdm manage more than one local X server, each with a different color
depth (see below).

*) How do I run more than one X local server simultaneously?

This is not difficult if you understand that unless the X server is told
otherwise, it attempts to be server number 0 for the local machine.

To instruct the X server to use a different server number for itself, pass
it the server number as an argument.  Thus:

startx -- :1 -bpp 16

Or, for xdm, edit the /etc/X11/xdm/Xservers file appropriately:

:1 local /usr/X11R6/bin/X :1 vt8 -bpp 8

It is a good idea to explicitly tell the X server which virtual console to
use (with the vt# argument) when writing the xdm Xservers file, because
when xdm starts at boot time, getty may not have taken control of the
virtual consoles it manages.  XFree86 X servers automatically place
themselves on the first available vitual console unless told otherwise.
One may then get the distressing problem of getty attempting to respawn on
a virtual console that xdm has claimed for itself; this usually results in
a system that is unresponsive to the keyboard, and one must either connect
to the system remotely to fix things, or take the system down hard via a
hardware reset, which is not very nice.

*) How do I set up the mouse buttons for left-handed use?

(Thanks to "ulisses" for suggesting this question for the FAQ, and
providing some of the information given.)

This depends on how many buttons your mouse has.  If it has two or three, I
have an answer.  If it has more than three, and/or a wheel, I'd appreciate
submissions from lefties with such mice who have gotten them reconfigured.

For a quick fix, you can execute the following while in an X session: 

  xmodmap -e "pointer = 2 1"    (for two-button mice)
  xmodmap -e "pointer = 3 2 1"  (for three-button mice)

To have the pointer buttons remapped for all of your X sessions, add the
following line to your $HOME/.Xmodmap file (creating the file if
necessary):

  pointer = 2 1    (for two-button mice)
  pointer = 3 2 1  (for three-button mice)

Note, however, that the system administrator can configure the X Window
System such that users' .xsession and/or .Xmodmap files in their $HOME
directories are ignored.  See the Xsession.options(5) manual page for more
information.

For more information about xmodmap, see xmodmap(1).

Branden Robinson, 17 Feb 1999
