diff --git a/Sources/Mojito/Util/PopoverGlass.swift b/Sources/Mojito/Util/PopoverGlass.swift index 099756e..15f22c4 100644 --- a/Sources/Mojito/Util/PopoverGlass.swift +++ b/Sources/Mojito/Util/PopoverGlass.swift @@ -1,20 +1,18 @@ import AppKit import SwiftUI -/// The system emoji picker's Liquid Glass, for our borderless panels. A bare -/// `NSGlassEffectView` renders the clearer regular glass, which reads as a -/// flat grey slab over light content. NSPopover hosts the same view with the -/// private `_variant` 20, which is frostier. +/// The system emoji picker's Liquid Glass, for our borderless panels, from +/// public API only. NSPopover gets its look from a private glass variant, +/// but those are numbered, and macOS 27.2 renumbered them: the number we +/// once borrowed now renders a clear lens that hides the panel's edges. /// -/// Even variant 20 sits darker than the system picker, which reads ~239 -/// over light content and ~115 over black, where bare glass gives ~232 and -/// 71. A 0.25 white veil lands on both; a heavier one turns the panel into -/// a light slab over dark backdrops and hides what's behind it. +/// Light mode is clear glass under a 0.25 white veil, which reads like the +/// system picker (~247 over white, ~117 over black). Regular glass reads +/// greyer over white and lifts dark backdrops into a light slab. /// /// Dark mode keeps the regular glass, unveiled. Over a bright backdrop -/// variant 20 turns light grey while the content stays dark-scheme, leaving -/// white text on light grey (NSPopover has the same problem; our rows are -/// text, so it matters more here). +/// clear glass turns light grey while the content stays dark-scheme, +/// leaving white text on light grey. @available(macOS 26.0, *) enum PopoverGlass { private static let lightVeil = NSColor.white.withAlphaComponent(0.25).cgColor @@ -41,15 +39,9 @@ enum PopoverGlass { /// Call whenever the panel's appearance is (re)set. static func match(_ glass: NSGlassEffectView, to appearance: NSAppearance) { - // Assigning `style` rewrites the private variant, even when the - // style is unchanged — that's what undoes a previous light-mode pass. - glass.style = .regular let isDark = appearance.bestMatch(from: [.aqua, .darkAqua]) == .darkAqua + glass.style = isDark ? .regular : .clear glass.contentView?.layer?.backgroundColor = isDark ? nil : lightVeil - // KVC on a missing key raises, so if a future macOS drops the key - // this degrades to the regular glass. - guard !isDark, glass.responds(to: NSSelectorFromString("set_variant:")) else { return } - glass.setValue(20, forKey: "_variant") } }