macos: remove glass view on syncAppearance with blur

pull/8801/head
Mitchell Hashimoto 2025-12-15 10:58:35 -08:00
parent a6ddf03a2e
commit 8482e0777d
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC
1 changed files with 11 additions and 7 deletions

View File

@ -483,6 +483,11 @@ class TerminalWindow: NSWindow {
if #available(macOS 26.0, *), derivedConfig.backgroundBlur.isGlassStyle {
setupGlassLayer()
} else if let appDelegate = NSApp.delegate as? AppDelegate {
// If we had a prior glass layer we should remove it
if #available(macOS 26.0, *) {
removeGlassLayer()
}
ghostty_set_window_background_blur(
appDelegate.ghostty.app,
Unmanaged.passUnretained(self).toOpaque())
@ -578,12 +583,11 @@ class TerminalWindow: NSWindow {
@available(macOS 26.0, *)
private func setupGlassLayer() {
guard let contentView = contentView else { return }
// Remove existing glass effect view
glassEffectView?.removeFromSuperview()
removeGlassLayer()
// Get the window content view (parent of the NSHostingView)
guard let contentView else { return }
guard let windowContentView = contentView.superview else { return }
// Create NSGlassEffectView for native glass effect
@ -596,13 +600,13 @@ class TerminalWindow: NSWindow {
case .macosGlassClear:
effectView.style = NSGlassEffectView.Style.clear
default:
// Should not reach here since we check for glass style before calling setupGlassLayer()
return
// Should not reach here since we check for glass style before calling
// setupGlassLayer()
assertionFailure()
}
effectView.cornerRadius = derivedConfig.windowCornerRadius
effectView.tintColor = preferredBackgroundColor
effectView.frame = windowContentView.bounds
effectView.autoresizingMask = [.width, .height]