How to Switch from Wayland to X11 on Raspberry Pi OS Bookworm

Raspberry Pi OS Bookworm - Switch from Wayland to X11

Wayland is now the default window manager in the latest Raspberry Pi OS based on Debian 12 Bookworm and is the modern version of the old good X11 windowing system (X11 = X Window System version 11, the version 11 was released in 1987). More precisely, Wayland is a display server protocol and an application (a display server) that implements the Wayland protocol is a Wayland compositor. On Raspberry Pi OS Bookworm, the Wayland compositor is Wayfire.

An X11 application can not run under Wayland. And this can be a problem. But fortunately, thanks to Xwayland compatibility layer (Xwayland is an X server), any X11 application can run under Wayland. Xwayland is installed on Raspberry Pi OS Bookworm. So why do we need to disable Wayland? Reasons to switch from Wayland to X11 can be multiple: support of some X11 features or particular tools, compatibility issues or testing/developping an X11 application.

When I updated GeeXLab 0.59 for the Raspberry Pi platform, I spent a lot of time debugging the drag and drop code (GeeXLab is an X11 app with native X11/Xlib code) on the new Raspberry Pi OS Bookworn (Debian 12). I read the XDND protocol again and again just in case I missed a little detail, I improved my code and DnD works perfectly on Raspberry Pi OS bulleyes (Debian 11), on Linux Mint 21, on MX-Linux. But not on Bookworm… For some obscure reason, X11 always sends to GeeXLab a XdndLeave message right after XdndDrop and just before SelectionNotify.

Actually, it took me some time to realize that the Raspberry Pi OS Bookworm does not use X11 but Wayland to manage windows and Xwayland to provide compatibility with X11 apps. And then, it was not the real X11 but Xwayland that sent XdndLeave messages to GeeXLab. Once I understood that, I looked for a way to disable Wayland and re-enabling X11 (because X11 is still there in Bookworm!) to test my code on X11/Bookworm. Result: my drag and drop worked flawlessly with the X11 compositor (the X11 compositor is Openbox) on Bookworm.

Enabling or disabling Wayland on Raspberry Pi OS Bookworm is easy. Open a terminal and type:

$ sudo raspi-config

Then go to Advanced Options > A6 Walyand and select X11 backend:
Raspberry Pi OS Bookworm - Switch Between X and Wayland

Raspberry Pi OS Bookworm - Switch Between X and Wayland

Raspberry Pi OS Bookworm - Switch Between X and Wayland

 
If you want to know what window manager is running, open a terminal and type:

$ echo $XDG_SESSION_TYPE
x11

 
If Wayland is running:

$ echo $XDG_SESSION_TYPE
wayland

 
I don’t know if there’s a bug in my drag and drop code or if the bug is in Xwayland. Time will reveal it. But I hope this issue will be fixed in the future because the Wayland window manager is really cool: windows appear and disappear smoothly and the GPU usage widget is really cool (with X11, there are only CPU usage and CPU temperature). But I feel that one day, I will have to natively support Wayland in GeeXLab…

Further readings:

 
 

Leave a Comment

Your email address will not be published.