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.swift46
1 files changed, 6 insertions, 40 deletions
diff --git a/src/macos/Sources/AppDelegate.swift b/src/macos/Sources/AppDelegate.swift
index 3cce7592..dbc0fbc9 100644
--- a/src/macos/Sources/AppDelegate.swift
+++ b/src/macos/Sources/AppDelegate.swift
@@ -15,9 +15,6 @@ import AppKit
final class AppDelegate: NSObject, NSApplicationDelegate, PardesViewDelegate {
private var window: NSWindow!
private var view: PardesView!
- /// The blur behind the grid, shown only while the theme declares no
- /// background of its own. See applyTheme.
- private var backdrop: NSVisualEffectView!
// One display-clock chain at a time. Input and pty notifications may all
// call pump(), but none advances animation; they only observe this flag and
// leave the already-scheduled frame alone.
@@ -78,31 +75,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate, PardesViewDelegate {
// isReleasedWhenClosed on would have AppKit release it out from under
// that reference the moment the close button is pressed.
window.isReleasedWhenClosed = false
- // The grid and the blur are SIBLINGS in a plain container, not parent
- // and child. A transparent theme has to show something through the
- // grid, and AppKit will not blur what is behind a window unless an
- // NSVisualEffectView asks it to. The backdrop can be hidden independently
- // when blur is disabled or the ground is opaque; hiding a superview hides
- // its subviews with it. Nested, an opaque theme drew a blank window.
let container = NSView(frame: NSRect(origin: .zero, size: want))
container.autoresizesSubviews = true
- backdrop = NSVisualEffectView(frame: container.bounds)
- // .underWindowBackground is the material meant for exactly this — the
- // full-window wash behind content, rather than the sidebar/HUD
- // materials that carry their own tint. .behindWindow is what samples
- // the desktop instead of the window's own layers.
- backdrop.material = .underWindowBackground
- backdrop.blendingMode = .behindWindow
- // .active, not .followsWindowActiveState: the grid stays readable when
- // the window is not key, and a backdrop that flattens to grey on focus
- // loss makes an unfocused pardes look switched off.
- backdrop.state = .active
- backdrop.autoresizingMask = [.width, .height]
view.frame = container.bounds
view.autoresizingMask = [.width, .height]
- // Order matters: the blur is BEHIND the grid.
- container.addSubview(backdrop)
- container.addSubview(view, positioned: .above, relativeTo: backdrop)
+ container.addSubview(view)
window.contentView = container
// Trim the content box down to whole cells: a partial column or row is
@@ -465,8 +442,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, PardesViewDelegate {
/// Dress the WINDOW in what the core is wearing: the background AppKit
/// paints where the view does not (the titlebar, and the strip a live
- /// resize outruns), and the blur behind a theme that brings no background
- /// of its own.
+ /// resize outruns).
///
/// Cheap enough to call every pump: the view compares before it dirties
/// itself, and the window properties are written only when the answer
@@ -474,7 +450,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate, PardesViewDelegate {
/// theme whose background happened to equal the view's starting guess
/// would otherwise leave the window in AppKit's default clothes forever.
private var dressed = false
- private var appliedBlur: UInt8 = 0
private func applyTheme() {
// Both reads happen every pump, and neither may be short-circuited by
@@ -483,16 +458,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, PardesViewDelegate {
// tick would leave one of them unworn.
let themeChanged = view.adoptThemeBG(pardes_theme_bg())
let opacityChanged = view.adoptWindowOpacity(pardes_window_opacity())
- let blur = pardes_window_blur()
- let blurChanged = blur != appliedBlur
- guard themeChanged || opacityChanged || blurChanged || !dressed else { return }
- appliedBlur = blur
- backdrop.alphaValue = CGFloat(blur) / 100
- backdrop.isHidden = blur == 0 || (view.themeBG != nil && view.backgroundAlpha >= 1)
+ guard themeChanged || opacityChanged || !dressed else { return }
dressed = true
- // Opacity paints the theme ground; blur controls the native material
- // behind it. An opaque ground hides the backdrop without losing the
- // requested strength, so lowering opacity restores the effect.
if let rgb = view.themeBG {
window.isOpaque = view.backgroundAlpha >= 1
window.backgroundColor = view.backgroundAlpha < 1 ? .clear : NSColor(
@@ -509,10 +476,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate, PardesViewDelegate {
+ 0.0722 * CGFloat(rgb & 0xFF)) / 255
window.appearance = NSAppearance(named: luma > 0.5 ? .aqua : .darkAqua)
} else {
- // Transparent: the window stops painting anything of its own and
- // the optional blur sits behind it. isOpaque false lets the desktop
- // reach the backdrop at all — a titled window is opaque by default
- // and would composite over it.
+ // Transparent: the window stops painting anything of its own.
+ // isOpaque false lets the desktop show through at all — a titled
+ // window is opaque by default and would composite over it.
window.isOpaque = false
window.backgroundColor = .clear
window.appearance = NSAppearance(named: .darkAqua)