diff --git a/CotEditor/Sources/DocumentWindow.swift b/CotEditor/Sources/DocumentWindow.swift index f9852a8278..920466fd68 100644 --- a/CotEditor/Sources/DocumentWindow.swift +++ b/CotEditor/Sources/DocumentWindow.swift @@ -24,7 +24,6 @@ // import AppKit -import Combine final class DocumentWindow: NSWindow { @@ -59,11 +58,6 @@ final class DocumentWindow: NSWindow { } - // MARK: Private Properties - - private var appearanceObserver: AnyCancellable? - - // MARK: - // MARK: Window Methods @@ -98,17 +92,6 @@ final class DocumentWindow: NSWindow { didSet { self.didChangeValue(for: \.isOpaque) - - guard isOpaque != oldValue else { return } - - self.invalidateTitlebarOpacity() - - if isOpaque { - self.appearanceObserver = nil - } else if self.appearanceObserver == nil { - self.appearanceObserver = self.publisher(for: \.effectiveAppearance) - .sink { [weak self] _ in self?.invalidateTitlebarOpacity() } - } } } @@ -172,17 +155,6 @@ final class DocumentWindow: NSWindow { self.invalidateRestorableState() } } - - - /// Make sure window title bar (incl. toolbar) is opaque. - private func invalidateTitlebarOpacity() { - - guard let titlebarView = self.standardWindowButton(.closeButton)?.superview else { return } - - // dirty manipulation to avoid the title bar being dyed in the window background color (2016-01). - titlebarView.wantsLayer = !self.isOpaque - titlebarView.layer?.backgroundColor = self.isOpaque ? nil : NSColor.windowBackgroundColor.cgColor(for: self.effectiveAppearance) - } } diff --git a/CotEditor/Sources/HoleContentView.swift b/CotEditor/Sources/HoleContentView.swift index 79279d6b25..217e0021fd 100644 --- a/CotEditor/Sources/HoleContentView.swift +++ b/CotEditor/Sources/HoleContentView.swift @@ -43,7 +43,7 @@ final class HoleContentView: NSView { super.viewWillMove(toWindow: newWindow) - self.windowOpacityObserver = newWindow?.publisher(for: \.isOpaque) + self.windowOpacityObserver = newWindow?.publisher(for: \.isOpaque, options: .initial) .sink { [unowned self] isOpaque in self.holeViewObserver = if isOpaque { nil diff --git a/CotEditor/Sources/NSColor+NamedColors.swift b/CotEditor/Sources/NSColor+NamedColors.swift index 3d6caf442e..5a6d5724d6 100644 --- a/CotEditor/Sources/NSColor+NamedColors.swift +++ b/CotEditor/Sources/NSColor+NamedColors.swift @@ -35,23 +35,6 @@ extension NSColor { extension NSColor { - /// Return CGColor of the receiver by converting system color correctly for the specific appearance. - /// - /// - Parameter appearance: The appearance to get the corresponding system color. - /// - Returns: A CGColor instance. - func cgColor(for appearance: NSAppearance) -> CGColor { - - guard NSAppearance.currentDrawing() != appearance else { return self.cgColor } - - var cgColor: CGColor = .clear - appearance.performAsCurrentDrawingAppearance { - cgColor = self.cgColor - } - - return cgColor - } - - /// Create desired number of well distributed colors from the receiver. /// /// - Parameter number: The required number of colors.