			   A Pseudo-Root Extension

				Keith Packard
			  Network Computing Devices.
			       October 28, 1994

The notion of encapsulating a screen inside a sub-window has been around for
a long time.  Rob Pike's 'layers' went as far as possible; the only way to
create nested windows was to run a new copy of the window system from within
a window.  Release 6 provided an X server which could do the same (Xnest).
However, both of these suffer from performance problems as each client
request must be delivered over two network connections and be interpreted by
two window system servers.  The X Window System provides for nested windows
already, and has only a few references to which window is the magic "root"
of all windows in the protocol.  By simply lying to clients about the
identity of this window, a full-speed window-system encapsulation can be
achieved.

The ICCCM DRAFT version of February 25th, 1988 contained a description of a
pseudo root mechanism which identified which window was to be treated as the
root window by clients.  This mechanism used an addition to the DISPLAY
environment variable to indicate a property on the real root of each screen
which contained the information about the pseudo root.  Xlib was modified by
Jim Fulton and Audry Ishizaki in August of 1988 to support this definition
and this code was shipped in Release 3 of the X Window System from MIT in
October of that year.  Significant problems were discovered with this
mechanism; e.g. X events with encoded root-relative positions were being
interpreted incorrectly by clients with the result that menus and dialog
boxes would appear in strange places on the screen.  In addition, the
real-root window manager and pseudo-root window manager conflicted on some
global resources (input focus and colormaps).  Discussions at the X
Consortium resulted in the removal of the pseudo root conventions from the
ICCCM and the removal of the pseudo root code from Xlib in March of 1989
with the realization that an X extension would be required to correctly
implement a pseudo root system.  Over five years have passed and, while no
pseudo-root capability exists in the X Consortium release, the original
language which introduced the pseudo-root ICCCM conventions remains behind;
the conventions themselves having been replaced with a single phrase:

"Doing so properly requires an extension, the design of which is under study."

Well, "under study" was a bit misleading.  I hadn't even thought about
pseudo roots since then until some NCD customers raised some concerns which
brought my mind back to this old idea.  They had discovered applications
which wouldn't run correctly on our PC product because the size of the root
window was too small and applications which didn't blend into the MS desktop
nicely as they place windows at the bottom of the screen completely covering
any MS application icons.  Re-enter the pseudo root.  The pseudo root window
could be made in any size; this size is reported as the screen size to the
applications using it.  Also, by encapsulating a suite of applications in a
single window, the pieces which conflict with Windows icons could easily be
moved out of the way by simply moving the pseudo root window.

I have designed and implemented a simple Pseudo-Root extension.  It
adjusts client requests, replies and events so that the client sees
a different window as the root window on a particular screen; multiple
pseudo-root windows can exist on each screen, and multiple screens can
each have pseudo-roots; clients may either use none, some or all of the
different pseudo root windows.

Each pseudo-root window has a client which must cooperate in making the
illusion complete by providing an interface between some requests and
the window manager enclosing the pseudo-root window.  In particular,
InstallColormap and SetInputFocus are managed indirectly by the
pseudo-root manager.

Because I implemented this as an extension, I wanted it to be transparent
to applications, including existing applications already linked with Xlib.
So, instead of using a magic DISPLAY syntax parsed by Xlib, I made the X
server able to "listen" for connections using more than one display number.
The extension directs clients to use one or more pseudo roots based on
which display they connect to.  The pseudo-root managers select which
display number directs clients to each pseudo-root window dynamically.

While some of the original impetus for a pseudo root extension, such as
debugging window managers, have become both less important as fewer people
are doing such things, and already supported by Xnest, a pseudo root
extension fills a real need in our product environment, and may prove useful
in other environments as well.  Finally, after five years of waiting, the
"extension under study" has become real.
