Wayland - ArchWiki

# Wayland

From ArchWiki
Jump to navigation Jump to search

Related articles

- KMS
- Xorg

Wayland is a protocol for a compositing window manager to talk to its clients, as well as a library implementing the protocol. It is supported on some desktop environments like GNOME and KDE. There is also a compositor reference implementation called Weston. XWayland provides a compatibility layer to seamlessly run legacy X11 applications in Wayland.

## Requirements

Most Wayland compositors only work on systems using Kernel mode setting. Wayland by itself does not provide a graphical environment; for this you also need a compositor such as #Weston or Sway, or a desktop environment that includes a compositor like GNOME or KDE.

For the GPU driver and Wayland compositor to be compatible they must support the same buffer API. There are two main APIs: GBM and EGLStreams.

Buffer API | GPU driver support | Wayland compositor support
--- | --- | ---
GBM | All except NVIDIA | All
EGLStreams | NVIDIA | GNOME, KDE (Plasma 5.16+)

## Weston

Weston is the reference implementation of a Wayland compositor.

### Installation

Install the weston package.

### Usage

Tip: Super (windows key) can be changed, see weston.ini

Keyboard Shortcuts
Cmd | Action
--- | ---
`Ctrl+Alt+Backspace` | Quit Weston
`Super+Scroll` (or `PageUp`/`PageDown`) | Zoom in/out of desktop
`Super+Tab` | Switch windows
`Super+LMB` | Move Window
`Super+MMB` | Rotate Window
`Super+RMB` | Resize Window
`Super+Alt+Scroll` | Change window opacity
`Super+k` | Force Kill Active Window
`Super+Up/Down` | Switch Prev/Next Workspace
`Super+Shift+Up/Down` | Grab Current Window and Switch Workspace
`Super+Fn` | Switch to Workspace n (e.g. F2)
`Super+s` | Take a screenshot
`Super+r` | Record a screencast

To launch Weston natively (from a TTY) or to run Weston inside a running X session:

    $ weston

Then within Weston, you can run the demos. To launch a terminal emulator:

    $ weston-terminal

To move flowers around the screen:

    $ weston-flower

To display images:

    $ weston-image image1.jpg image2.jpg...

### Configuration

Weston's outputs differ slightly from those of `xorg.conf` Monitors:

    $ ls /sys/class/drm
    card0
    card0-VGA-1
    card1
    card1-DVI-I-1
    card1-HDMI-A-1
    card1-VGA-2

`card0` is the unused built-in video adapter. The add-on adapter `card1` is cabled to one HDMI and one DVI monitor, so the output names are `HDMI-A-1` and `DVI-I-1`.

Following is an example configuration file. See weston.ini(5) for more.

    ~/.config/weston.ini

    [core]
    # xwayland support
    xwayland=true

    [libinput]
    enable-tap=true

    [shell]
    #background-image=/usr/share/backgrounds/gnome/Aqua.jpg
    background-type=scale-crop
    background-color=0xff000000
    #background-color=0xff002244
    #panel-color=0x90ff0000
    panel-color=0x00ffffff
    panel-position=bottom
    #clock-format=none
    #animation=zoom
    #startup-animation=none
    close-animation=none
    focus-animation=dim-layer
    #binding-modifier=ctrl
    num-workspaces=6
    locking=false
    cursor-theme=Adwaita
    cursor-size=24

    # tablet options
    #lockscreen-icon=/usr/share/icons/gnome/256x256/actions/lock.png
    #lockscreen=/usr/share/backgrounds/gnome/Garden.jpg
    #homescreen=/usr/share/backgrounds/gnome/Blinds.jpg
    #animation=fade

    # for Laptop displays
    [output]
    name=LVDS1
    mode=preferred
    #mode=1680x1050
    #transform=90

    #[output]
    #name=VGA1
    # The following sets the mode with a modeline, you can get modelines for your preffered resolutions using the cvt utility
    #mode=173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
    #transform=flipped

    #[output]
    #name=X1
    #mode=1024x768
    #transform=flipped-270

    # on screen keyboard input method
    #[input-method]
    #path=/usr/lib/weston/weston-keyboard

    [keyboard]
    keymap_rules=evdev
    #keymap_layout=us,de
    #keymap_variant=colemak,
    #keymap_options=grp:shifts_toggle
    #keymap_options=caps:ctrl_modifier,shift:both_capslock_cancel
    repeat-rate=30
    repeat-delay=300

    # keymap_options from /usr/share/X11/xkb/rules/base.lst
    #numlock-on=true

    [terminal]
    font=monospace
    font-size=18

    [launcher]
    icon=/usr/share/weston/icon_flower.png
    path=/usr/bin/weston-flower

    [launcher]
    icon=/usr/share/icons/gnome/32x32/apps/utilities-terminal.png
    path=/usr/bin/weston-terminal --shell=/usr/bin/bash

    #[launcher]
    #icon=/usr/share/icons/gnome/32x32/apps/utilities-terminal.png
    #path=/usr/bin/gnome-terminal

    [launcher]
    icon=/usr/share/icons/hicolor/32x32/apps/firefox.png
    path=MOZ_GTK_TITLEBAR_DECORATION=client /usr/bin/firefox

    #[launcher]
    #icon=/usr/share/icons/Adwaita/32x32/apps/multimedia-volume-control.png
    #path=/usr/bin/st alsamixer -c0

Minimal `weston.ini`:

    ~/.config/weston.ini

    [core]
    xwayland=true

    [keyboard]
    keymap_layout=gb

    [output]
    name=LVDS1
    mode=1680x1050
    transform=90

    [launcher]
    icon=/usr/share/icons/gnome/24x24/apps/utilities-terminal.png
    path=/usr/bin/weston-terminal

    [launcher]
    icon=/usr/share/icons/hicolor/24x24/apps/firefox.png
    path=/usr/bin/firefox

#### XWayland

Install the xorg-server-xwayland package.

When you want to run an X application from within Weston, it spins up Xwayland to service the request. The following configuration is shown above:

    ~/.config/weston.ini

    [core]
    xwayland=true

Note: if X is not already configured you may need to configure a keymap: Keyboard configuration in Xorg

#### High DPI displays

For Retina or HiDPI displays, use:

    ~/.config/weston.ini

    [output]
    name=...
    scale=2

#### Shell font

Weston uses the default sans-serif font for window title bars, clocks, etc. See Font configuration#Replace or set default fonts for instructions on how to change this font.

### Tips and tricks

#### Screencast recording

Weston has built-in screencast recording which can be started and stopped by pressing the `Super`+`r` key combination. Screencasts are saved to the file `capture.wcap` in the current working directory of Weston. The WCAP format is a lossless video format specific to Weston, which only records the difference in frames. To be able to play the recorded screencast, the WCAP file will need to be converted to a format which a media player can understand. First, convert the capture to the YUV pixel format:

    $ wcap-decode --yuv4mpeg2 capture.wcap > capture.y4m

The YUV file can then be transcoded to other formats using FFmpeg or x264 (see `x264 -h` for more).

#### Window switching

To switch windows with `Super+Space` instead of `Super+Tab` change `KEY_TAB` to `KEY_SPACE` in `desktop-shell/shell.c` and recompile weston.

## GUI libraries

See details on the official website.

### GTK 3

The gtk3 package has the Wayland backend enabled. GTK will default to the Wayland backend, but it is possible to override it to Xwayland by modifying an environment variable: `GDK_BACKEND=x11`.

### Qt 5

To enable Wayland support in Qt 5, install the qt5-wayland package.

To run a Qt 5 app with the Wayland plugin [1], use `-platform wayland` or `QT_QPA_PLATFORM=wayland-egl` environment variable. To force the usage of X11 on a Wayland session, use `QT_QPA_PLATFORM=xcb`.

### Clutter

The Clutter toolkit has a Wayland backend that allows it to run as a Wayland client. The backend is enabled in the clutter package.

To run a Clutter app on Wayland, set `CLUTTER_BACKEND=wayland`.

### SDL2

To run a SDL2 application on Wayland, set `SDL_VIDEODRIVER=wayland`.

### GLFW

To use GLFW with the Wayland backend, install the glfw-wayland package (instead of glfw-x11).

### GLEW

To use GLEW with the Wayland backend, install the glew-wayland package (instead of glew).

### EFL

EFL has complete Wayland support. To run a EFL application on Wayland, see Wayland project page.

## Display managers

Below listed display managers which supports running Wayland compositors. The Type column indicates whether the display manager supports running on Wayland or not.

Name | Type | Description
--- | --- | ---
GDM | Runs on Wayland | GNOME display manager.
LightDM | Runs on X11 | Cross-desktop display manager.
SDDM | Runs on X11 | QML-based display manager.

## Compositors

Name | Type | Description
--- | --- | ---
GNOME | Stacking | See GNOME#Starting.
sway | Tiling | Sway is an i3-compatible window manager for Wayland. GitHub
Enlightenment | Stacking and tiling | More Info
KDE Plasma | Stacking | See KDE#Starting Plasma
Orbment | Tiling | orbment (previously loliwm) is an abandonned tiling WM for Wayland.
Velox | Tiling | Velox is a simple window manager based on swc. It is inspired by dwm and xmonad.
Orbital | Stacking | Orbital is a Wayland compositor and shell (more akin to a WM than a DE) using Qt5 and Weston. The goal of the project is to build a simple but flexible and good looking Wayland desktop.
Liri Shell | Stacking | Liri Shell is the desktop shell for Liri, built using QtQuick and QtCompositor as a compositor for Wayland.
Maynard | (Unclear) | Maynard is a desktop shell client for Weston based on GTK. It was based on weston-gtk-shell, a project by Tiago Vignatti. Not under development. [2][3]
Motorcar | (Unclear) | Motorcar is a Wayland compositor to explore 3D windowing using virtual reality.
Way Cooler | Tiling | Way Cooler is a customizable (Lua config files) Wayland compositor written in Rust. Inspired by i3 and awesome.
Maze Compositor | Floating 3D | Maze Compositor is a 3D Qt based Wayland compositor
Cage | Kiosk | Cage is a Wayland compositor that displays a single fullscreen application
Greenfield | Stacking | Greenfield is a Wayland compositor that runs in a web browser and can display remote applications
Grefsen | Floating | Grefsen is a Qt/Wayland compositor providing a minimal desktop environment.
Waymonad | Tiling | Waymonad is a Wayland compositor based on ideas from and inspired by xmonad
wayfire | Stacking | Wayfire is a general purpose compositor.

Some of the above may support display managers. Check `/usr/share/wayland-sessions/compositor.desktop` to see how they are started.

## Troubleshooting

### Gamma

While Redshift doesn't support Wayland (without a patch) it is possible to apply the desired temperature in tty before starting a compositor. For example:

    redshift -m drm -PO 3000

Otherwise some compositors feature this option during runtime:

- GNOME provides features like Redshift out-of-the-box and has Wayland support. Enable Night Light in Display settings.
- Likewise, KDE Plasma provides Night Color which is Wayland-only.
- On Sway 1.0 and other wlroots-based compositors, redshift-wlr-gamma-control-gitAUR can be used.
- On Orbital, redshift-wayland-gitAUR can be used.

### LLVM assertion failure

If you get an LLVM assertion failure, you need to rebuild mesa without Gallium LLVM until this problem is fixed.

This may imply disabling some drivers which require LLVM. You may also try exporting the following, if having problems with hardware drivers:

    $ export EGL_DRIVER=/usr/lib/egl/egl_gallium.so

### Slow motion, graphical glitches, and crashes

Gnome-shell users may experience display issues when they switch to Wayland from X. One of the root cause might be the `CLUTTER_PAINT=disable-clipped-redraws:disable-culling` set by yourself for Xorg-based gnome-shell. Just try to remove it from `/etc/environment` or other rc files to see if everything goes back to normal.

### Electron based applications / VS Code

Try running with GDK_BACKEND=x11. Example alias:

    $ alias code='GDK_BACKEND=x11 /usr/bin/code 2>/dev/null'

### Screen recording

green-recorderAUR and obs-gnome-screencastAUR support screen recording on Wayland using GNOME screencast feature.

wf-recorder-gitAUR is a video recorder for wlroots-based compositors.

wlrobs-hgAUR is obs-studio plugin that allows you to screen capture on wlroots-based compositors.

### Remote display

- (20190503) wlroots (used by sway) offers an RDP backend since version 0.6 [4].
- (20180401) mutter has now remote desktop enabled at compile time, see [5] and gnome-remote-desktop for details.
- There was a merge of FreeRDP into Weston in 2013, enabled via a compile flag. The weston package has it enabled since version 6.0.0.
- waypipe-gitAUR is a transparent proxy for Wayland applications, with a wrapper command to run over SSH

### Input grabbing in games, remote desktop and VM windows

In contrast to Xorg, Wayland does not allow exclusive input device grabbing, also known as active or explicit grab (e.g. keyboard, mouse), instead, it depends on the Wayland compositor to pass keyboard shortcuts and confine the pointer device to the application window.

This change in input grabbing breaks current applications' behavior, meaning:

- Hotkey combinations and modifiers will be caught by the compositor and won't be sent to remote desktop and virtual machine windows.
- The mouse pointer will not be restricted to the application's window which might cause a parallax effect where the location of the mouse pointer inside the window of the virtual machine or remote desktop is displaced from the host's mouse pointer.

Wayland solves this by adding protocol extensions for Wayland and XWayland. Support for these extensions is needed to be added to the Wayland compositors. In the case of native Wayland clients, the used widget toolkits (e.g GTK, QT) needs to support these extensions or the applications themselves if no widget toolkit is being used. In the case of Xorg applications, no changes in the applications or widget toolkits are needed as the XWayland support is enough.

These extensions are already included in wayland-protocols, and supported by xorg-server-xwayland 1.20.

The related extensions are:

- XWayland keyboard grabbing protocol
- Compositor shortcuts inhibit protocol
- Relative pointer protocol
- Pointer constraints protocol

Supporting Wayland compositors:

- Mutter, GNOME's compositor since release 3.28.

Supporting widget toolkits:

- GTK since release 3.22.18.

#### wlroots input inhibitor protocol

Input inhibitor is a Wayland protocol which was defined the by developers of Sway and wlroots and is overlapping Wayland's `Compositor shortcuts inhibit` protocol.
Sway and wlroots do not support the `Compositor shortcuts inhibit` and `XWayland keyboard grabbing` protocols, and it seems they are against adding support for the latter [6] [7].
No widget toolkit or application is known to support this protocol.

## See also

- Article about Wayland debugging on Fedora Wiki
- Cursor themes
- Arch Linux forum discussion
- Wayland documentation online

Category:

- Graphical user interfaces