fix: clip frosted backdrop to rounded panel bounds

This commit is contained in:
2026-10-11 20:07:45 +02:00
parent 85121cef07
commit 01cf6cc8c4
2 changed files with 19 additions and 7 deletions
+18 -6
View File
@@ -61,9 +61,7 @@ final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSe
content.material = .hudWindow
content.blendingMode = .behindWindow
content.state = .active
content.wantsLayer = true
content.layer?.cornerRadius = 24
content.layer?.masksToBounds = true
roundMaterialCorners(content, radius: 24)
content.layer?.borderWidth = 0.5
window.contentView = content
let background = LauncherBackground(frame: content.bounds)
@@ -164,9 +162,7 @@ final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSe
actionPill.material = .popover
actionPill.blendingMode = .withinWindow
actionPill.state = .active
actionPill.wantsLayer = true
actionPill.layer?.cornerRadius = 18
actionPill.layer?.masksToBounds = true
roundMaterialCorners(actionPill, radius: 18)
actionPill.layer?.borderWidth = 0.5
for view in [openButton, returnKey] {
view.translatesAutoresizingMaskIntoConstraints = false
@@ -432,3 +428,19 @@ private final class LauncherRowView: NSTableRowView {
selection.stroke()
}
}
@MainActor
private func roundMaterialCorners(_ view: NSVisualEffectView, radius: CGFloat) {
let size = NSSize(width: radius * 2 + 1, height: radius * 2 + 1)
let mask = NSImage(size: size, flipped: false) { rect in
NSColor.black.setFill()
NSBezierPath(roundedRect: rect, xRadius: radius, yRadius: radius).fill()
return true
}
mask.capInsets = NSEdgeInsets(top: radius, left: radius, bottom: radius, right: radius)
mask.resizingMode = .stretch
view.wantsLayer = true
view.layer?.cornerRadius = radius
view.layer?.masksToBounds = true
view.maskImage = mask
}