enum DisplayScale
Swift
enum DisplayScale
The output scale a window is drawn at: framebuffer pixels per layout pixel.
A compositor drawing a window on a 1.5 screen renders it at 1.5 times its
layout size and says so with a Scale event (InputEventKind.scale).
Layout never changes — everything here stays in layout pixels — and most of
a frame needs nothing from the app: shapes are drawn at device resolution
by the renderer, and text is rasterised there from the same face at the
device size. What the renderer cannot do is ask for an image at a size it
was never decoded at, because the client picks the decode size. That is
what this is for.
Two readings, for two kinds of caller:
DrawList.displayScaleis per window, and is what the framework's ownImage(path:width:height:)uses at emit time — so a window on each of two screens decodes for its own.DisplayScale.mainis the app's first window, for an app that sizes its own decodes inbody(a dock's icons, a thumbnail cache). A change invalidatesbody, so a view that reads it is rebuilt with the new value. Apps with one window, which is nearly all of them, lose nothing.
Windowed apps have no source for it yet and stay at 1.
Sources/LavaUI/DisplayScale.swift:23
Properties
nonisolated(unsafe) static var main: Float { get }
The main window's scale. 1 until a compositor says otherwise.
Sources/LavaUI/DisplayScale.swift:25
Methods
static func logicalSize(width: UInt32, height: UInt32, scale: Float, transform: UInt32) -> (width: Float, height: Float)
The size in layout pixels of a screen running width×height device
pixels at scale, turned by transform (wl_output_transform; odd
values are a quarter turn, which swaps the axes).
What a window that wants to fill a screen should ask for — not the mode, which is device pixels: a client that asked for 2560×1600 on a 1.5 screen laid its first frame out half as large again as the screen, and the compositor held the window back until a frame at the real size came. Rounded up, the way the compositor sizes what fills an output, so the request lands on the size the window is actually given.
Sources/LavaUI/DisplayScale.swift:49
static func pixels(_ points: Float) -> UInt32
points layout pixels in device pixels at the main window's scale,
rounded up — the decode cap for a box that size.
Sources/LavaUI/DisplayScale.swift:29