enum WindowBridge
Swift
enum WindowBridge
Where a window's chrome sends the verbs it cannot perform itself.
The same shape as ClipboardBridge, DropBridge and ScrollBridge, and
for the same reason: LavaUI must not know what a compositor is, so the
framework declares the hole and LavaClient fills it. Unfilled — a
windowed app, a unit test — every hook is nil and the controls become inert
rather than wrong. That is the right default: a GLFW window already has a
real frame with real buttons, and an app that also draws these on top of it
has asked for a decoration it does not need.
close is the exception, and it needs no hook at all: ending the window is
something an app can always do. A client still must drop its surface
(DestroySurface) on the way out — otherwise the window lingers until
NPRPC notices the process is gone — and LavaClient.run does that when
the frame loop returns.
Sources/LavaUI/WindowControls.swift:44
Properties
nonisolated(unsafe) static var beginDrag: (@Sendable () -> Void)?
"The user has grabbed the window" — starts an interactive move. Called on the press; everything after it belongs to the compositor.
Sources/LavaUI/WindowControls.swift:47
static var canControlWindow: Bool { get }
Whether the window state verbs reach anything. False in a windowed app.
Sources/LavaUI/WindowControls.swift:98
static var canFullscreen: Bool { get }
Whether this window can cover the screen at all.
Sources/LavaUI/WindowControls.swift:63
nonisolated(unsafe) static var desktopCornerRadius: Float
The desktop's window corner radius, in points. 0 when windows are square, and 0 in a windowed app, where the radius belongs to whatever window manager drew the frame and is not ours to know.
Not needed to be rounded — the compositor masks a window's corners whatever the client draws. It is for matching: a menu, a dialog or a card the app draws inside its own window should carry the same radius as the window around it.
content.cornerRadius(WindowBridge.desktopCornerRadius)
Read once, when the client connected. A desktop whose config changes
mid-session leaves this stale until the app restarts — see
GetAppearance in the IDL for why that is a call and not a stream.
Sources/LavaUI/WindowControls.swift:116
nonisolated(unsafe) static var desktopShadow: (blur: Float, opacity: Float, offsetY: Float)
The shadow the desktop puts under a focused window: how far it reaches, how dark it is directly underneath, and how far down it is pushed.
For the same reason the radius is here — matching, not doing. The
compositor casts a window's shadow; an app that gives its own menu or
dialog one should use these numbers rather than pick its own, or the
two will disagree in the same frame. blur 0 means the desktop casts
no shadows, and so should the app.
Sources/LavaUI/WindowControls.swift:126
nonisolated(unsafe) static var drawsOwnChrome: Bool
Whether this window has no frame but its own — set by whoever opened it, because only that call knows what it asked for.
An app that runs both windowed and as a client reads this to decide whether to draw a control cluster at all: under a window manager the real frame already has one, and a second set of buttons below it is a decoration nobody asked for.
if WindowBridge.drawsOwnChrome { WindowControls() }
Sources/LavaUI/WindowControls.swift:76
nonisolated(unsafe) static var isMaximized: Bool { get set }
Whether this window currently fills the work area.
The compositor owns the fact; this is the client's copy, updated
when ToggleMaximize returns and when a WindowState input event
arrives (keyboard maximize, a restore from a drag). Read it in
body and hide your chrome:
TitleStrip().windowChrome()
Writing it marks the tree for a body pass, so a strip that reads this disappears on the same frame the window grows.
Sources/LavaUI/WindowControls.swift:91
nonisolated(unsafe) static var minimize: (@Sendable () -> Void)?
Hides the window without ending it.
Sources/LavaUI/WindowControls.swift:51
nonisolated(unsafe) static var setFullscreen: (@Sendable (Bool) -> Void)?
Fills the screen with this window, or gives it its old shape back.
Nil in a windowed build, where the window manager owns the decision. An app that must cover the screen to do its job — a screenshot tool showing a frozen desktop — should check rather than assume: without this it is a window like any other, and should say so rather than draw a selection over a desktop that is still moving.
Sources/LavaUI/WindowControls.swift:60
nonisolated(unsafe) static var toggleMaximize: (@Sendable () -> Void)?
Fills the work area, or restores.
Sources/LavaUI/WindowControls.swift:49