X11 vs. Wayland: Architecture and Trade-offs
X11 vs. Wayland: Architecture and Trade-offs
The graphical user interface (GUI) on Linux has undergone a historic architectural transition: moving away from the 40-year-old X Window System (X11) to the modern Wayland display protocol.
+-----------------------------------------------------------+
| The X11 Architecture (Legacy) |
| |
| [ Client App ] ---> (Render request via X11 protocol) |
| | |
| v |
| [ Xorg Server (Root) ] <---> [ Compositor (Mutter/KWin) ] |
| | |
| v |
| [ Kernel DRM/KMS Driver ] ---> [ Screen Framebuffer ] |
+-----------------------------------------------------------+
+-----------------------------------------------------------+
| The Wayland Architecture (Modern) |
| |
| [ Client App ] ---+ (Direct GPU rendering via OpenGL/Vulkan)
| | | |
| | v |
| +----> [ Wayland Compositor (KWin / Sway / Weston)]|
| | |
| v |
| [ Kernel DRM/KMS Driver ] ---> [ Display ] |
+-----------------------------------------------------------+
The X11 Legacy: Why It Broke Down
Created in 1984 at MIT, X11 was engineered for a computing world where terminal screens were thin network clients connected to a central Unix mainframe: 1. Network Transparency at the Cost of Local Speed: The X server was responsible for drawing basic primitives (lines, text, rectangles). In modern computing, client applications (browsers, video editors) render complex pixel buffers locally using GPU shaders (Vulkan/OpenGL). Sending raw draw requests to Xorg creates massive indirection. 2. Security Vulnerability by Design: In X11, any client application connected to the X display can inspect, intercept, and inject keystrokes into any other window (xdotool, keyloggers) and capture screenshots of the entire desktop without user permission. 3. Screen Tearing and Latency: The split between the X server, the window manager, and the compositing manager introduces out-of-sync buffer swaps, causing visual tearing.
The Wayland Philosophy: Every Frame is Perfect
Wayland is not a monolithic display server; Wayland is an IPC protocol.
Under Wayland: - The Compositor is the Display Server. - Client applications render their own UI buffers off-screen using hardware acceleration (EGL / GBM / Mesa). - The client passes a handle to the rendered memory buffer (wl_buffer) directly to the compositor. - The compositor schedules buffer presentation directly with the kernel’s Direct Rendering Manager (DRM) and Kernel Mode Setting (KMS) subsystems. - No client can read keystrokes or screen buffers belonging to another client without explicit protocol portals (xdg-desktop-portal).
XWayland: Backward Compatibility
To maintain compatibility with legacy software that has not been ported to Wayland (e.g., older games, legacy X11 utilities), compositors launch XWayland—a headless X server that runs as a rootless Wayland client.