Per-monitor HiDPI
The Tao backend tracks a per-window scale factor so Compose layouts stay in Dp while rendering matches each display's pixel density.
The Tao backend tracks the scale factor of each window's current display and reconfigures its render surface when that factor changes. Your Compose layout stays in Dp; only the rasterized output changes to match the display's pixel density. Per-monitor HiDPI is part of decorated-window-tao and needs no extra setup.
Read the current density
Read LocalDensity inside any composable to get the scale factor of the window it renders in:
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalDensity
@Composable
fun ShowDensity() {
val density = LocalDensity.current
Text("Scale: ${density.density}x · font scale: ${density.fontScale}")
}The value updates automatically when the window moves to a display with a different scale factor.
How it works
When you open a DecoratedWindow on Tao, the backend queries the active display for its scale factor and configures the Skiko surface accordingly: CAMetalLayer.contentsScale on macOS, the swapchain color space on Windows, and the EGL buffer scale on Wayland.
The native window receives a ScaleFactorChanged event whenever you drag it between displays, plug in an external monitor, or change the system scale. Tao forwards that event to the ComposeScene, which propagates a new LocalDensity to your composables.
The result: a Modifier.size(48.dp) occupies 48 device pixels on a 1.0 display, 96 device pixels on a 2.0 display, and 72 device pixels on a 1.5 fractional Wayland output. The layout does not change — only the rasterized output does.
linux-hidpi and the AWT backends
The linux-hidpi module reads a single global scale from the desktop environment (GSettings, Mutter, GDK_SCALE, or Xft.dpi) and applies it to JVM properties before AWT initializes, through applyLinuxHiDpiScale(). It sets one scale at startup and does not react to per-window changes.
The Tao backend does not use that helper — it observes per-window scale changes at runtime. When you migrate from the AWT backends to Tao on Linux, you can drop the linux-hidpi dependency.
Keep linux-hidpi only for sessions where you still run the AWT (JBR or JNI) backends.
API reference
LocalDensity.current— the Compose density of the window the composable renders in.Platform.isWayland—trueon a Wayland session, where fractional scaling is per-monitor;falseon X11.WindowState— hold window sizes inDp, never in pixels, so they survive a scale change.
Notes
- On Windows 10 1607 and later, Tao declares Per-Monitor V2 DPI awareness through the application manifest. The Nucleus Gradle plugin writes that manifest for packaged builds.
- On macOS, Retina backing stores are configured automatically.
- Fractional scaling on KDE Plasma works on both X11 and Wayland, but only Wayland reports per-monitor accuracy.
What's next
- Tao backend — the no-AWT native windowing backend.
- Wayland — session detection and Wayland-specific behavior.
- Decorated window — the window you render your UI into.