feat: add macos-title-bar-luminance-check

this paves the road for disabling the custom colored titleBar on macOS
This commit is contained in:
Haze Booth
2024-06-06 23:37:00 -04:00
parent 54ccefe838
commit efc9d3957f
4 changed files with 17 additions and 1 deletions

View File

@ -265,6 +265,8 @@ class TerminalController: NSWindowController, NSWindowDelegate,
if let windowTheme = ghostty.config.windowTheme {
window.windowTheme = .init(rawValue: windowTheme)
}
window.titleBarLuminanceCheck = ghostty.config.titleBarLuminanceCheck
// 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

View File

@ -151,7 +151,7 @@ class TerminalWindow: NSWindow {
if let titlebarContainer = contentView?.superview?.subviews.first(where: {
$0.className == "NSTitlebarContainerView"
}), let effectView = titlebarContainer.descendants(withClassName: "NSVisualEffectView").first {
effectView.isHidden = titlebarTabs || !titlebarTabs && !hasVeryDarkBackground
effectView.isHidden = titlebarTabs || !titlebarTabs && !hasVeryDarkBackground && !titleBarLuminanceCheck
}
effectViewIsHidden = true
@ -188,6 +188,8 @@ class TerminalWindow: NSWindow {
var hasVeryDarkBackground: Bool {
backgroundColor.luminance < 0.05
}
var titleBarLuminanceCheck: Bool
private var newTabButtonImageLayer: VibrantLayer? = nil

View File

@ -236,6 +236,14 @@ extension Ghostty {
return v
}
var titleBarLuminanceCheck: Bool {
guard let config = self.config else { return false }
var v = false;
let key = "macos-title-bar-luminance-check"
_ = ghostty_config_get(config, &v, key, UInt(key.count))
return v
}
var backgroundColor: Color {
var rgb: UInt32 = 0
let bg_key = "background"

View File

@ -976,6 +976,10 @@ keybind: Keybinds = .{},
/// This option only applies to new windows when changed.
@"macos-titlebar-tabs": bool = false,
/// If `true`, check the luminance of the background and show the custom effect
/// (custom colored titlebars) )if the luminance is too low.
@"macos-title-bar-luminance-check": bool = true,
/// If `true`, the *Option* key will be treated as *Alt*. This makes terminal
/// sequences expecting *Alt* to work properly, but will break Unicode input
/// sequences on macOS if you use them via the *Alt* key. You may set this to