fix: make titlebar transparent when using glass background style

pull/8801/head
Justy Null 2025-10-17 18:39:11 -07:00 committed by Mitchell Hashimoto
parent d5c378cd6b
commit 42493de098
2 changed files with 14 additions and 1 deletions

View File

@ -627,6 +627,7 @@ class TerminalWindow: NSWindow {
let backgroundOpacity: Double
let macosWindowButtons: Ghostty.MacOSWindowButtons
let macosBackgroundStyle: Ghostty.MacBackgroundStyle
let macosTitlebarStyle: String
let windowCornerRadius: CGFloat
init() {
@ -635,6 +636,7 @@ class TerminalWindow: NSWindow {
self.backgroundOpacity = 1
self.macosWindowButtons = .visible
self.macosBackgroundStyle = .defaultStyle
self.macosTitlebarStyle = "transparent"
self.windowCornerRadius = 16
}
@ -644,6 +646,7 @@ class TerminalWindow: NSWindow {
self.backgroundOpacity = config.backgroundOpacity
self.macosWindowButtons = config.macosWindowButtons
self.macosBackgroundStyle = config.macosBackgroundStyle
self.macosTitlebarStyle = config.macosTitlebarStyle
// Set corner radius based on macos-titlebar-style
// Native, transparent, and hidden styles use 16pt radius

View File

@ -88,7 +88,17 @@ class TransparentTitlebarTerminalWindow: TerminalWindow {
// color of the titlebar in native fullscreen view.
if let titlebarView = titlebarContainer?.firstDescendant(withClassName: "NSTitlebarView") {
titlebarView.wantsLayer = true
titlebarView.layer?.backgroundColor = preferredBackgroundColor?.cgColor
// For glass background styles, use a transparent titlebar to let the glass effect show through
// Only apply this for transparent and tabs titlebar styles
let isGlassStyle = derivedConfig.macosBackgroundStyle == .regularGlass ||
derivedConfig.macosBackgroundStyle == .clearGlass
let isTransparentTitlebar = derivedConfig.macosTitlebarStyle == "transparent" ||
derivedConfig.macosTitlebarStyle == "tabs"
titlebarView.layer?.backgroundColor = (isGlassStyle && isTransparentTitlebar)
? NSColor.clear.cgColor
: preferredBackgroundColor?.cgColor
}
// In all cases, we have to hide the background view since this has multiple subviews