macOS: update window appearance based on `preferredBackgroundColor` (#9344)
### Background > Reported from https://discord.com/channels/1005603569187160125/1320882404717625374/1431258448439279709 Per current implementation, when `macos-titlebar-style` is `tabs` or `transparent`, the titlebar's background is hidden to enable a blur effect, but this could result in an incorrect appearance when the window's appearance is different from the one based on the terminal's background color. For instance, with the following configs: ``` window-theme = "light" // theme will be default to Ghostty, which is dark ``` or ``` window-theme = "system" // theme will be default to Ghostty, which is dark // and system theme is set to light ``` ### Changes Update window theme based on the terminal's background color when using `tabs` or `transparent`pull/9346/head
commit
9703d6cb6c
|
|
@ -143,6 +143,10 @@ class TitlebarTabsVenturaTerminalWindow: TerminalWindow {
|
||||||
|
|
||||||
override func syncAppearance(_ surfaceConfig: Ghostty.SurfaceView.DerivedConfig) {
|
override func syncAppearance(_ surfaceConfig: Ghostty.SurfaceView.DerivedConfig) {
|
||||||
super.syncAppearance(surfaceConfig)
|
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
|
// Update our window light/darkness based on our updated background color
|
||||||
let themeChanged = isLightTheme != OSColor(surfaceConfig.backgroundColor).isLightColor
|
let themeChanged = isLightTheme != OSColor(surfaceConfig.backgroundColor).isLightColor
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,10 @@ class TransparentTitlebarTerminalWindow: TerminalWindow {
|
||||||
|
|
||||||
override func syncAppearance(_ surfaceConfig: Ghostty.SurfaceView.DerivedConfig) {
|
override func syncAppearance(_ surfaceConfig: Ghostty.SurfaceView.DerivedConfig) {
|
||||||
super.syncAppearance(surfaceConfig)
|
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
|
// Save our config in case we need to reapply
|
||||||
lastSurfaceConfig = surfaceConfig
|
lastSurfaceConfig = surfaceConfig
|
||||||
|
|
|
||||||
|
|
@ -1765,7 +1765,7 @@ keybind: Keybinds = .{},
|
||||||
/// * `ghostty` - Use the background and foreground colors specified in the
|
/// * `ghostty` - Use the background and foreground colors specified in the
|
||||||
/// Ghostty configuration. This is only supported on Linux builds.
|
/// 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.
|
/// automatically set based on the luminosity of the terminal background color.
|
||||||
/// This only applies to terminal windows. This setting will still apply to
|
/// This only applies to terminal windows. This setting will still apply to
|
||||||
/// non-terminal windows within Ghostty.
|
/// non-terminal windows within Ghostty.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue