mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: use enum for window theme
This commit is contained in:
@ -255,7 +255,10 @@ class TerminalController: NSWindowController, NSWindowDelegate,
|
|||||||
// This makes sure our titlebar renders correctly when there is a transparent background
|
// This makes sure our titlebar renders correctly when there is a transparent background
|
||||||
window.titlebarColor = backgroundColor.withAlphaComponent(ghostty.config.backgroundOpacity)
|
window.titlebarColor = backgroundColor.withAlphaComponent(ghostty.config.backgroundOpacity)
|
||||||
|
|
||||||
window.windowTheme = ghostty.config.windowTheme
|
// Make sure our theme is set on the window so styling is correct.
|
||||||
|
if let windowTheme = ghostty.config.windowTheme {
|
||||||
|
window.windowTheme = .init(rawValue: windowTheme)
|
||||||
|
}
|
||||||
|
|
||||||
// Handle titlebar tabs config option. Something about what we do while setting up the
|
// 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
|
// titlebar tabs interferes with the window restore process unless window.tabbingMode
|
||||||
|
@ -76,7 +76,9 @@ class TerminalWindow: NSWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var windowTheme: String?
|
// The window theme configuration from Ghostty. This is used to control some
|
||||||
|
// behaviors that don't look quite right in certain situations.
|
||||||
|
var windowTheme: TerminalWindowTheme?
|
||||||
|
|
||||||
// We only need to set this once, but need to do it after the window has been created in order
|
// We only need to set this once, but need to do it after the window has been created in order
|
||||||
// to determine if the theme is using a very dark background, in which case we don't want to
|
// to determine if the theme is using a very dark background, in which case we don't want to
|
||||||
@ -134,7 +136,10 @@ class TerminalWindow: NSWindow {
|
|||||||
|
|
||||||
updateResetZoomTitlebarButtonVisibility()
|
updateResetZoomTitlebarButtonVisibility()
|
||||||
|
|
||||||
guard let windowTheme, windowTheme == "auto" else { return }
|
// The remainder of the styles we only apply if we're on "auto" theming
|
||||||
|
// because they conflict with the appearance being forced a certain
|
||||||
|
// direction. See issue #1709.
|
||||||
|
guard let windowTheme, windowTheme == .auto else { return }
|
||||||
|
|
||||||
titlebarSeparatorStyle = tabbedWindows != nil && !titlebarTabs ? .line : .none
|
titlebarSeparatorStyle = tabbedWindows != nil && !titlebarTabs ? .line : .none
|
||||||
|
|
||||||
@ -631,3 +636,9 @@ fileprivate class WindowButtonsBackdropView: NSView {
|
|||||||
layer?.addSublayer(overlayLayer)
|
layer?.addSublayer(overlayLayer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum TerminalWindowTheme: String {
|
||||||
|
case auto
|
||||||
|
case light
|
||||||
|
case dark
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user