mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
Fix new tab icon color not updating sometimes
This commit is contained in:
@ -167,8 +167,6 @@ class TerminalWindow: NSWindow {
|
|||||||
backgroundColor.luminance < 0.05
|
backgroundColor.luminance < 0.05
|
||||||
}
|
}
|
||||||
|
|
||||||
private var newTabButtonImage: NSImage? = nil
|
|
||||||
|
|
||||||
private var newTabButtonImageLayer: VibrantLayer? = nil
|
private var newTabButtonImageLayer: VibrantLayer? = nil
|
||||||
|
|
||||||
func updateTabBar() {
|
func updateTabBar() {
|
||||||
@ -208,16 +206,11 @@ class TerminalWindow: NSWindow {
|
|||||||
guard let newTabButtonImageView: NSImageView = newTabButton.subviews.first(where: {
|
guard let newTabButtonImageView: NSImageView = newTabButton.subviews.first(where: {
|
||||||
$0 as? NSImageView != nil
|
$0 as? NSImageView != nil
|
||||||
}) as? NSImageView else { return }
|
}) as? NSImageView else { return }
|
||||||
|
guard let newTabButtonImage = newTabButtonImageView.image else { return }
|
||||||
|
|
||||||
if newTabButtonImage == nil {
|
|
||||||
newTabButtonImage = newTabButtonImageView.image
|
|
||||||
}
|
|
||||||
|
|
||||||
guard let newTabButtonImage else { return }
|
|
||||||
|
|
||||||
let isLightTheme = backgroundColor.isLightColor
|
|
||||||
|
|
||||||
if newTabButtonImageLayer == nil {
|
if newTabButtonImageLayer == nil {
|
||||||
|
let isLightTheme = backgroundColor.isLightColor
|
||||||
let fillColor: NSColor = isLightTheme ? .black.withAlphaComponent(0.85) : .white.withAlphaComponent(0.85)
|
let fillColor: NSColor = isLightTheme ? .black.withAlphaComponent(0.85) : .white.withAlphaComponent(0.85)
|
||||||
let newImage = NSImage(size: newTabButtonImage.size, flipped: false) { rect in
|
let newImage = NSImage(size: newTabButtonImage.size, flipped: false) { rect in
|
||||||
newTabButtonImage.draw(in: rect)
|
newTabButtonImage.draw(in: rect)
|
||||||
@ -234,12 +227,9 @@ class TerminalWindow: NSWindow {
|
|||||||
newTabButtonImageLayer = imageLayer
|
newTabButtonImageLayer = imageLayer
|
||||||
}
|
}
|
||||||
|
|
||||||
newTabButtonImageView.layer?.sublayers?.first(where: { $0.className == "VibrantLayer" })?.removeFromSuperlayer()
|
newTabButtonImageView.isHidden = true
|
||||||
newTabButtonImageView.layer?.addSublayer(newTabButtonImageLayer!)
|
newTabButton.layer?.sublayers?.first(where: { $0.className == "VibrantLayer" })?.removeFromSuperlayer()
|
||||||
newTabButtonImageView.image = nil
|
newTabButton.layer?.addSublayer(newTabButtonImageLayer!)
|
||||||
// When we nil out the original image, the image view's frame resizes and repositions
|
|
||||||
// slightly, so we need to reset it to make sure our new image doesn't shift quickly.
|
|
||||||
newTabButtonImageView.frame = newTabButton.bounds
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func updateTabsForVeryDarkBackgrounds() {
|
private func updateTabsForVeryDarkBackgrounds() {
|
||||||
|
Reference in New Issue
Block a user