In computing, the X Window System (commonly: X11, or X) is a network-transparent windowing system for bitmap displays. This article details the protocols and technical structure of X11.
X uses a client–server model. 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 plus the display number [1] 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 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 and operating systems. A client and server can communicate securely over the Internet by tunneling the connection over an encrypted connection. [2]
Bob Scheifler and Jim Gettys set out the early principles of X as follows (as listed in Scheifler/Gettys 1996):
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 develops the reference implementation with a view to extension and improvement of the implementation, whilst keeping it almost entirely compatible with the original 1987 protocol.
Communication between server and clients is done by exchanging packets over a network channel. 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:
The X server provides a set of basic services. The client programs realize more complex functionalities by interacting with the server.
What other graphical user interfaces 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. The X server automatically creates the root of the tree, called the root window. 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.
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.
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 languages, 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 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.
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 (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.
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 colors, 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.
Most client programs communicate with the server via the Xlib client library. Beside Xlib, the XCB library operates more closely to X protocol. In particular, most clients use libraries such as Xaw, Motif, GTK+, or Qt which in turn use Xlib for interacting with the server. Qt switched from Xlib to XCB with the 5.0 release, but client programs were almost entirely unaffected by this change.
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 specifies the protocol for the exchange of data via selections and the interaction of applications with the window manager. Some have considered this specification difficult and confusing; [3] [4] consistency of application look and feel 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 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).
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.
A window manager is a program that controls the general appearance of windows and other graphical elements of the graphical user interface. 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:
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 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 do not implement icons at all.
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 ksmserver
, xfce4-session
, and gnome-session
for KDE, Xfce, and GNOME respectively.
The program known as the X display manager 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 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), WDM (using the WINGs widget set used in Window Maker) and entrance (using the architecture used in Enlightenment v.17).
Early widget toolkits for X included Xaw (the Athena Widget Set, 1983), OLIT (OPEN LOOK Intrinsics Toolkit, 1988), XView (1988), Motif (1980s) and Tk. OLIT and XView function as the base toolkits for Sun's legacy OpenWindows desktop environment.
Motif provides the base toolkit for the Common Desktop Environment (CDE), the desktop environment used on commercial Unix systems such as Solaris, AIX and HP-UX. (Solaris 10 includes both CDE and GNOME, with the latter the preferred desktop environment as of 2010 [update] .)
Toolkits developed more recently include Qt (1991- , used by KDE), GTK+ (1997- , used by GNOME), wxWidgets (1992- ), FLTK (1998- ), FOX (1997- ) and fpGUI (2005-current).
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. [5] It is a long-term goal of the XCB 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:
Extension | Description and notes |
---|---|
Composite | Off-screen rendering of entire window hierarchies, allowing applications and composition managers to do effects anywhere along the way. Required for things like alpha transparency for windows and drop shadows. |
Damage | Tracks modified regions of windows, and minimizes bandwidth use required to keep the display up to date. |
XFixes | Several protocol changes. |
Extended-Visual-Information (EVIE) | Allows client to determine information about core X visuals beyond what the core protocol provides. |
Distributed Multihead (DMX) | Communicates with DMX X server. |
X-Video Motion Compensation (XvMC) | Offloading video motion compensation to a GPU that supports it. |
GLX | Support for rendering OpenGL within windows. |
XRender | Hardware accelerated image compositing with alpha blending. |
Resize and Rotate (RANDR) | Dynamically change the size, reflection, rotation and refresh rate of an X screen. |
Xinerama | Splitting the desktop across multiple monitors. |
Display Power Management Signaling (DPMS) | Allows controlling monitor power saving modes. |
X keyboard extension | Enhanced keyboard layout handling. |
DOUBLE-BUFFER | Gives flicker-free animation. |
RECORD | Used in server testing |
MIT-SHM | Use of shared memory to improve performance. |
SYNC | Provides timers and synchronizes clients (e.g. running on different hosts and operating systems) from within the X server. Created because of errors introduced by the network. |
XTEST | For generating fake input. Use i.e. the xte application from the XAutomation package. |
XInputExtension | Support for input devices such as graphic tablets; implementable as libXi [6] |
BIG-REQUESTS | Enables requests exceeding 262,140 bytes in length. |
XC-MISC | Fixes resource ID range overrun [7] |
X video extension | Support for hardware video overlays and hardware-based video scaling on playback. Also called Xv (not to be confused with the xv program). |
Shape | Support for non-rectangular and partially transparent (binary, no alpha opacity) windows. |
MIT-SCREEN-SAVER | Launches a program when the X server turns on the built-in screen saver |
SECURITY | Provides enhanced server security [8] |
X-Resource | Allows querying the X server about its resource usage |
XFree86-Bigfont | |
XFree86-DGA | Provides direct linear framebuffer access (direct graphics access). To be mostly removed in X.Org 7.6 [9] |
XFree86-VidModeExtension | Dynamically configures modelines and gamma. |
Extension | Description and notes |
---|---|
Low Bandwidth X (LBX) | Replaced by VNC tunneled over a secure shell connection, proved faster than LBX. |
PEX | "PHIGS Extension to X"; support for PHIGS 3D scene graph API. GLX with OpenGL is frequently used instead. |
XImage Extension | MIT-SHM is used instead. |
XEvIE | X Event Interception Extension. Designed for users who need to intercept all keyboard and mouse events. Removed in X.Org 7.5. [10] |
XFree86-Misc | Superseded by input properties. Removed in X.Org 7.5. [10] |
DEC-XTRAP | XTrap allows a controlling X client to emulate a real user's interaction with an X workstation. Registering itself to monitor visual output, actual keyboard and mouse input, and to simulate device input. A typical use case would be for precise performance measurement of user-perceived interactive response time, in milliseconds. A user emulation script can be recorded and then played back, repeatedly. XTrap was released open-source by engineers at Digital Equipment Corporation around 1988. Removed in X.Org 7.5. [10] |
TOG-CUP | Provides colormap utilization policy. Removed in X.Org 7.5. [10] |
MIT-SUNDRY-NONSTANDARD | Support for various backwards compatibility features for clients which used early implementations of X11. For compatibility with Pre-X11R4 clients. Disabled since 2006. Removed in X.Org 7.5. [10] |
XC-APPGROUP | Removed in X.Org 7.5. [10] |
XPRINT | Deprecated. Allows an application to render output to a printer just as it would to any other display device. Removed in May 2008. [11] |
The ICCCM is unbelievably dense, it must be followed to the last letter, and it still doesn't work. ICCCM compliance is one of the most complex ordeals of implementing X toolkits, window managers, and even simple applications. It's so difficult, that many of the benefits just aren't worth the hassle of compliance.
ICCCM is about as horrible as the [Unix Hater's Handbook's] authors describe, but that's hard to notice these days because modern toolkits and window managers do a pretty good job of hiding the ugliness from applications.
X11 does not permit the read back of all information that may have been stored in the server (for example, the X11 protocol does not permit querying the GC state). This makes modularity somewhat harder to accomplish.
libXi - library for the X Input Extension
The X Window System is a windowing system for bitmap displays, common on Unix-like operating systems.
NeWS is a discontinued windowing system developed by Sun Microsystems in the mid-1980s. Originally known as "SunDew", its primary authors were James Gosling and David S. H. Rosenthal. The NeWS interpreter was based on PostScript extending it to allow interaction and multiple "contexts" to support windows. Like PostScript, NeWS could be used as a complete programming language, but unlike PostScript, NeWS could be used to make complete interactive programs with mouse support and a GUI.
An X window manager is a window manager that runs on top of the X Window System, a windowing system mainly used on Unix-like systems.
In computing, a windowing system is a software suite that manages separately different parts of display screens. It is a type of graphical user interface (GUI) which implements the WIMP paradigm for a user interface.
VNC is a graphical desktop-sharing system that uses the Remote Frame Buffer protocol (RFB) to remotely control another computer. It transmits the keyboard and mouse input from one computer to another, relaying the graphical-screen updates, over a network. Popular uses for this technology include remote technical support and accessing files on one's work computer from one's home computer, or vice versa.
freedesktop.org (fd.o), formerly X Desktop Group (XDG), is a project to work on interoperability and shared base technology for free-software desktop environments for the X Window System (X11) and Wayland on Linux and other Unix-like operating systems. Although freedesktop.org produces specifications for interoperability, it is not a formal standards body.
Cygwin/X is an implementation of the X Window System that runs under Microsoft Windows. It is part of the Cygwin project, and is installed using Cygwin's standard setup system. Cygwin/X is free software, licensed under the X11 License.
x11vnc is a Virtual Network Computing (VNC) server program. It allows remote access from a remote client to a computer hosting an X Window session and the x11vnc software, continuously polling the X server's frame buffer for changes. This allows the user to control their X11 desktop from a remote computer either on the user's own network, or from over the Internet as if the user were sitting in front of it. x11vnc can also poll non-X11 frame buffer devices, such as webcams or TV tuner cards, iPAQ, Neuros OSD, the Linux console, and the Mac OS X graphics display. x11vnc is part of the LibVNCServer project and is free software available under the GNU General Public License. x11vnc was written by Karl Runge.
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.
X Toolkit Intrinsics is a library that implements an API to facilitate the development of programs with a graphical user interface (GUI) for the X Window System. It can be used in the C language. Design took place late 1980s to early 1990s.
Xlib 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 details of the X protocol.
Selections, cut buffers, and drag-and-drop are the mechanisms used in the X Window System to allow a user to transfer data from one window to another. Selections and cut buffer are typically used when a user selects text or some other data in a window and pastes in another one. Drag-and-drop is used when a user selects something in a window, then clicks on the selection and drags it into another window.
In the X Window System, an X session manager is a session management program, a program that can save and restore the current state of a set of running applications, including window manager.
XCB 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 Bart Massey and aims to replace Xlib.
In the X Window System, the X resources are parameters of computer programs such as the name of the font used in the buttons, the background color of menus, etc. They are used in conjunction with or as an alternative to command line parameters and configuration files.
The X Window System core protocol is the base protocol of the X Window System, which is a networked windowing system for bitmap displays used to build graphical user interfaces on Unix, Unix-like, and other operating systems. The X Window System is based on a client–server model: a single server controls the input/output hardware, such as the screen, the keyboard, and the mouse; all application programs act as clients, interacting with the user and with the other clients via the server. This interaction is regulated by the X Window System core protocol. Other protocols related to the X Window System exist, both built at the top of the X Window System core protocol or as separate protocols.
In the X Window System, programs run as X clients, and as such they connect to the X display server, possibly via a computer network. Since the network may be accessible to other users, a method for forbidding access to programs run by users different from the one who is logged in is necessary.
VirtualGL (VGL) is an open-source software package that redirects the 3D rendering commands from Unix and Linux OpenGL applications to 3D accelerator hardware in a dedicated server and sends the rendered output to a (thin) client located elsewhere on the network. On the server side, VirtualGL consists of a library that handles the redirection and a wrapper program that instructs applications to use this library. Clients can connect to the server either using a remote X11 connection or using an X11 proxy such as a Virtual Network Computing (VNC) server. In case of an X11 connection some client-side VirtualGL software is also needed to receive the rendered graphics output separately from the X11 stream. In case of a VNC connection no specific client-side software is needed other than the VNC client itself.
Adaptive Internet Protocol (AIP) is a multi-channel protocol that allows an application running on any of multiple platforms to be displayed on any of a wide range of client systems. It supports rich remote display and input services with a number of display options to deliver the presentation of the remote applications onto the local display either as a standalone window, or within a contained remote environment delivered full-screen or in a standalone window. The protocol also supports audio, printing, and other device mapping services.
In computing, Nano-X is a windowing system which is full featured enough to be used on a PC, an embedded system or a PDA. It is an open source project aimed at bringing the features of modern graphical windowing environments to smaller devices and platforms. The project was renamed from Microwindows due to legal threats from Microsoft regarding the Windows trademark.