fix(macOS): set titlebar background color to support transparent windows with titlebar tabs

This commit is contained in:
Qwerasd
2024-01-31 07:58:31 -05:00
parent ba16d65d02
commit dacbdf3f38
2 changed files with 18 additions and 0 deletions

View File

@ -238,6 +238,14 @@ class TerminalController: NSWindowController, NSWindowDelegate,
delegate: self
))
// Give the titlebar a custom background color to account for transparent windows.
window.setTitlebarBackground(
window
.backgroundColor
.withAlphaComponent(self.ghostty.config.backgroundOpacity)
.cgColor
)
// In various situations, macOS automatically tabs new windows. Ghostty handles
// its own tabbing so we DONT want this behavior. This detects this scenario and undoes
// it.

View File

@ -78,6 +78,16 @@ class TerminalWindow: NSWindow {
}
}
// Assign a background color to the titlebar area.
public func setTitlebarBackground(_ color: CGColor) {
guard let titlebarContainer = contentView?.superview?.subviews.first(where: {
$0.className == "NSTitlebarContainerView"
}) else { return }
titlebarContainer.wantsLayer = true
titlebarContainer.layer?.backgroundColor = color
}
private var windowButtonsBackdrop: NSView? = nil
private func addWindowButtonsBackdrop(titlebarView: NSView, toolbarView: NSView) {