Skip to content

Instantly share code, notes, and snippets.

@probonopd
Last active February 10, 2024 08:47
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save probonopd/d57e9c77e4fccc5e5f87d7000beb9730 to your computer and use it in GitHub Desktop.
Save probonopd/d57e9c77e4fccc5e5f87d7000beb9730 to your computer and use it in GitHub Desktop.

Wayland transition notes for X11 users

Please comment below to contribute. Thanks!

X11 concept Wayland concept Notes
"Window" "Top-level Shell Surface" An entire window, including window decorations
X11 (the specfication) Wayland (the protocols) Neither X11 nor Wayland are binaries that can be installed
Xorg, one universally shared default implementation Multiple competing Wayland compositors Unfortunately there is no universally used single Wayland compositor; apparently every desktop environment does its own, and as a result what works in one may not work in another
export DISPLAY=... export WAYLAND_DISPLAY=... How to know which WAYLAND_DISPLAY one needs to export? The sockets (and their names) should be located in /run/user/*. If WAYLAND_SOCKET is detected, the client will prefer to use the socket provided using that environment variable.
X server Wayland compositor Unfortunately Wayland has no clear separation between the display server and the window manager
Window manager Wayland compositor Unfortunately Wayland has no clear separation between the display server and the window manager
Window ID zwlr_foreign_toplevel_handle_v1, xdg_toplevel A zwlr_foreign_toplevel_handle_v1 is a window from a non-Wayland application, a xdg_toplevel is a window from a Wayland application
./some-window-manager --replace ??? In a running session, replace the currently running window manager (compositor) with another one (e.g., for testing)
/var/log/xorg.log ???

Apparently you need to manually invoke your Wayland compositor of choice something like this: /usr/bin/yourwaylandcompositor >/tmp/yourwaylandcompositor.log 2>&1
The further splintering of the desktop by Wayland no longer providing elementary things like logging in a universally accepted way for everyone makes suporting it harder than before

Which compositor to use for a Qt based desktop?

https://doc.qt.io/qt-5/qtwaylandcompositor-examples.html has example Wayland compositors written in Qt. Unfortunately they don't seem to be intended for productive use on the desktop, and are not based on wlroots (hence lacking functionality that wlroots-based Wayland compositors may have).

QWindow Compositor

QWindow Compositor is a desktop-style Wayland compositor example that demonstrates the power of the Qt Wayland Compositor C++ APIs. However, it is lacking server side window decorations (like window title bars).

Running the following on Raspberry Pi OS in a default (Wayland) session results in the QWindow Compositor to run as a nested window on the desktop.

cd ~
git clone https://github.com/qt/qtwayland/
cd qtwayland
git checkout 5.15
cd ..
mkdir -p qwindow-compositor
cd qwindow-compositor
qmake ~/qtwayland/examples/wayland/qwindow-compositor/qwindow-compositor.pro 
./qwindow-compositor &
export QT_WAYLAND_SHELL_INTEGRATION=wl-shell
export WAYLAND_DISPLAY=wayland-0 # How to know the value?
featherpad --platform wayland

If you get Failed to create wl_display then the compositor is not running or $WAYLAND_DISPLAY is wrong.

Sever Side Decoration Compositor

Server Side Decoration Compositor is a desktop-style Wayland compositor example implementing server-side window decorations. However, it is lacking minimize/maximize buttons.

ksnip_20231118-174844

sudo apt install qml-module-qtwayland-compositor  
mkdir -p ~/server-side-decoration
cd ~/server-side-decoration
qmake ~/qtwayland/examples/wayland/server-side-decoration/server-side-decoration.pro 
make -j4
./server-side-decoration &
export QT_WAYLAND_SHELL_INTEGRATION=xdg-shell
export WAYLAND_DISPLAY=wayland-0 # How to know the value?
featherpad --platform wayland

Questions

  • How could one change Raspberry Pi OS to use such a compositor instead of the default one for the desktop session?
  • How can one build a Qt based Wayland compositor that renders server side decorations using Qt Widgets rather than Qml?
  • How woud one do drop shadows, round corners, fading, etc.?
  • How can one bring in wlroots so that the Qt based compositor automatically supports everything that wlroots supports?
  • Is there a full-fledged Qt based Wayland compositor suitable for the desktop but not as heavyweight in dependencies as KWin?

References

  • https://github.com/ec1oud/grefsen - Desktop environment built on Qt and Wayland
  • https://github.com/dcfranca/greenisland - The API extends QtCompositor with additional features needed by any real world Wayland compositor. Green Island offers multiple screen support and it also implements specific protocols such as xdg-shell, gtk-shell and those for Plasma 5. Also include a screencaster protocol and command line application, plus a minimal Wayland compositor written with QML. Unmaintained since 2015?
@Sivecano
Copy link

Sivecano commented Jan 16, 2024

How to know which $WAYLAND_DISPLAY one needs to export?

the sockets (and their names) should be located in /run/user/*

@alerikaisattera
Copy link

Add Arcan to the comparison

@i509VCB
Copy link

i509VCB commented Feb 9, 2024

export WAYLAND_DISPLAY=...

Compositors may also choose to set WAYLAND_SOCKET. WAYLAND_SOCKET is usually used to connect a single client to the server in some special way. If WAYLAND_SOCKET is detected, the client will prefer to use the socket provided using that environment variable. Sockets provided this way are single use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment