summaryrefslogtreecommitdiff
path: root/src/macos/Sources/AppDelegate.swift
diff options
context:
space:
mode:
Diffstat (limited to 'src/macos/Sources/AppDelegate.swift')
-rw-r--r--src/macos/Sources/AppDelegate.swift18
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