mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-07-19 15:41:20 +00:00
fix: make titlebar transparent when using glass background style
This commit is contained in:
committed by
Mitchell Hashimoto
parent
d5c378cd6b
commit
42493de098
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user