diff --git a/macos/Sources/Features/Terminal/TerminalController.swift b/macos/Sources/Features/Terminal/TerminalController.swift index 8118103d6..252e40eb5 100644 --- a/macos/Sources/Features/Terminal/TerminalController.swift +++ b/macos/Sources/Features/Terminal/TerminalController.swift @@ -212,6 +212,9 @@ class TerminalController: BaseTerminalController { // Set our explicit appearance if we need to based on the configuration. window.appearance = surfaceConfig.windowAppearance + // Update our window light/darkness based on our updated background color + window.isLightTheme = OSColor(surfaceConfig.backgroundColor).isLightColor + // If our window is not visible, then we do nothing. Some things such as blurring // have no effect if the window is not visible. Ultimately, we'll have this called // at some point when a surface becomes focused. diff --git a/macos/Sources/Features/Terminal/TerminalWindow.swift b/macos/Sources/Features/Terminal/TerminalWindow.swift index 9d29c193f..3209449e4 100644 --- a/macos/Sources/Features/Terminal/TerminalWindow.swift +++ b/macos/Sources/Features/Terminal/TerminalWindow.swift @@ -3,6 +3,10 @@ import Cocoa class TerminalWindow: NSWindow { @objc dynamic var keyEquivalent: String = "" + /// This is used to determine if certain elements should be drawn light or dark and should + /// be updated whenever the window background color or surrounding elements changes. + var isLightTheme: Bool = false + lazy var titlebarColor: NSColor = backgroundColor { didSet { guard let titlebarContainer else { return } @@ -295,7 +299,6 @@ class TerminalWindow: NSWindow { if newTabButtonImageLayer == nil { - let isLightTheme = backgroundColor.isLightColor let fillColor: NSColor = isLightTheme ? .black.withAlphaComponent(0.85) : .white.withAlphaComponent(0.85) let newImage = NSImage(size: newTabButtonImage.size, flipped: false) { rect in newTabButtonImage.draw(in: rect) @@ -714,7 +717,7 @@ fileprivate class WindowButtonsBackdropView: NSView { init(window: TerminalWindow) { self.terminalWindow = window - self.isLightTheme = window.backgroundColor.isLightColor + self.isLightTheme = window.isLightTheme super.init(frame: .zero)