How does Linux's display work?

Display-Server

Linux display

The Linux’s display system, uses multiple technology, protocols, extensions, applications, servers (daemon), drivers and concepts to achieve the windowing system for instance: Xorg, Wayland, X11, OpenGL, RandR, XrandR, Screen Resolution, DPI, Display server, etc. This can be overwhelming to understand fully, but each side of it is meant for a specific purpose and they are not used all together at the same time.

X protocol

The X Window System, X11 (X version 11) 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 with a mouse and keyboard. X does not mandate the user interface, this is handled by individual programs. As such, the visual styling of X-based environments varies greatly; different programs may present radically different interfaces. X originated at the Project Athena at Massachusetts Institute of Technology (MIT) in 1984. The X protocol has been at version 11 (hence “X11”) since September 1987. The X.Org Foundation leads the X project, with the current reference implementation, X.Org Server, available as free and open source software under the MIT License and similar permissive licenses.

X implementation

Most Linux distribution uses X.Org Server which is the free and open-source implementation of the display server for the X Window System (X11) stewarded by the X.Org Foundation. Xorg/X alone doesn’t support multiple provided features like scaling or rendering, for that Xorg uses extensions such as XFixes, RandR (RandR is managed by xrandr it can for instance setup panning, resolution or scaling), GLX (OpenGL extension), Render or Composite which causes an entire sub-tree of the window hierarchy to be rendered to an off-screen buffer, applications can then take the contents of that buffer and do whatever they like, the off-screen buffer can be automatically merged into the parent window or merged by external programs, called compositing managers to do compositing on their own like some window managers do; E.g. Compiz, Enlightenment, KWin, Marco, Metacity, Muffin, Mutter and Xfwm. For other “non-compositing” window managers, a standalone composite manager can be used, example: Picom, Xcompmgr or Unagi. Xorg supported extensions can be listed with: xdpyinfo -display :0 -queryExtensions | awk '/^number of extensions:/,/^default screen number/'.

On the other hand Wayland is intended as a simpler replacement for Xorg/X11, easier to develop and maintain but as of 2020 desktop’s support for Wayland is not yet fully ready other than Gnome (e.g. KDE Kwin and Wayland support); on the distributions side, Fedora does use Wayland by default. Note that Wayland and Xorg can work simultaneously, this can be the case depending on the used configuration. XWayland is a series of patches over the X.Org server codebase that implement an X server running upon the Wayland protocol. The patches are developed and maintained by the Wayland developers for compatibility with X11 applications during the transition to Wayland, and was mainlined in version 1.16 of the X.Org Server in 2014. When a user runs an X application from within Weston, it calls upon XWayland to service the request.

The whole scope

Diagram

A display server or window server is a program (like Xorg or Wayland) whose primary task is to coordinate the input and output of its clients to and from the rest of the operating system, the hardware, and each other. The display server communicates with its clients over the display server protocol, a communications protocol, which can be network-transparent or simply network-capable. For instance X11 and Wayland are display server communications protocols.

As shown on the diagram a window manager is an other important element of the desktop environment that is a system software that controls the placement and appearance of windows within a windowing system in a graphical user interface. Most window managers are designed to help provide a desktop environment. They work in conjunction with the underlying graphical system that provides required functionality support for graphics hardware, pointing devices, and a keyboard, and are often written and created using a widget toolkit. KDE uses KWin as a window manager (it has a limited support for Wayland as of 2020), similarly Gnome 2 uses Metacity and Gnome 3 uses Mutter as a window manager.

An other important aspect of a windows manager is the compositor or compositing window manager, which is a window manager that provides applications with an off-screen buffer for each window. The window manager composites the window buffers into an image representing the screen and writes the result into the display memory. Compositing window managers may perform additional processing on buffered windows, applying 2D and 3D animated effects such as blending, fading, scaling, rotation, duplication, bending and contortion, shuffling, blurring, redirecting applications, and translating windows into one of a number of displays and virtual desktops. Computer graphics technology allows for visual effects to be rendered in real time such as drop shadows, live previews, and complex animation. Since the screen is double-buffered, it does not flicker during updates. The most commonly used compositing window managers include: Linux, BSD, Hurd and OpenSolaris-Compiz, KWin, Xfwm, Enlightenment and Mutter. each one have its own implementation, for instance KDE’s KWin’s compositor have many features/settings like animation speed, tearing prevention (vsync), window thumbnails, scaling method and can use OpenGLv2/OpenGLv3 or XRender as a rendering backend along with Xorg. (XRender/Render not to confuse with XRandR/RandR).

OpenGL (Open Graphics Library) is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics. The API is typically used to interact with a graphics processing unit (GPU), to achieve hardware-accelerated rendering. OpenGL is a rendering library that can be used with Xorg, Wayland or any application that implements it. OpenGL installation can be checked with glxinfo | grep OpenGL.

The display resolution or display modes of a computer monitor or display device is the number of distinct pixels in each dimension that can be displayed. It is usually quoted as width × height, with the units in pixels: for example, 1024 × 768 means the width is 1024 pixels and the height is 768 pixels. xrandr can be used to add or render/simulate a new display resolution.

The DPI stand for dots per inch and is a measure of spatial printing/display, in particular the number of individual dots that can be placed in a line within the span of 1 inch (2.54 cm). Computer’s screens do not have dots, but do have pixels, the closely related concept is pixels per inch or PPI and thus DPI is implemented with the PPI concept. The default 96 DPI mesure mean 96x96 vertically and horizontally. Additionally https://unix.stackexchange.com/questions/596765 QA is very informative.

Notes

Some KDE’s gui tools: systemsettings5 > display, kcmshell5 xserver and kinfocenter.

References

Links and sources: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 and 12.

Share this post on:

Related posts:

How to scale the desktop's resolution?
How to setup a VNC Server on Linux?