import SwiftUI import AppKit // The within-window material glass Messages.app uses for its chat header and // composer footer: an NSVisualEffectView blending within the window, frosting // whatever scrolls behind it. Deliberately NO colour of its own — a tint can // only ever mismatch the feed (it did: windowBackgroundColor isn't what the // pane actually sits on). A blur of a solid is that solid, so the glass // matches the transcript at rest and frosts what passes beneath. // // ⚠️ Two dead ends, so nobody re-walks them: // - alphaValue < 1 on an NSVisualEffectView silently DISABLES its backdrop // blur — you get a faded plate with sharp content bleeding through, not a // lighter frost. The band must run at exactly 1. // - A true CSS-style backdrop-filter (pure gaussian via public // CALayer.backgroundFilters, no material plate) is compositor-ignored in // this window tree; only the private CABackdropLayer gets backdrop // sampling, and we don't ship private API. struct FrostedBand: View { var body: some View { WithinWindowBlur() } } private struct WithinWindowBlur: NSViewRepresentable { // Decoration must be transparent to the mouse. This AppKit view lives in // its own PlatformViewHost, and SwiftUI does not keep representable // NSViews' z-order in step with the SwiftUI stack — after a composer-row // re-mount the band's host could land ABOVE the field's scroll view in // NSView order, and every click on the input died on the glass (and // resigned the caret to the window): the "composer goes unclickable for // a while" bug. hitTest nil = clicks always fall through to whatever the // band is dressing, whatever the subview order. private final class ClickThroughEffectView: NSVisualEffectView { override func hitTest(_ point: NSPoint) -> NSView? { nil } } func makeNSView(context: Context) -> NSVisualEffectView { let v = ClickThroughEffectView() v.blendingMode = .withinWindow v.material = .headerView v.state = .active return v } func updateNSView(_ nsView: NSVisualEffectView, context: Context) {} }