Nucleus
Windows

Linux and Wayland

How Nucleus windows run on native Wayland and X11, what the compositor controls, and how to branch on screen placement.

View as Markdown

On Linux, Nucleus windows run as native Wayland surfaces in a Wayland session and as X11 windows elsewhere, with no code change and no dependency beyond nucleus-application. On native Wayland the compositor owns window positions.

Detect the session

Read the session type for diagnostics, or to gate features that differ per session, such as taskbar progress and global hotkeys:

val onWayland = Platform.isWayland
val desktopEnv = if (Platform.Current == Platform.Linux) LinuxDesktopEnvironment.Current else null

Platform.isWayland describes the session, not a window: a window opened with forceX11 runs on XWayland inside a Wayland session. For a per-window answer, read TaoWindow.isNativeWaylandSurface once the window is ready.

Branch on screen placement

On native Wayland, the app can neither read nor set a window's screen position. Check TaoWindow.canPlaceOnScreen before you read a window origin, move a window, or place one window against another:

fun savedPosition(window: TaoWindow): IntOffset? {
    // Native Wayland: the compositor owns placement, so the origin is meaningless
    if (!window.canPlaceOnScreen) return null
    val (x, y) = window.outerBoundsPx() ?: return null
    return IntOffset(x.toInt(), y.toInt())
}

canPlaceOnScreen is false only on a native Wayland surface. The size from outerBoundsPx() stays valid everywhere. Branch on this property, not on the compositor name or LinuxDesktopEnvironment.

Where it is false:

  • WindowPosition and WindowPosition.Aligned have no effect. Persist the window size, not its position.
  • Start window moves from a Modifier.windowDragArea region.
  • In cross-window drags (tearing off a tab, docking a satellite), a snapshot follows the pointer instead of the window. See Tool windows. Satellite chrome reads the same answer through SatelliteScope.isCompositorPlaced, see Floating satellites on Wayland.

Run on XWayland

Set NUCLEUS_TAO_LINUX_RENDERER=x11 (or GDK_BACKEND=x11) before launch to put the whole process on XWayland, where every window can read and set its position:

NUCLEUS_TAO_LINUX_RENDERER=x11 ./gradlew run

To move a single window, pass forceX11 = true to it. See Overlay windows.

Follow the compositor's decorationsNew

KWin can tell a window to draw no decorations: on Plasma Mobile, under a "No titlebar and frame" window rule, or under a rule that forces KWin's own title bar. The stock title bars (TitleBar, DialogTitleBar, and the toolkit bars built on them) then drop the window controls but keep your content, such as tabs, a title or menus. A bar left empty takes no room. WindowScaffold reserves no space for the controls, and WindowControls draws only the exit-fullscreen button.

Custom chrome reads TaoWindow.isDecorationSuppressed to do the same:

val taoWindow = nucleusWindow.unsafe.taoWindow
if (!taoWindow.isDecorationSuppressed) {
    MyWindowButtons()
}

The property is Compose state and follows the compositor when it changes its mind. It is always false on X11 and on compositors without KDE's server-decoration protocol. In fullscreen, a bar with Modifier.newFullscreenControls() keeps its exit-fullscreen button when the desktop's button layout has a maximize button.

Wayland and X11 differences

ConcernNative WaylandX11 / XWayland
Window positionCompositor decides, reported as (0, 0)Read and set
alwaysOnTop, alwaysOnBottomNo effectSupported
Workspace stickinessNo effectSupported
hiddenFromDockNo effectSupported
Trackpad pinchDeliveredNot delivered
Fractional scalingInteger render, compositor scalesInteger scale

Copy and paste

Use the standard Compose LocalClipboard API. Plain text, images and file lists work in both directions, and pasted files land in file managers. HTML does not cross, and Nucleus ignores the X11 PRIMARY (middle-click) selection.

API reference

SymbolDescription
TaoWindow.canPlaceOnScreenfalse on a native Wayland surface, where the app can neither read nor set the window position.
TaoWindow.isNativeWaylandSurfaceWhether this window runs on a native Wayland surface. Read after the window is ready.
TaoWindow.isDecorationSuppressedtrue while the compositor asks the window to draw no decorations. Compose state.
TaoWindow.outerBoundsPx()[x, y, width, height] in physical pixels, or null before the window exists.
Platform.isWaylandtrue in a Linux session where XDG_SESSION_TYPE is wayland or WAYLAND_DISPLAY is set.
LinuxDesktopEnvironment.CurrentGnome, KDE, XFCE, Cinnamon, Mate, or Unknown.
NUCLEUS_TAO_LINUX_RENDERER=x11Environment variable that puts the process on XWayland.

Inside window content, reach the TaoWindow with nucleusWindow.unsafe.taoWindow.

What's next

Was this page helpful?
Edit on GitHub

Last updated on