macOS: update window appearance based on `preferredBackgroundColor`

pull/9344/head
Lars 2025-10-25 18:08:53 +02:00
parent 3f75c66e83
commit d39cc6d478
No known key found for this signature in database
GPG Key ID: 845CB61BD38F4E49
3 changed files with 9 additions and 1 deletions

View File

@ -143,6 +143,10 @@ class TitlebarTabsVenturaTerminalWindow: TerminalWindow {
override func syncAppearance(_ surfaceConfig: Ghostty.SurfaceView.DerivedConfig) {
super.syncAppearance(surfaceConfig)
// override appearance based on the terminal's background color
if let preferredBackgroundColor {
appearance = (preferredBackgroundColor.isLightColor ? NSAppearance(named: .aqua) : NSAppearance(named: .darkAqua))
}
// Update our window light/darkness based on our updated background color
let themeChanged = isLightTheme != OSColor(surfaceConfig.backgroundColor).isLightColor

View File

@ -59,6 +59,10 @@ class TransparentTitlebarTerminalWindow: TerminalWindow {
override func syncAppearance(_ surfaceConfig: Ghostty.SurfaceView.DerivedConfig) {
super.syncAppearance(surfaceConfig)
// override appearance based on the terminal's background color
if let preferredBackgroundColor {
appearance = (preferredBackgroundColor.isLightColor ? NSAppearance(named: .aqua) : NSAppearance(named: .darkAqua))
}
// Save our config in case we need to reapply
lastSurfaceConfig = surfaceConfig

View File

@ -1765,7 +1765,7 @@ keybind: Keybinds = .{},
/// * `ghostty` - Use the background and foreground colors specified in the
/// Ghostty configuration. This is only supported on Linux builds.
///
/// On macOS, if `macos-titlebar-style` is "tabs", the window theme will be
/// On macOS, if `macos-titlebar-style` is `tabs` or `transparent`, 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.