The Basics of X
session is usually composed of several windows, each running a separate
program or client. Like programs on any other system, programs running under X vary in functionality. Some interact completely with the user, like the XTerm
terminal emulator. Others simply display output on the screen, like the xload
The background window is referred to as the root window. Application
windows, or clients, are displayed on top of the root window. Like UNIX
processes, these windows are grouped together, or related, in a family
hierarchy. As init
is the great-grandmother of all processes, the root window is
the great-grandmother of all windows. Clients displayed on the root window are
children of the root window, and the root window is their parent. This hierarchy
actually extends to different parts of a window. For example, menus are often
considered children of the parent window as they inherit characteristics, but
also can be configured and react independently of the parent window.
X consists of two sides: a server side and a client
side. The basic functionality is similar to the way all client-server models work in that the X
server has certain resources that it provides to the client.
It is a common
misconception that the server and clients are on the same machine. Because X
integrated with the TCP/IP stacks, requests can come from any client and can be
requested of any server. In addition, because X
is not a program but more a protocol, machines can communicate with completely different architectures. For example, a Digital OSF/1 server can provide services to both a Linux and an AIX client, as well as either of the others providing services to the OSF/1 machine. Just like other network applications, a single machine can be both client and server.
The server acts as the interface between the client programs and the
physical hardware. When you input data through either the keyboard or pointer,
the server accepts that input and is responsible for passing it along to the
client. This information is passed to the client
an event. Pressing a key or moving the pointer causes an event,
to which the client
may react. Often
that reaction is in the form of changing the display on the screen. For example,
receives the event
that a particular menu was clicked on. It responds
by requesting the server to display the pull-down menu. The server then passes
the information on to the hardware, which shows the pull-down menu as a screen.
It gives it to the server, which then passes it to the hardware. As a result of
this separation of functionality, one client
could display information on more
than one server.
To start anything, an X
server needs to be running somewhere. Despite that
fact that you can access servers anywhere on the network,
a common configuration
is one in which the server is running on the same machine as the client.
Some systems have a graphic login
that automatically starts when the system boots (for example, the Common Desktop Environment, KDE, Gnome and so on). Another common way for the system to start is through the startx shell script, which reads the two files
.xinitrc and .xserverrc file in your home directory and treats them in the same
way as your shell
would treat the .cshrc and .kshrc files. Here is where your
initial clients are started, such as terminal
emulator and the window manager. If you don't have a .xinitrc file in your home directory,
then startx will read the system default file /etc/X11/xinit/xinitrc. In reality, the X server is started by the xinit program. However, startx starts xinit for you.
Contrary to popular belief, neither the X
server nor the clients are
responsible for the appearance of the windows on the screen as we understand
them. Instead, this falls to a window "manager." Most Linux
distributions provide two window managers: The F(?) Virtual Window Manager
(fvwm) and the Tab Windows Manager (twm). In most cases (that I have seen), the default window manager is fvwm.
What you can do to each part of a window is important in understanding the
basic concepts of X.
These parts are shown in Figure 0-1. A click is
used to active a button. This is done by quickly pressing down and releasing one
of the mouse
buttons. Because there is only one mouse button on many systems,
button used to click is usually button number one. On a right-handed
mouse, this is the left button. A double-click is when the button is clicked
twice in rapid succession.
Description of the Various Parts of a Window
To drag an object, select that object by placing the pointer somewhere on that object, then
pressing down and holding the first mouse button. In many cases, such as in
XTerm, you must click on the title bar. You then see the outline of that window, which you can move
to a new location. You can also select the window by clicking Move in the Window Menu. To drop the
object onto another, drag that object over another object and release the mouse button. This only
works in appropriate circumstances, for example, dropping a document onto the printer
icon to print it.
It can also be said that you, the user, manage the windows. You determine the size and location
of the window, as well as determine which is the active window. You can
change the size of the window in several different ways. By moving the pointer, you can
grab any corner of the window by pressing and holding down the left
mouse button. You can then move that corner in any direction, thus changing
both the horizontal and vertical proportions of the window. You can also grab an edge and change the
horizontal or vertical edge, depending on which edge you grab. In addition, you can choose the Size
option from the window menu and then move the pointer to the edge or corner with which you want to
resize. This time, though, do not hold down the left mouse button.
There are also two buttons in the upper right hand corner of the window. The inner button is the
maximize button. When you click it, the window will fill the screen (it maximizes). When you click
it again, it returns to its previous size not the default, but the size it was before you clicked
the maximize button. The other button is the iconify button. This turns the window into a miniature
version of its former self. This is a "representation" of that window. These little images are
referred to as icons. Double-clicking the icon returns it to the size it was
before you clicked it to iconify it.
When you choose which window is active, you set the focus. There are two types of
focus policies used: explicit and pointer. In explicit focus, you must click
somewhere within the window to set the focus. In pointer focus, the focus is set when the pointer
enters a window.
If the default is explicit focus,
I suggest you leave it as such until you are very familiar with moving around windows or have a
compelling reason to change it. The problem with pointer focus is that you could be typing away in
one window and accidentally push the mouse so the pointer is in another window
allowing, all of a sudden, the new window to accept input. On slower machines, the opposite effect
might happen. You may move the pointer intentionally to a new window and start typing. However,
because the focus takes a moment to "catch up" with you, the input is sent to the previous
To change this, edit your .fvwmrc file and look for the entry that says AutoRaise. This item
defines how long (in milliseconds) the system will wait until it automatically raises the window
over which you have moved the cursor. This is pointer
focus. Comment out this entry by placing a pound-sign (#) in front of the
line. Just below it, is the entry ClickToFocus. This is the explicit mode. This means that you have
to explicitely click on a window to change the focus.
In the .fvmwrc file, these focus
modes are referred to as auto-raise mode and focus-follows mouse
mode. Most of the other documentation refers to explicit and auto focus; use what you like.
Common to every windowing system (at least every one I have ever seen) is the concept of a menu.
Like a menu in a restaurant, a menu in X presents a list of choices. Windows in
X come in two types: pull-down and pop-up. Pull-down menus are almost universally associated with a
particular location on the window. When you click on that location, a menu appears to drop down from
that location. In a sense, you are pulling down that menu. By default, each window has Window Menu,
which is a small square with a horizontal bar running through it, located in the upper left corner.
Some people describe it as looking like a filing cabinet drawer with a handle. When you click on the
Window Menu, you are give options that are related to the window itself. These include moving,
resizing, or changing the windows position in the windows "stack" (raising or lowering it).
Pop-up menus are usually not associated with any particular location on the window. These menus
"pop-up" from the current cursor position. An example of a pop-up menu is the
Root Menu that pops up anytime you click on an exposed area of the root window.
Earlier I mentioned that the window manager determines the "look and feel" of an
application. This is not entirely true. Although what is presented is a
function of the window manager, the underlying routines used to represent a button or a scrollbar
can be different. Many of the Linux-provided clients use a set of routines called the
X Toolkit (Xt), which is actually two libraries (the X Toolkit Intrinsics and the Athena Widget set [Xaw]) used to create the interface components (buttons, menus, etc.),
referred to as "widgets."
Keep in mind that X
does not provide a graphical-user interface (GUI). X is simply the windowing mechanism, but some
other component provides the GUI. To produce such a GUI, the Open Software
Foundation (OSF) developed the Motif Toolkit, which is based on the X Toolkit Intrinsics and a set
of widgets developed by DEC and HP. This was originally designed to emulate the look and feel of the
IBM/Microsoft Presentation Manager used in OS/2.
On Linux, you will find both Motif and standard X
applications. Motif applications are those that use the Motif Toolkit and all have a common look
and feel. One standard X application is the xclipboard. If you run it along
with some other application such as xv (a graphics viewer), you will notice some distinct
differences, the most dramatic of which is the overall appearance. Motif-based applications appear
three-dimensional, whereas standard X applications look "flat" (two-dimensional).