diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-16 12:00:52 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:14 -0300 |
| commit | 556c5b50bbfd4a6aaae192377d7810f610fc7d9e (patch) | |
| tree | d2acef085c6e6589fbf94936702222d914abc86a /src/macos/Sources/AppDelegate.swift | |
| parent | 0b54c599fa5e26fb1754ca0aab53da5fa0e14af1 (diff) | |
| download | pardes-556c5b50bbfd4a6aaae192377d7810f610fc7d9e.tar.gz pardes-556c5b50bbfd4a6aaae192377d7810f610fc7d9e.zip | |
Let WindowOpacity through on macOS
The builtin was gated on the SDL platform, so the macOS shell never registered
it and the setting had nowhere to land. macOS already had transparency, but
only the binary kind a theme decides — a theme with no background of its own
drops the ground and the blur shows through. WindowOpacity is the graded,
theme-independent version, and the window had no way to hear about it.
pardes_window_opacity reports the percentage and acknowledges the request in
one read, beside pardes_theme_bg: an SDL surface can arrive without an alpha
channel and has to be able to refuse, while an AppKit window always composites
per pixel, so there is nothing here to refuse and no rollback to perform.
The view then paints the rule shaders/ui.frag.glsl states for the SDL shell:
backgrounds — ground, cell and band fills, and the chrome rules over them —
take the alpha, glyph ink never does, and the block cursor is exempt because
it is foreground chrome that happens to be carried in a cell background. That
exemption is why the cursor joins the colour in the background run key; it can
no longer share a fill with the cells beside it.
Two things the harness was missing fall out of testing it: it never adopted
the theme background or the opacity, so a Theme or WindowOpacity in a script
moved the core and never reached a pixel. draw-opacity records both ends of
the alpha range, which is what makes the two-sided contract assertable —
60% reads 153..255, and 0% reads 0..255 with the ink still standing.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Diffstat (limited to 'src/macos/Sources/AppDelegate.swift')
| -rw-r--r-- | src/macos/Sources/AppDelegate.swift | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/macos/Sources/AppDelegate.swift b/src/macos/Sources/AppDelegate.swift index 96f4a184..107c40fd 100644 --- a/src/macos/Sources/AppDelegate.swift +++ b/src/macos/Sources/AppDelegate.swift @@ -462,17 +462,27 @@ final class AppDelegate: NSObject, NSApplicationDelegate, PardesViewDelegate { private var dressed = false private func applyTheme() { - let changed = view.adoptThemeBG(pardes_theme_bg()) - guard changed || !dressed else { return } + // Both reads happen every pump, and neither may be short-circuited by + // the other: `changed` has to be the OR of two adoptions, not the first + // one that answered true, or a Theme and a WindowOpacity in the same + // tick would leave one of them unworn. + let themeChanged = view.adoptThemeBG(pardes_theme_bg()) + let opacityChanged = view.adoptWindowOpacity(pardes_window_opacity()) + guard themeChanged || opacityChanged || !dressed else { return } dressed = true + // A ground short of solid needs the same non-opaque window a + // background-less theme does — but not the blur behind it. The backdrop + // answers "this theme brings no background"; WindowOpacity says how + // much of the one it brings to paint, and what shows through the rest + // is the desktop, which is what asking for a translucent window means. if let rgb = view.themeBG { backdrop.isHidden = true - window.isOpaque = true + window.isOpaque = view.backgroundAlpha >= 1 window.backgroundColor = NSColor( srgbRed: CGFloat((rgb >> 16) & 0xFF) / 255, green: CGFloat((rgb >> 8) & 0xFF) / 255, blue: CGFloat(rgb & 0xFF) / 255, - alpha: 1) + alpha: view.backgroundAlpha) // ...and follow the theme into light mode, so the titlebar, the // traffic lights and the resize cursor stop belonging to a // different application than the grid under them. Luminance off |
