mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
Merge pull request #1433 from mitchellh/macos-titlebar-light
macos: titlebar tabs set window appearance based on bg luminance
This commit is contained in:
@ -59,11 +59,24 @@ class TerminalWindow: NSWindow {
|
||||
}) {
|
||||
toolbarTitleView.isHidden = true
|
||||
}
|
||||
|
||||
// We match the appearance depending on the lightness/darkness of the
|
||||
// background color. We have to do this because our titlebars in tabs inherit
|
||||
// our background color for the focused tab but use the macOS theme for the
|
||||
// rest of the titlebar.
|
||||
if let appDelegate = NSApp.delegate as? AppDelegate {
|
||||
let color = OSColor(appDelegate.ghostty.config.backgroundColor)
|
||||
let appearance = NSAppearance(named: color.isLightColor ? .aqua : .darkAqua)
|
||||
self.appearance = appearance
|
||||
}
|
||||
} else {
|
||||
// "expanded" places the toolbar below the titlebar, so setting this style and
|
||||
// removing the toolbar ensures that the titlebar will be the default height.
|
||||
self.toolbarStyle = .expanded
|
||||
self.toolbar = nil
|
||||
|
||||
// Reset the appearance to whatever our app global value is
|
||||
self.appearance = nil
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -604,6 +604,11 @@ keybind: Keybinds = .{},
|
||||
/// whatever the system theme is will be used. This can also be set to `light`
|
||||
/// or `dark` to force a specific theme regardless of the system settings.
|
||||
///
|
||||
/// On macOS, if `macos-titlebar-tabs` is set, the window theme will be
|
||||
/// automatically set based on the luminosity of the terminal background color.
|
||||
/// This only applies to terminal windows. This setting will still apply to
|
||||
/// non-terminal windows within Ghostty.
|
||||
///
|
||||
/// This is currently only supported on macOS and Linux.
|
||||
@"window-theme": WindowTheme = .system,
|
||||
|
||||
|
Reference in New Issue
Block a user