mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
feat: add macos-title-bar-luminance-check
this paves the road for disabling the custom colored titleBar on macOS
This commit is contained in:
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user