Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

440. Xwayland and X11 applications

This page is for anyone running a program that is older than Wayland or was never ported to it. KDOS has no Xorg server. Programs that can only speak the X11 protocol run on Xwayland, an X server that is itself a client of KWin and draws each X11 window as a window of the desktop. This page covers how Xwayland is started, which settings decide whether a program uses it, how to run an X11 program on purpose from a terminal, from another console or inside a box, how to check that X11 and its OpenGL work, and what to look at when an X11 program does not open. Why X is allowed only in this form is explained in No Xorg server, and one carve-out, and how KWin runs it in KWin.

Installation

Xwayland is part of every image that has the desktop, and it is not a service:

The session’s KWin creates the X display when it starts and puts DISPLAY and XAUTHORITY into the session’s environment, so every program the session starts has them. Xwayland itself starts when the first X11 client connects; KWin then runs plasma-workspace’s /usr/lib/libexec/plasma-setup-xwayland with DISPLAY set, and takes the X11 window-manager selections. The greeter’s KWin starts no X server at all. Nothing is enabled by hand, and fs/etc/X11/ does not exist.

The live medium and an installed system behave the same.

Configuration

The Xwayland build

meson setup build \
	--prefix=/usr --sysconfdir=/etc --libdir=lib \
	--buildtype=release \
	-Dxvfb=false \
	-Dsecure-rpc=false \
	-Dxwayland_ei=false \
	-Dlibdecor=false \
	-Dsystemd_notify=false \
	-Dxselinux=false \
	-Dglamor=true \
	-Ddri3=true \
	-Dglx=true \
	-Dsha1=libcrypto \
	-Dxkb_dir=/usr/share/X11/xkb \
	-Dxkb_output_dir=/var/lib/xkb \
	-Dxkb_bin_dir=/usr/bin \
	-Ddefault_font_path=/usr/share/fonts/misc/,/usr/share/fonts/75dpi/ \
	-Ddocs=false \
	-Ddevel-docs=false

ports/core/x11/xwayland/build.sh, lines 12–30

What each switch does is on the xwayland package page. The keymaps it compiles at run time are written to /var/lib/xkb.

KWin’s settings for X11 programs

Two pages of System Settings change how KWin treats X11 programs:

Which toolkits choose X11

Every login shell exports the toolkits’ back ends, and Wayland comes first in each that has one:

# Toolkit back ends. GTK and Qt are built with their Wayland and X11 back ends,
# and Wayland comes first; SDL is built with Wayland alone, so its driver
# names no fallback; Tk and Motif have only X11 and run under Xwayland.
# Qt takes a list and falls back to xcb (Xwayland) only when the Wayland
# plugin cannot start, which is a Qt 5 application built without one; a name
# on its own here would leave that application not starting at all. GDK_BACKEND
# is left unset: GDK already tries Wayland first, and a value here would
# override the GDK_BACKEND=x11 an X11-only application sets for itself.
export QT_QPA_PLATFORM="wayland;xcb"
export MOZ_ENABLE_WAYLAND=1
export SDL_VIDEODRIVER=wayland
export CLUTTER_BACKEND=wayland

fs/etc/profile.d/10-wayland.sh, lines 82–93

A port whose program misbehaves on Wayland can force X11 in its own desktop entry. Brasero’s recipe does:

Exec=env GDK_BACKEND=x11 brasero %U

ports/core/optical/brasero/build.sh, lines 40–40

Boxed applications

A box receives no profile environment. Xwayland is one client to KWin, so an X11 window in a box is drawn untagged and nothing it binds is filtered. A box is handed the X11 display anyway unless its profile’s x11 key says no: Tk, Java, Motif, FLTK, GTK 2 and Xt programs have no other way to open a window, and nothing in a package says which toolkit a program draws with. A box handed it is at most tagged, and x11 = no is what confines one. kdos-appbox sets DISPLAY and the cookie itself (src/system/kdos-appbox/main.c):

	/*
	 * DISPLAY, for a box that is handed X11 (profile_x11): every box
	 * whose profile does not say `x11 = no`. The socket is the authority
	 * — KWin exports DISPLAY only into what the session started, and a
	 * launch from a prompt may not have it — and the cookie is the box's
	 * copy in its own runtime directory, or the session's own where the
	 * box shares that directory. A box that says `x11 = no` is told there
	 * is no display, so a toolkit with an X11 fallback does not reach for
	 * one it would be refused.
	 */

src/system/kdos-appbox/main.c, lines 605–614

It also exports QT_QPA_PLATFORM=wayland;xcb and SDL_VIDEODRIVER=wayland,x11 into every box, because Qt 5 and SDL 2 would otherwise take DISPLAY over the tagged Wayland socket; a catalogue or pack env row that forces X11 is exported after them and wins.

When kdos-appbox writes launchers for a boxed application, it removes from the entry’s Exec line the assignments that would force X11, so an application whose distribution entry asks for X11 runs on Wayland:

static const char *X11_FORCING[] = {
	"GDK_BACKEND=x11", "CLUTTER_BACKEND=x11", "QT_QPA_PLATFORM=xcb",
	"SDL_VIDEODRIVER=x11", "MOZ_ENABLE_WAYLAND=0",
	"ELECTRON_OZONE_PLATFORM_HINT=x11", NULL
};

src/system/kdos-appbox/launchers.c, lines 326–330

Usage

Checking that Xwayland is there

  1. In Konsole (Meta+Return):

    echo "$DISPLAY"
    ls /tmp/.X11-unix/

    DISPLAY names the display, such as :0, and /tmp/.X11-unix/ holds its socket, X0 for :0.

  2. See whether the server is running at this moment; with no X11 client it is not:

    pgrep -a Xwayland

    While a client is connected it prints a line such as Xwayland :0 -rootless -core -terminate 10 -listenfd 20 -listenfd 21 -displayfd 76 -wm 67. Ten seconds after the last client leaves, the process is gone and X0 is still there.

  3. kdos doctor’s Desktop section checks the socket DISPLAY names when it is set. With no DISPLAY it checks that Xwayland is installed and that /tmp/.X11-unix exists, root-owned and mode 1777: KWin does not create that directory, and without it no X11 program opens.

Running a program on X11

  1. To run a GTK program on X11 instead of Wayland, for one start:

    GDK_BACKEND=x11 <program>
  2. For a Qt program:

    QT_QPA_PLATFORM=xcb <program>
  3. A Tk program needs nothing; Tk speaks only X11. A test window, which closes when its button is pressed:

    echo 'pack [button .b -text "X11 works" -command exit]' | wish

To make the choice for every start of one program, write your own copy of its desktop entry into ~/.local/share/applications/ with env GDK_BACKEND=x11 (or QT_QPA_PLATFORM=xcb) at the front of its Exec line; see The panel and the launcher.

Running an X11 program from tty2 or SSH

A shell outside the session has no DISPLAY, and Xwayland requires the session’s cookie.

  1. Log in as the same account as the session.

  2. Read the display number off the socket, and the cookie’s path from KWin’s own environment:

    ls /tmp/.X11-unix/
    tr '\0' '\n' < /proc/$(pgrep -u "$USER" -x kwin_wayland)/environ | grep XAUTHORITY
    DISPLAY=:0 XAUTHORITY=<that path> wish

Checking OpenGL through Xwayland

The host’s mesa-demos port is built for Wayland alone, so glxinfo and glxgears come from a box; the host has es2gears_wayland and none of the three below. The app.mesa-utils catalogue entry builds Debian’s mesa-utils and puts the three X11 programs on the host’s path. This needs a network for the first install; without one it stops at app.mesa-utils: base did not build:

kdos app install app.mesa-utils
glxinfo | head -20
glxgears
es2gears_x11

glxinfo shows the GLX extension, which Xwayland on the host serves, and the renderer, which is the box’s own Mesa: an X11 client in a box draws with its box’s libraries. Comparing es2gears_x11 with the host’s es2gears_wayland shows what the X11 path costs; see Desktop GL and GLX.

Tips

Troubleshooting

An X11 program exits saying it cannot open or connect to the display. Its shell has no DISPLAY or no cookie. Inside the session, start it from Konsole, or set both as in Running an X11 program from tty2 or SSH. In a box, the profile’s x11 key decides: kdos-box profile <box> shows it, and a box with x11 = no is handed no display; remove the line, or set x11 = yes, and start the box again.

There is no socket in /tmp/.X11-unix/. KWin could not create the X display. Read the session log for KWin’s Xwayland lines:

grep -i xwayland ~/.local/share/sddm/wayland-session.log

Check that the package is installed with kpkg info xwayland; the display is created when KWin starts, so log in again after installing it.

An X11 program starts and exits at once with a GLX error, or says no GLX extension is present. Run glxinfo from the box above. When it lists no GLX extension, the X server is the cause: Xwayland serves GLX only when it is built with -Dglx=true, as the xwayland page explains. When the extension is listed and a host program still fails, check that the host’s OpenGL libraries are installed; see Desktop GL and GLX.

A Java program draws a blank or misplaced window. Java’s AWT toolkit does not always recognise the window manager it runs under, and then draws for the wrong kind. The login profile does not set _JAVA_AWT_WM_NONREPARENTING, the variable that tells it not to expect a frame around its window; set it on the command line:

_JAVA_AWT_WM_NONREPARENTING=1 <program>

Typing in an X11 program ignores the input method. An X11 program has an input-method route only when it is a GTK 3 or GTK 4 program on the host, through fcitx5-gtk’s module (Input methods); every other X11 program has none. See X11 programs other than GTK ones get no input method.

A program that has a Wayland back end runs on X11 anyway. Check its environment for a forcing variable (GDK_BACKEND=x11, QT_QPA_PLATFORM=xcb, SDL_VIDEODRIVER=x11) and its desktop entry’s Exec line for an env prefix:

grep -l 'GDK_BACKEND=x11\|QT_QPA_PLATFORM=xcb' /usr/share/applications/*.desktop ~/.local/share/applications/*.desktop

Known gaps

See also