X Window System Protocols And Architecture
   HOME

TheInfoList



OR:

In
computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic processes, and development of both hardware and software. Computing has scientific, e ...
, the
X Window System The X Window System (X11, or simply X) is a windowing system for bitmap displays, common on Unix-like operating systems. X provides the basic framework for a GUI environment: drawing and moving windows on the display device and interacting wi ...
(commonly: X11, or X) is a network-transparent
windowing system In computing, a windowing system (or window system) is software that manages separately different parts of display screens. It is a type of graphical user interface (GUI) which implements the WIMP (windows, icons, menus, pointer) paradigm fo ...
for
bitmap In computing, a bitmap is a mapping from some domain (for example, a range of integers) to bits. It is also called a bit array or bitmap index. As a noun, the term "bitmap" is very often used to refer to a particular bitmapping application: t ...
displays. This article details the protocols and technical structure of X11.


Client–server model and network transparency

X uses a
client–server model The client–server model is a distributed application structure that partitions tasks or workloads between the providers of a resource or service, called servers, and service requesters, called clients. Often clients and servers communicate ove ...
. An ''X server'' program runs on a computer with a graphical display and communicates with various ''client programs''. The X server acts as a go-between for the user and the client programs, accepting requests on TCP port 6000 for graphical output (windows) from the client programs and displaying them to the user (display), and receiving user input (keyboard, mouse) and transmitting it to the client programs. In X, the server runs on the user's computer, while the clients may run on remote machines. This terminology reverses the common notion of client–server systems, where the ''client'' normally runs on the user's local computer and the server runs on the remote computer. The X Window terminology takes the perspective that the X Window program is at the centre of all activity, i.e. the X Window program accepts and responds to requests from applications, and from the user's mouse and keyboard input. Therefore, applications (on remote computers) are viewed as clients of the X Window server program. The
communication protocol A communication protocol is a system of rules that allows two or more entities of a communications system to transmit information via any kind of variation of a physical quantity. The protocol defines the rules, syntax, semantics and synchroniza ...
between server and client runs network-transparently: the client and server may run on the same machine or on different ones, possibly with different
architectures Architecture is the art and technique of designing and building, as distinguished from the skills associated with construction. It is both the process and the product of sketching, conceiving, planning, designing, and constructing buildings o ...
and
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs. Time-sharing operating systems schedule tasks for efficient use of the system and may also i ...
s. A client and server can communicate securely over the
Internet The Internet (or internet) is the global system of interconnected computer networks that uses the Internet protocol suite (TCP/IP) to communicate between networks and devices. It is a '' network of networks'' that consists of private, pub ...
by tunneling the connection over an encrypted connection.Client–server model * IBM 1994, pp.2-11 * Maguolo 2005 * Manrique 2001 * Stevens 1994, pp.430-433 * Quercia & O'Reilly 1993, pp.13-17


Design principles

Bob Scheifler Robert William Scheifler (born June 24, 1954) is an American computer scientist. He was born in Kirkwood, Missouri. He is most notable for leading the development of the X Window System from the project's inception in 1984 until the closure of t ...
and
Jim Gettys Jim Gettys (born 15 October 1953) is an American computer programmer. He was involved in multiple computer related projects. Activity Gettys worked at DEC's Cambridge Research Laboratory. Until January 2009, he was the Vice President of Sof ...
set out the early principles of X as follows (as listed in Scheifler/Gettys 1996): * ''Do not add new functionality unless an implementor cannot complete a real application without it.'' * ''It is as important to decide what a system is not as to decide what it is. Do not serve all the world's needs; rather, make the system extensible so that additional needs can be met in an upwardly compatible fashion.'' * ''The only thing worse than generalizing from one example is generalizing from no examples at all.'' * ''If a problem is not completely understood, it is probably best to provide no solution at all.'' * ''If you can get 90 percent of the desired effect for 10 percent of the work, use the simpler solution.'' (See also
Worse is better Worse is better (also called the New Jersey style) is a term conceived by Richard P. Gabriel in an essay of the same name to describe the dynamics of software acceptance. It refers to the argument that software quality does not necessarily increa ...
.) * ''Isolate complexity as much as possible.'' * ''Provide mechanism rather than policy. In particular, place user interface policy in the clients' hands.'' The first principle was modified during the design of X11 to: ''Do not add new functionality unless you know of some real application that will require it.'' X has largely kept to these principles since. The
X.Org Foundation The X.Org Foundation is a non-profit corporation chartered to research, develop, support, organize, administrate, standardize, promote, and defend a free and open accelerated graphics stack. This includes, but is not limited to, the following p ...
develops the
reference implementation In the software development process, a reference implementation (or, less frequently, sample implementation or model implementation) is a program that implements all requirements from a corresponding specification. The reference implementation o ...
with a view to extension and improvement of the implementation, whilst keeping it almost entirely compatible with the original 1987 protocol.


Core protocol

Communication between server and clients is done by exchanging packets over a network
channel Channel, channels, channeling, etc., may refer to: Geography * Channel (geography), in physical geography, a landform consisting of the outline (banks) of the path of a narrow body of water. Australia * Channel Country, region of outback Austral ...
. The client establishes the connection, sending the first packet. The server answers by sending back a packet stating the acceptance or refusal of the connection, or with a request for a further authentication. If the connection is accepted, the acceptance packet contains data for the client to use in the subsequent interaction with the server. After connection is established, the client and the server exchange four different types of packets over the channel: # Request: the client requests information from the server or requests it to perform an action. # Reply: the server responds to a request. Not all requests generate replies. # Event: the server sends an event to the client, e.g., keyboard or mouse input, or a window being moved, resized or exposed. # Error: the server sends an error packet if a request is invalid. Since requests are queued, error packets generated by a request may not be sent immediately. The X server provides a set of basic services. The client programs realize more complex functionalities by interacting with the server.


Windows

What other
graphical user interface The GUI ( "UI" by itself is still usually pronounced . or ), graphical user interface, is a form of user interface that allows users to interact with electronic devices through graphical icons and audio indicator such as primary notation, inst ...
s usually call a ''window'' is a ''top-level window'' in the X Window System. The term ''window'' is also used for windows that lie within another window, that is, the ''subwindows'' of a ''parent window''. Graphical elements such as buttons, menus, icons, etc. are all realized using windows. A window can only be created as a subwindow of a parent window. This causes the windows to be arranged hierarchically in a
tree In botany, a tree is a perennial plant with an elongated stem, or trunk, usually supporting branches and leaves. In some usages, the definition of a tree may be narrower, including only woody plants with secondary growth, plants that are ...
. The X server automatically creates the root of the tree, called the
root window {{Unreferenced, date=September 2008 In the X Window System, every window is contained within another window, called its parent. This makes the windows form a hierarchy. The root window is the root of this hierarchy. It is as large as the screen/d ...
. The top-level windows are exactly the direct subwindows of the root window. Visibly, the root window is as large as the screen, and lies behind all other windows.


Identifiers

The X server stores all data about windows, fonts, etc. The client knows identifiers of these objects – integers it can use as names for them when interacting with the server. For example, if a client wishes a window to be created, it requests the server to create one and (in case of success) gets in return an identifier the server associated with the newly created window. The identifier can be later used by the client to request, for example, a string to be drawn in the window. Identifiers are unique to the server, not only to the client; for example, no two windows have the same identifier, even if created by two different clients. A client can access any object given its identifier, even if another client created the object.


Attributes and properties

Every window has a predefined set of attributes and a set of properties, all stored in the X server and accessible to the clients via appropriate requests. Attributes are data about the window, such as its size, position, background color, etc. Properties are pieces of data that are attached to a window. Unlike attributes, properties have no meaning at the level of the X Window core protocol. A client can store arbitrary data in a property of a window. A property is characterized by a name, a type, and a value. Properties resemble variables in
imperative programming language In computer science, imperative programming is a programming paradigm of software that uses statements that change a program's state. In much the same way that the imperative mood in natural languages expresses commands, an imperative program co ...
s, in that the application can create a new property with a given name and of a given type and store a value in it. Properties are associated to windows: two properties with the same name can exist on two different windows while having different types and values. Properties are mostly used for inter-client communication. For example, the property named WM_NAME stores the name for the window; window managers typically read this property and display the name of the window at the top of it. The xprop program can display the properties of a window. In particular, xprop -root shows the properties of the root window, which include the X resources (parameters of programs).


Events

Events are packets sent by the server to the client to communicate that something has happened which may interest the client. A client can request the server to send an event to another client; this is used for communication between clients. For example, when a client requests the text that is currently selected, an event is sent to the client that is currently handling the window that holds the selection. The content of a window may be "destroyed" in some conditions (for example, if the window is covered). Whenever an area of destroyed content is made visible, the server generates an Expose event to notify the client that a part of the window has to be drawn. Other events can serve to notify clients of keyboard or mouse input, of the creation of new windows, etc. Some kinds of events are always sent to a client, but most kinds of event are sent only if the client previously stated an interest in them, because clients may only be interested in some kind of events. For example, a client may be interested in keyboard-related event but not in mouse-related events.


Color modes

The way the X Window System handles colors can sometimes confuse users, and historically several different modes have been supported. Most modern applications use
full color The RGB color model is an additive color, additive color model in which the red, green and blue primary colors of light are added together in various ways to reproduce a broad array of colors. The name of the model comes from the initials of t ...
(24-bit color, 8 bits for each of red, green and blue), but old or specialist applications may require a different color mode. Many commercial specialist applications use
PseudoColor False color (or pseudo color) refers to a group of color Signal processing, rendering methods used to display images in color which were recorded in the visible spectrum, visible or non-visible parts of the electromagnetic spectrum. A false-c ...
. The X11 protocol actually uses a single 32-bit unsigned integer - called a ''pixelvalue'' - for representing a single color in most graphic operations. When transferring the intensity of
primary color A set of primary colors or primary colours (see spelling differences) consists of colorants or colored lights that can be mixed in varying amounts to produce a gamut of colors. This is the essential method used to create the perception of a ...
s, a 16 bit integer is used for each color component. The following representations of colors exist; not all of them may be supported on a specific device. * DirectColor: A pixel value is decomposed into separate red, green, and blue subfields. Each subfield indexes a separate colormap. Entries in all colormaps can be changed. ** TrueColor: Same as DirectColor, except that the colormap entries are predefined by the hardware and cannot be changed. Typically, each of the red, green, and blue colormaps provides a (near) linear ramp of intensity. * GrayScale: A pixel value indexes a single colormap that contains monochrome intensities. Colormap entries can be changed. ** StaticGray: Same as GrayScale, except that the colormap entries are predefined by the hardware and cannot be changed. * PseudoColor ( Chunky): A pixel value indexes a single colormap that contains color intensities. Colormap entries can be changed. ** StaticColor: Same as PseudoColor, except that the colormap entries are predefined by the hardware and cannot be changed.


Xlib and other client libraries

Most client programs communicate with the server via the
Xlib Xlib (also known as libX11) is an X Window System protocol client library written in the C programming language. It contains functions for interacting with an X server. These functions allow programmers to write programs without knowing the ...
client library. Beside Xlib, the
XCB XCB (''X protocol C-language Binding'') is a library implementing the client-side of the X11 display server protocol. XCB is written in the C programming language and distributed under the MIT License. The project was started in 2001 by B ...
library operates more closely to X protocol. In particular, most clients use libraries such as
Xaw X Athena Widgets or Xaw is a GUI widget library for the X Window System. Developed as part of Project Athena, Xaw was written under the auspices of the MIT X Consortium as a sample widget set built on X Toolkit Intrinsics (Xt); Xt and Xaw are ...
, Motif, GTK+, or Qt which in turn use
Xlib Xlib (also known as libX11) is an X Window System protocol client library written in the C programming language. It contains functions for interacting with an X server. These functions allow programmers to write programs without knowing the ...
for interacting with the server. Qt switched from Xlib to
XCB XCB (''X protocol C-language Binding'') is a library implementing the client-side of the X11 display server protocol. XCB is written in the C programming language and distributed under the MIT License. The project was started in 2001 by B ...
with the 5.0 release, but client programs were almost entirely unaffected by this change.


Inter-client communication

The X Window core protocol provides mechanisms for communication between clients: window properties and events, in particular the client-to-client message events. However, it does not specify any protocol for such interactions. Instead, a separate set of inter-client communication conventions governs these protocols. The
Inter-Client Communication Conventions Manual In computing, the Inter-Client Communication Conventions Manual (ICCCM or I39L short for "I", 39 letters and "L") consistency of application
look and feel In software design, the look and feel of a graphical user interface comprises aspects of its design, including elements such as colors, shapes, layout, and typefaces (the "look"), as well as the behavior of dynamic elements such as buttons, boxe ...
and communication is typically addressed by programming to a given desktop environment. The Inter-Client Exchange protocol (ICE) specifies a framework for building protocols for interaction between clients, so that programmers can build a specific protocol on top of it. In particular, the X Session Management protocol (XSMP) is a protocol based on ICE that governs the interaction between applications with the session manager, which is the program that takes care of storing the status of the desktop at the end of an interactive session and recovering it when another session with the same user is started again. The
freedesktop freedesktop.org (fd.o) is a project to work on interoperability and shared base technology for Free software, free-software desktop environments for the X Window System (X11) and Wayland (display server protocol), Wayland on Linux and other Uni ...
specifications include newer conventions, including the drag-and-drop convention Xdnd (used for transferring data by selecting it and dragging in another window) and the embedded application convention Xembed (which details how an application can run in a subwindow of another application).


Selections, cut buffers, and drag-and-drop

The mechanisms of selections, cut buffers, and drag-and-drop in the X Window System allow a user to transfer data from one window to another. Selections and cut buffer are used (typically) when a user selects text or some other data in a window and pastes in a different window. Drag-and-drop is used when a user selects something in a window, then clicks on the selection and drags it into another window. Since two different applications may handle the two windows, data transfer requires different clients connected with the same X server to interact. The X Window core protocol includes some types of requests and events that are specific to selection exchange, but the transfer is mainly done using the general client-to-client event sending and window properties, which are not specific to selection transfer. Users can transfer data of different types between clients: it is usually text, but can also be a pixmap, a number, a list of objects, etc. Selections and drag-and-drop are active mechanisms: after the user selects data in a window, the client handling the window must actively support a protocol for transferring that data to the application requesting it. Cut buffers, by contrast, provide a passive mechanism: when the user selects some text, its content is transferred to a cut buffer, where it remains even if the application handling the window terminates and the window is destroyed.


Window manager

A window manager is a program that controls the general appearance of windows and other graphical elements of the
graphical user interface The GUI ( "UI" by itself is still usually pronounced . or ), graphical user interface, is a form of user interface that allows users to interact with electronic devices through graphical icons and audio indicator such as primary notation, inst ...
. Differences in the look of X Window System in different installations stem mainly from the use of different window managers or from different configurations of the window manager. The window manager takes care of deciding the position of windows, placing the decorative border around them, handling icons, handling mouse clicks outside windows (on the “background”), handling certain keystrokes, etc. From the point of view of the X server, the window manager operates as a client just like any other client. The initial position and the decorative borders around windows are handled by the window manager using the following requests: # an application can request the server not to satisfy requests of mapping (showing) subwindows of a given window, and to be sent an event instead; # an application can request changing the parent of a window. The window manager uses the first request to intercept any request for mapping top-level windows (children of the root window). Whenever another application requests the mapping of a top-level window, the server does not do it but sends an event to the window manager instead. Most window managers reparent the window: they create a larger top-level window (called the frame window) and reparent the original window as a child of it. Graphically, this corresponds to placing the original window inside the frame window. The space of the frame window that is not taken by the original window is used for the decorative frame around the window (the “border” and the “title bar”). The window manager manages mouse clicks in the frame window. This allows, for example, a user to move or resize the window by clicking and dragging on the border or on the title bar. The window manager also handles icons and related visual elements of the graphical user interface. Icons do not exist at the level of the X Window core protocol. They are implemented by the window manager. For example, whenever a window has to be “iconified”, the
FVWM The F Virtual Window Manager is a virtual window manager for the X Window System. Originally a twm derivative, FVWM has evolved into a powerful and highly configurable environment for Unix-like systems. History In 1993, during his work analyzi ...
window manager unmaps the window, and creates a window for the icon name and possibly another window for the icon image. The meaning and handling of icons is therefore completely decided by the window manager: some window managers such as
wm2 wm2 is a minimalist reparenting window manager for the X Window System written by Chris Cannam. It provides support for moving, resizing, and deleting windows, but does not support icons. Instead of icons, wm2 allows temporary hiding of wind ...
do not implement icons at all.


Session manager

Roughly, the state of a session is the “state of the desktop” at a given time: a set of windows with their current content. More precisely, it is the set of applications managing these windows and the information that allow these applications to restore the condition of their managed windows if required. A program known as the X session manager saves and restores the state of sessions. Most recognizably, using a session manager permits a user to log out from an interactive session but to find exactly the same windows in the same state when logging in again. For this to work, the session manager program stores the names of the running applications at logout and starts them again at login. In order for the state of the applications to be restored as well (which is needed to restore the content of windows), the applications must be able to save their state of execution upon request from the session manager and load it back when they start again. The X Window System includes a default session manager called xsm. Developers have written other session managers for specific desktop systems. Major examples include , , and for
KDE KDE is an international free software community that develops free and open-source software. As a central development hub, it provides tools and resources that allow collaborative work on this kind of software. Well-known products include the ...
, Xfce, and GNOME respectively.


X display manager

The program known as the
X display manager In the X Window System, an X display manager is a graphical login manager which starts a login session on an X server from the same or another computer. A display manager presents the user with a login screen. A session starts when a user ...
shows the graphical login prompt in the X Window System. More generally, a display manager runs one or more X servers on the local computer or accepts incoming connections from X servers running on remote computers. The local servers are started by the display manager, which then connects to them to present the user the login screen. The remote servers are started independently from the display manager and connect to it. In this situation, the display manager works like a graphical
telnet Telnet is an application protocol used on the Internet or local area network to provide a bidirectional interactive text-oriented communication facility using a virtual terminal connection. User data is interspersed in-band with Telnet contr ...
server: an X server can connect to the display manager, which starts a session; the applications which utilize this session run on the same computer of the display manager but have input and output on the computer where the X server runs (which may be the computer in front of the user or a remote one). The X Window System ships with XDM as the basic supplied display manager. Other display managers include GDM ( GNOME), KDM/ SDDM (
KDE KDE is an international free software community that develops free and open-source software. As a central development hub, it provides tools and resources that allow collaborative work on this kind of software. Well-known products include the ...
), WDM (using the WINGs widget set used in
Window Maker Window Maker is a free and open-source window manager for the X Window System, allowing graphical applications to be run on Unix-like operating-systems. It is designed to emulate NeXTSTEP's GUI as an OpenStep-compatible environment. Window Maker ...
) and entrance (using the architecture used in Enlightenment v.17).


User interface elements

Early
widget toolkit A widget toolkit, widget library, GUI toolkit, or UX library is a library or a collection of libraries containing a set of graphical control elements (called ''widgets'') used to construct the graphical user interface (GUI) of programs. Most widge ...
s for X included
Xaw X Athena Widgets or Xaw is a GUI widget library for the X Window System. Developed as part of Project Athena, Xaw was written under the auspices of the MIT X Consortium as a sample widget set built on X Toolkit Intrinsics (Xt); Xt and Xaw are ...
(the
Athena Athena or Athene, often given the epithet Pallas, is an ancient Greek religion, ancient Greek goddess associated with wisdom, warfare, and handicraft who was later syncretism, syncretized with the Roman goddess Minerva. Athena was regarded ...
Widget Set, 1983),
OLIT OLIT (OPEN LOOK Intrinsics Toolkit ) is a widget toolkit from Sun Microsystems introduced in 1988, providing an OPEN LOOK user interface for X Window System applications. It provides an Xt application programming interface for the C programmin ...
(
OPEN LOOK OPEN LOOK (sometimes referred to as Open Look) is a graphical user interface (GUI) specification for UNIX workstations. It was originally defined in the late 1980s by Sun Microsystems and AT&T Corporation. History OPEN LOOK was created at a ...
Intrinsics Toolkit, 1988),
XView XView is a widget toolkit from Sun Microsystems introduced in 1988. It provides an OPEN LOOK user interface for X Window System applications, with an object-oriented application programming interface (API) for the C programming language. Its in ...
(1988), Motif (1980s) and Tk. OLIT and XView function as the base toolkits for
Sun The Sun is the star at the center of the Solar System. It is a nearly perfect ball of hot plasma, heated to incandescence by nuclear fusion reactions in its core. The Sun radiates this energy mainly as light, ultraviolet, and infrared radi ...
's legacy
OpenWindows OpenWindows is a discontinued desktop environment for Sun Microsystems workstations which combined SunView, NeWS, and X Window System protocols. OpenWindows was included in later releases of the SunOS 4 and Solaris operating systems, until its r ...
desktop environment. Motif provides the base toolkit for the
Common Desktop Environment The Common Desktop Environment (CDE) is a desktop environment for Unix and OpenVMS, based on the Motif widget toolkit. It was part of the UNIX 98 Workstation Product Standard, and was for a long time the Unix desktop associated with commercial ...
(CDE), the desktop environment used on commercial
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, an ...
systems such as
Solaris Solaris may refer to: Arts and entertainment Literature, television and film * ''Solaris'' (novel), a 1961 science fiction novel by Stanisław Lem ** ''Solaris'' (1968 film), directed by Boris Nirenburg ** ''Solaris'' (1972 film), directed by ...
,
AIX Aix or AIX may refer to: Computing * AIX, a line of IBM computer operating systems *An Alternate Index, for a Virtual Storage Access Method Key Sequenced Data Set * Athens Internet Exchange, a European Internet exchange point Places Belgi ...
and HP-UX. (Solaris 10 includes both CDE and GNOME, with the latter the preferred desktop environment .) Toolkits developed more recently include Qt (1991- , used by
KDE KDE is an international free software community that develops free and open-source software. As a central development hub, it provides tools and resources that allow collaborative work on this kind of software. Well-known products include the ...
), GTK+ (1997- , used by GNOME),
wxWidgets wxWidgets (formerly wxWindows) is a widget toolkit and tools library for creating graphical user interfaces (GUIs) for cross-platform applications. wxWidgets enables a program's GUI code to compile and run on several computer platforms with mini ...
(1992- ), FLTK (1998- ),
FOX Foxes are small to medium-sized, omnivorous mammals belonging to several genera of the family Canidae. They have a flattened skull, upright, triangular ears, a pointed, slightly upturned snout, and a long bushy tail (or ''brush''). Twelve sp ...
(1997- ) and fpGUI (2005-current).


Extensions

Scheifler and Gettys designed the X server to be simple but extensible. As such, much functionality now resides in extensions to the protocol. At the protocol level, every extension can be assigned new request/event/error packet types. Extension features are accessed by client applications through extension libraries. Adding extensions to current X server implementations is reportedly difficult due to a lack of modularity in the server design. It is a long-term goal of the
XCB XCB (''X protocol C-language Binding'') is a library implementing the client-side of the X11 display server protocol. XCB is written in the C programming language and distributed under the MIT License. The project was started in 2001 by B ...
project to automate generating both the client and server sides of extensions from XML protocol descriptions. The following table provides a partial catalog of extensions that have been developed, sorted roughly by recency of introduction:


Obsolete extensions


See also

*
Xlib Xlib (also known as libX11) is an X Window System protocol client library written in the C programming language. It contains functions for interacting with an X server. These functions allow programmers to write programs without knowing the ...
* Intrinsics (Xt) *
X Window System core protocol The X Window System core protocolRobert W. Scheifler and James Gettys: ''X Window System: Core and extension protocols, X version 11, releases 6 and 6.1'', Digital Press 1996, RFC 1013Grant EdwardsAn Introduction to X11 User Interfaces/ref> is the ...
*
X logical font description X logical font description (XLFD) is a font standard used by the X Window System. Modern X software typically relies on the newer Fontconfig system instead, but XLFDs are still supported in current X window implementations for compatibility with ...


Notes


References

# # # # # archive.org has the 1990 edition.


Further reading

* Robert W. Scheifler and James Gettys: ''X Window System: Core and extension protocols, X version 11, releases 6 and 6.1'', Digital Press 1996, *
Introduction to X Windows
sic] *


External links


X.Org Foundation
(official home page)
X.Org Foundation wiki

X Window System Internals



X11 Extension tutorial
{{XWinSys X Window System, *protocols and architecture Application layer protocols Remote desktop protocols X Window extensions