Nucleus
Windows

Overlay windows

Build watermarks, desktop widgets, and heads-up overlays with transparent, click-through, always-on-bottom, and all-workspaces windows.

View as Markdown

An overlay sits outside the normal window stack: a watermark that ignores clicks, a widget pinned below other windows, a badge that follows you across workspaces. You build one with DecoratedWindow flags from nucleus-application.

Build a click-through watermark

fun main(args: Array<String>) = nucleusApplication(args) {
    DecoratedWindow(
        onCloseRequest = { },
        state = rememberWindowState(
            position = WindowPosition.Aligned(Alignment.BottomEnd),
            size = DpSize(360.dp, 160.dp),
        ),
        title = "Watermark",
        resizable = false,
        undecorated = true,
        transparent = true,
        alwaysOnTop = true,
        focusable = false,
        clickThrough = true,
        hiddenFromDock = true,
        visibleOnAllWorkspaces = true,
        forceX11 = true,
    ) {
        Watermark()
    }
}

Pair clickThrough = true with focusable = false: a window you cannot click has no use for keyboard focus.

Pin a widget below other windows

A desktop widget swaps alwaysOnTop for alwaysOnBottom and keeps clicks:

DecoratedWindow(
    onCloseRequest = ::exitApplication,
    title = "Nucleus widget",
    undecorated = true,
    transparent = true,
    hiddenFromDock = true,
    nativeContextMenu = true,
    visibleOnAllWorkspaces = true,
    forceX11 = true,
    alwaysOnBottom = true,
) {
    WidgetSurface()
}

alwaysOnTop and alwaysOnBottom exclude each other: the last one you set wins.

The window still shows in the taskbar and Alt+Tab unless you set hiddenFromDock. Native Wayland cannot glue a surface to the wallpaper.

Toggle flags at run time

clickThrough, alwaysOnBottom, and visibleOnAllWorkspaces are reactive. For imperative control, call the setters on nucleusWindow.unsafe.taoWindow:

fun applyOverlayMode(window: TaoWindow, passive: Boolean) {
    window.setIgnoreCursorEvents(passive)
    window.setAlwaysOnBottom(passive)
    window.setVisibleOnAllWorkspaces(passive)
}

transparent and forceX11 apply at creation only.

Take an X11 surface on Wayland

Stacking, position, and workspace flags do nothing on a native Wayland surface. forceX11 = true gives one window an XWayland surface and leaves the rest of the app on Wayland. To move the whole process, set NUCLEUS_TAO_LINUX_RENDERER=x11 (or GDK_BACKEND=x11) before launch.

TaoWindow.isNativeWaylandSurface tells you which surface a window received, after it is ready. To decide whether you can position a window, branch on canPlaceOnScreen instead. See Linux and Wayland.

If forceX11 finds no X server, the window stays on Wayland. Nucleus logs a warning for each flag that a native Wayland surface ignores.

Platform behavior

A transparent window keeps a shadow shaped to the drawn content. Floating above another app's full-screen Space is not supported.

visibleOnAllWorkspaces is a no-op. A window with hiddenFromDock = true already shows on every virtual desktop. A fully transparent window drops the system shadow and border.

Transparency works on X11 and Wayland. alwaysOnBottom, visibleOnAllWorkspaces, and positioning need X11: use forceX11 per window or NUCLEUS_TAO_LINUX_RENDERER=x11 for the process.

A mostly transparent window reads better with undecorated = true and custom chrome than with the stock TitleBar.

API reference

ParameterDefaultReactiveDescription
transparentfalseNoNative surface with an alpha channel.
clickThroughfalseYesPointer events pass to whatever sits behind.
alwaysOnBottomfalseYesKeeps the window below normal windows. Clears alwaysOnTop.
visibleOnAllWorkspacesfalseYesShows the window on every workspace or Space.
forceX11falseNoLinux only: XWayland surface for this window.

HostedWindow takes alwaysOnBottom. The Material and Jewel wrappers take transparent, clickThrough, visibleOnAllWorkspaces, and forceX11.

TaoWindow memberDescription
setIgnoreCursorEvents(ignore)Imperative clickThrough.
setAlwaysOnBottom(alwaysOnBottom)Imperative alwaysOnBottom.
setVisibleOnAllWorkspaces(visible)Imperative visibleOnAllWorkspaces.
isNativeWaylandSurfaceWindow runs on a native Wayland surface.
canPlaceOnScreenApp can read and set the window's screen position.

What's next

Was this page helpful?
Edit on GitHub

Last updated on