Wayland display server protocol

Long and Short Routes

In X11, the kernel transmits a mouse click via the evdev driver [8]. The X server determines which window the event is intended for and sends it to the client responsible for the window. One problem with this approach is that the position of the window is controlled by the compositor and not by X itself. Because a mouse click can change elements in the window or open a new window, the client sends a request to render to the X server. The X server then forwards this request to the graphics driver, which delegates the rendering to the hardware. The X server then calculates the geometry and position of the area to be rendered and sends a report called a damage event to the compositor, which provides the information that something has changed in the window and that an area of the display must be redrawn. The commands for this redraw again have to go through the X server.

The X server carries around a lot of baggage, but it doesn't actually have much functionality that is still useful today. The X server is the middleman, and these days it just generates unnecessary steps between the application and the compositor and between the compositor and the graphics hardware.

In Wayland, the compositor is also the display server (Figure 5). The kernel hands over events directly to the compositor. Wayland allows the compositor to transmit events directly to the clients and then lets clients send back damage events directly to the compositor. For example, the compositor looks for which window the event is intended. Thanks to its scene graph [9], the compositor knows exactly which changes have already been made to the window (Figure 6).

Figure 5: Short routes in Wayland [12]. (CC BY-SA 3.0 [5])
Figure 6: The Wayland compositor handles various clients [13]. (CC BY-SA 3.0 [5])

The event is forwarded directly to the clients, and the clients calculate the rendering themselves and send feedback to the compositor, stating that the window has been updated. The compositor redraws the window and sends a system call (ioctl) to the Kernel Mode Setting (KMS) [10] to request a pageflip. The clients can't take over the rendering themselves because of the Direct Rendering Infrastructure (DRI) [11], which allows common video buffer storage for the client and server. This means that the client can link to a rendering library (e.g., OpenGL, Vulkan, or the rendering engines Qt or Gtk+), which then writes directly in the shared buffer.

The only supposed disadvantage of Wayland compared with X11 is that X11 is network capable, whereas Wayland is not. However, with the Remote Desktop Protocol (RDP) or Virtual Network Computing (VNC), users today have options for sending desktops or individual GUI application via the network. An RDP or VNC server based directly on Wayland is also conceivable. For security reasons, however, much more focus is placed on one of X11's weaknesses: In the past, the X server corresponded directly with the hardware, so it traditionally ran with root privileges. Thanks to KMS, today the X server theoretically can run without root privileges, but this option is hardly ever used. Wayland, on the other hand, doesn't require root privileges because it communicates with the hardware via the kernel.

Wayland's State of Development

Wayland and its reference compositor Weston are now up to version 1.9. The protocol itself is considered quite mature and no longer receives new functions, so developers of compositors for KDE, Gnome, Enlightenment, Sailfish OS, Tizen, and others have time to finish and test their Wayland implementations. The Weston reference compositor [14], on the other hand, provides new experimental technologies and interfaces.

New features include atomic kernel mode switching [15], which promises a completely flicker-free view change. A library that can manage the input devices of various compositors and that aims to replace drivers such as evdev, synaptics, or wacom was already integrated with libinput in Weston 1.5 (Figure 7). Fedora has used libinput for managing input and output devices since version 22.

Figure 7: Libinput looks after input and output events and the devices behind them [16]. (CC-BY-SA-3.0 [5])

Fedora has offered experimental support for Wayland for more than a year. The Fedora Rawhide distribution takes that support one step further and, as of recently, supports Wayland by default. Users might need to edit the /etc/gdm/custom.conf file to receive a conventional X.Org session. Because not everyone wants to test Rawhide, the Fedora developers promise to implement Wayland bug fixes quickly so that users remain fairly close to the current state of development when updating their system.

The Test Course

To test Wayland using a Live image of Fedora 23, the user needs to create a password after starting the Live medium to obtain the Wayland option. To do so, just click the down arrow in the top right corner of the desktop, select Live System User | Account Settings, and enter a password. Fedora places value on passwords that are as safe as possible and therefore makes you create secure passwords.

Once you've created a secure password, go to Live System User | Log Out, and you'll be taken to the login manager, where you can select the Wayland session by clicking the cogwheel to the left of Sign In (Figure 8). The next thing to do is import the latest updates. The quickest way to import updates is in a terminal using the

sudo dnf upgrade

command. If you want to check whether a Gnome Wayland session is running, you can use the

ls -l $XDG_RUNTIME_DIR/wayland-0

command. A socket will be displayed in /run/user/1000 if this command is successful.

Figure 8: Wayland session in the Fedora 23 Gnome GDM login manager. In Fedora 24, the Wayland session will be GNOME.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Wayland 1.4 Challenges X11

    X marks the target for the next-generation windowing system.

  • Hawaii Desktop

    The Hawaii desktop relies on Qt Quick, supports Wayland, and comes with its own compositor. Thanks to the Maui Linux system, you can test Hawaii on a Live CD or on a VMware virtual machine.

  • Tech Tools
    • New Intel Xeon Phi
    • Intel-HP HPC Center
    • Oracle Supports Azure Cloud
    • Wayland 1.2 Released
    • Java Enterprise Edition 7 Released
  • Fedora 22

    Fedora 22 was released a week late, but it is seriously impressive with Gnome 3.16 and the new DNF package manager. Only the installer, Anaconda, might cause beginners a headache.

  • Canonical Announces Mir Display Server

    New X replacement will support the Unity desktop in future Ubuntu releases.

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95

News