From 98ad832d86231157630d53259d0aedce9d8f01ea Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 1 Feb 2024 21:16:03 -0800 Subject: [PATCH] macos: set window button backdrop color based on appearance --- .../Sources/Features/Terminal/TerminalWindow.swift | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/macos/Sources/Features/Terminal/TerminalWindow.swift b/macos/Sources/Features/Terminal/TerminalWindow.swift index b01d14ebe..1d8e5ce83 100644 --- a/macos/Sources/Features/Terminal/TerminalWindow.swift +++ b/macos/Sources/Features/Terminal/TerminalWindow.swift @@ -177,7 +177,6 @@ class TerminalWindow: NSWindow { view.topAnchor.constraint(equalTo: toolbarView.topAnchor).isActive = true view.heightAnchor.constraint(equalTo: toolbarView.heightAnchor).isActive = true view.wantsLayer = true - view.layer?.backgroundColor = CGColor(genericGrayGamma2_2Gray: 0.0, alpha: 0.45) let topBorder = NSView() view.addSubview(topBorder) @@ -187,7 +186,17 @@ class TerminalWindow: NSWindow { topBorder.topAnchor.constraint(equalTo: view.topAnchor).isActive = true topBorder.bottomAnchor.constraint(equalTo: view.topAnchor, constant: 1).isActive = true topBorder.wantsLayer = true - topBorder.layer?.backgroundColor = CGColor(genericGrayGamma2_2Gray: 0.0, alpha: 0.85) + + // This is jank but this makes the background color for light themes on the button + // backdrop look MUCH better. I couldn't figure out a perfect color to use that works + // for both so we just check the appearance. + if effectiveAppearance.name == .aqua { + view.layer?.backgroundColor = NSColor.textBackgroundColor.cgColor.copy(alpha: 0.45) + topBorder.layer?.backgroundColor = NSColor.textBackgroundColor.cgColor.copy(alpha: 0.85) + } else { + view.layer?.backgroundColor = CGColor(genericGrayGamma2_2Gray: 0.0, alpha: 0.45) + topBorder.layer?.backgroundColor = CGColor(genericGrayGamma2_2Gray: 0.0, alpha: 0.85) + } windowButtonsBackdrop = view }