Merge pull request #1527 from tt/set-background-color-in-title-bar-tab-mode-only

Set background color in title bar tab mode only
This commit is contained in:
Mitchell Hashimoto
2024-02-16 13:55:32 -08:00
committed by GitHub

View File

@ -254,10 +254,7 @@ class TerminalController: NSWindowController, NSWindowDelegate,
// Center the window to start, we'll move the window frame automatically // Center the window to start, we'll move the window frame automatically
// when cascading. // when cascading.
window.center() window.center()
// Set the background color of the window
window.backgroundColor = NSColor(ghostty.config.backgroundColor)
// Handle titlebar tabs config option. Something about what we do while setting up the // Handle titlebar tabs config option. Something about what we do while setting up the
// titlebar tabs interferes with the window restore process unless window.tabbingMode // titlebar tabs interferes with the window restore process unless window.tabbingMode
// is set to .preferred, so we set it, and switch back to automatic as soon as we can. // is set to .preferred, so we set it, and switch back to automatic as soon as we can.
@ -268,17 +265,20 @@ class TerminalController: NSWindowController, NSWindowDelegate,
DispatchQueue.main.async { DispatchQueue.main.async {
window.tabbingMode = .automatic window.tabbingMode = .automatic
} }
// Set the background color of the window
window.backgroundColor = NSColor(ghostty.config.backgroundColor)
// Set a custom background on the titlebar - this is required for when
// titlebar tabs are used in conjunction with a transparent background.
window.setTitlebarBackground(
window
.backgroundColor
.withAlphaComponent(ghostty.config.backgroundOpacity)
.cgColor
)
} }
// Set a custom background on the titlebar - this is required for when
// titlebar tabs is used in conjunction with a transparent background.
window.setTitlebarBackground(
window
.backgroundColor
.withAlphaComponent(ghostty.config.backgroundOpacity)
.cgColor
)
// Initialize our content view to the SwiftUI root // Initialize our content view to the SwiftUI root
window.contentView = NSHostingView(rootView: TerminalView( window.contentView = NSHostingView(rootView: TerminalView(
ghostty: self.ghostty, ghostty: self.ghostty,