mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
fix(macOS): set titlebar background color to support transparent windows with titlebar tabs
This commit is contained in:
@ -237,6 +237,14 @@ class TerminalController: NSWindowController, NSWindowDelegate,
|
||||
viewModel: self,
|
||||
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
|
||||
|
@ -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) {
|
||||
|
Reference in New Issue
Block a user