From ea772a19af1398816b4c7daa524936a2976c4a61 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Fri, 27 Nov 2026 19:00:53 +0700 Subject: [PATCH 1/2] fix(theme): stop a themed window covering the sidebar in full screen --- .claude/rules/theme.md | 3 + .../Infrastructure/ContentWindow.swift | 30 ++-- .../MainSplitViewController.swift | 4 - .../Infrastructure/TabWindowController.swift | 4 + .../Compare/CompareSyncWindowController.swift | 4 + .../DataFiles/DataFileWindowController.swift | 4 + .../Views/Main/EditorTabItemView.swift | 4 + .../Views/Main/EditorTabStripSurfaces.swift | 18 ++ .../Views/Main/EditorTabStripView.swift | 8 +- .../Services/ContentWindowTitlebarTests.swift | 63 ++++--- .../Main/EditorTabStripTrackThemeTests.swift | 51 +++++- .../check-fullscreen-titlebar-backstop.sh | 158 ++++++++++++++++++ 12 files changed, 307 insertions(+), 44 deletions(-) create mode 100755 apple/scripts/probes/check-fullscreen-titlebar-backstop.sh diff --git a/.claude/rules/theme.md b/.claude/rules/theme.md index 48ad7ede79..da038ea903 100644 --- a/.claude/rules/theme.md +++ b/.claude/rules/theme.md @@ -38,6 +38,9 @@ paths: - **A content window subclasses `ContentWindow`** and holds a `ThemeWindowBackdrop`. On macOS 26 and later the backdrop sets `window.background` only while the theme sets it; earlier the window keeps its own color. Code asks `ThemeWindowBackdrop.canReachChrome`, never an `#available` of its own. - `ContentWindow` owns the titlebar. Before macOS 26 it stays opaque: a transparent one there swaps its material for a flat fill. +- **In full screen the titlebar stays opaque too.** There it moves into a window of its own, and transparent under a custom window color it draws an opaque system backstop over one titlebar section, the sidebar's when the window has an inspector. Handing the color back once full screen has begun does not remove it (`apple/scripts/probes/check-fullscreen-titlebar-backstop.sh`). So the full-screen toolbar is the system material in every theme. +- **An opaque titlebar makes its accessories vibrant**, where system fills resolve darker. A vibrant editor tab strip resolves its fills in its window's appearance (`EditorTabStripPalette.drawing(_:_:)`), so it draws the same on either titlebar, and its track takes the theme only while it is not vibrant. Never build an appearance by name for this: `NSAppearance(named:)` returns nil for the high-contrast names, and the window's appearance already carries Increase Contrast. +- **A delegate of a content window forwards `windowDidFailToEnterFullScreen(_:)` to `ContentWindow.fullScreenEntryDidFail()`.** AppKit can refuse full screen after `willEnterFullScreen` and tells only the delegate. - The detail column sits on `DetailColumnBackdrop`, so a pane that draws nothing shows `window.background`. `DetailPaneBackdropFill` goes only there. - A glass sidebar or inspector pane sits on `SplitItemBackdrop`, pinned to the pane's edges and not its safe area, so it covers the titlebar band too. It draws only under Reduce Transparency (Content, never chrome) and is clear otherwise, so the glass shows. diff --git a/apple/TablePro/Core/Services/Infrastructure/ContentWindow.swift b/apple/TablePro/Core/Services/Infrastructure/ContentWindow.swift index 9744a712d7..6cbadf8f38 100644 --- a/apple/TablePro/Core/Services/Infrastructure/ContentWindow.swift +++ b/apple/TablePro/Core/Services/Infrastructure/ContentWindow.swift @@ -5,9 +5,9 @@ import AppKit -/// The window class of the four content windows: main, Data File, Compare & Sync and the value -/// viewers. On macOS 26 and later the theme reaches a toolbar and titlebar only through -/// `backgroundColor`, and only while the titlebar draws no background of its own. +// The four content windows: main, Data File, Compare & Sync and the value viewers. From macOS 26 the theme +// reaches the toolbar and titlebar only through `backgroundColor`, and only while the titlebar draws no +// background of its own. @MainActor internal class ContentWindow: NSWindow { override internal init( @@ -29,25 +29,25 @@ internal class ContentWindow: NSWindow { ) } - // Hiding the toolbar drops the content's top safe area, so the titlebar is decided again. - override internal func toggleToolbarShown(_ sender: Any?) { - super.toggleToolbarShown(sender) - applyTitlebarPolicy() - } - // The full-screen hooks run either side of the style mask flipping, so they name the state they move to. internal func applyTitlebarPolicy(isFullScreen: Bool? = nil) { guard ThemeWindowBackdrop.canReachChrome else { return } titlebarAppearsTransparent = Self.titlebarIsTransparent( - isFullScreen: isFullScreen ?? styleMask.contains(.fullScreen), - toolbarVisible: toolbar?.isVisible ?? false + isFullScreen: isFullScreen ?? styleMask.contains(.fullScreen) ) } - // In full screen with no toolbar the content reaches the screen edge, and the titlebar that - // slides down over it needs its own background to stay legible. - internal static func titlebarIsTransparent(isFullScreen: Bool, toolbarVisible: Bool) -> Bool { - isFullScreen ? toolbarVisible : true + // Full screen moves the titlebar into a window of its own. Transparent over a themed window, it draws an + // opaque system backstop under one section in place of the window color, the sidebar's when there is an + // inspector, and changing the color once it is up does not remove it + // (apple/scripts/probes/check-fullscreen-titlebar-backstop.sh). + internal static func titlebarIsTransparent(isFullScreen: Bool) -> Bool { + !isFullScreen + } + + // AppKit can refuse full screen after posting willEnterFullScreen, and tells only the delegate. + internal func fullScreenEntryDidFail() { + applyTitlebarPolicy(isFullScreen: false) } @objc private func willEnterFullScreen(_ notification: Notification) { diff --git a/apple/TablePro/Core/Services/Infrastructure/MainSplitViewController.swift b/apple/TablePro/Core/Services/Infrastructure/MainSplitViewController.swift index b180a61079..a1ec7e30e5 100644 --- a/apple/TablePro/Core/Services/Infrastructure/MainSplitViewController.swift +++ b/apple/TablePro/Core/Services/Infrastructure/MainSplitViewController.swift @@ -532,10 +532,6 @@ internal final class MainSplitViewController: NSSplitViewController { /// when the window appears. A repoint cannot be relied on for this: a window opening with /// no session repoints from nothing to nothing, which returns before it reaches the toolbar. owner.refreshContext(forcing: true) - /// The transparency decision reads `window.toolbar?.isVisible`, so a window that gains its - /// toolbar after that decision was taken keeps the opaque titlebar chosen for a - /// toolbar-less one, over content that is no longer inset below it. - (window as? ContentWindow)?.applyTitlebarPolicy() } /// The window's toolbar goes too. Dropping only the owner left the built `NSToolbar` on the diff --git a/apple/TablePro/Core/Services/Infrastructure/TabWindowController.swift b/apple/TablePro/Core/Services/Infrastructure/TabWindowController.swift index e7e27abb5e..f73d5e8de2 100644 --- a/apple/TablePro/Core/Services/Infrastructure/TabWindowController.swift +++ b/apple/TablePro/Core/Services/Infrastructure/TabWindowController.swift @@ -308,6 +308,10 @@ internal final class TabWindowController: NSWindowController, NSWindowDelegate { return false } + internal func windowDidFailToEnterFullScreen(_ window: NSWindow) { + (window as? ContentWindow)?.fullScreenEntryDidFail() + } + internal func windowWillClose(_ notification: Notification) { let seq = MainContentCoordinator.nextSwitchSeq() let t0 = Date() diff --git a/apple/TablePro/Views/Compare/CompareSyncWindowController.swift b/apple/TablePro/Views/Compare/CompareSyncWindowController.swift index 993136a3d6..03055e5421 100644 --- a/apple/TablePro/Views/Compare/CompareSyncWindowController.swift +++ b/apple/TablePro/Views/Compare/CompareSyncWindowController.swift @@ -764,6 +764,10 @@ internal final class CompareSyncWindowController: NSWindowController, window.close() } + internal func windowDidFailToEnterFullScreen(_ window: NSWindow) { + (window as? ContentWindow)?.fullScreenEntryDidFail() + } + internal func windowWillClose(_ notification: Notification) { // Stays listed until the run itself ends: a statement already sent can still be writing. session.cancelRunningWork() diff --git a/apple/TablePro/Views/DataFiles/DataFileWindowController.swift b/apple/TablePro/Views/DataFiles/DataFileWindowController.swift index 945b1c42ef..bac20ba026 100644 --- a/apple/TablePro/Views/DataFiles/DataFileWindowController.swift +++ b/apple/TablePro/Views/DataFiles/DataFileWindowController.swift @@ -98,6 +98,10 @@ final class DataFileWindowController: NSWindowController, NSWindowDelegate, NSTo (contentViewController as? DataFileSplitViewController)?.dismissTransientUI() } + func windowDidFailToEnterFullScreen(_ window: NSWindow) { + (window as? ContentWindow)?.fullScreenEntryDidFail() + } + func focusSearchField() { searchItem?.beginSearchInteraction() } diff --git a/apple/TablePro/Views/Main/EditorTabItemView.swift b/apple/TablePro/Views/Main/EditorTabItemView.swift index 35cb1607bd..4a9f1c63d8 100644 --- a/apple/TablePro/Views/Main/EditorTabItemView.swift +++ b/apple/TablePro/Views/Main/EditorTabItemView.swift @@ -278,6 +278,10 @@ internal final class EditorTabItemView: NSView { } override internal func draw(_ dirtyRect: NSRect) { + EditorTabStripPalette.drawing(self) { drawFills() } + } + + private func drawFills() { let metrics = EditorTabStripLayout.self if showsLeadingSeparator { EditorTabStripPalette.separatorColor.setFill() diff --git a/apple/TablePro/Views/Main/EditorTabStripSurfaces.swift b/apple/TablePro/Views/Main/EditorTabStripSurfaces.swift index 672ebef479..addcb47f71 100644 --- a/apple/TablePro/Views/Main/EditorTabStripSurfaces.swift +++ b/apple/TablePro/Views/Main/EditorTabStripSurfaces.swift @@ -15,6 +15,24 @@ internal enum EditorTabStripPalette { followsWindowBackdrop && ThemeBackdropState.isThemed(highContrast: highContrast) } + // A vibrant strip sits on the material of an opaque titlebar, which the window color never reaches. + @MainActor + internal static func isOverThemedBackdrop(in appearance: NSAppearance, highContrast: Bool) -> Bool { + !appearance.allowsVibrancy && isOverThemedBackdrop(highContrast: highContrast) + } + + // An opaque titlebar, as in full screen, makes the strip vibrant, where `controlColor` resolves darker than + // the track. The fills are picked for the transparent titlebar, so a vibrant strip resolves them in its + // window's appearance, which also carries Increase Contrast. + @MainActor + internal static func drawing(_ view: NSView, _ body: () -> Void) { + guard view.effectiveAppearance.allowsVibrancy, let window = view.window else { + body() + return + } + window.effectiveAppearance.performAsCurrentDrawingAppearance(body) + } + // Over a themed window an opaque gray cuts a slab into the theme, so the track takes a translucent system fill. internal static func trackColor(overThemedBackdrop: Bool) -> NSColor { let native = NSColor.unemphasizedSelectedContentBackgroundColor diff --git a/apple/TablePro/Views/Main/EditorTabStripView.swift b/apple/TablePro/Views/Main/EditorTabStripView.swift index 6d5e851380..24999476f1 100644 --- a/apple/TablePro/Views/Main/EditorTabStripView.swift +++ b/apple/TablePro/Views/Main/EditorTabStripView.swift @@ -844,9 +844,13 @@ internal final class EditorTabTrackView: NSView { override internal var mouseDownCanMoveWindow: Bool { false } override internal func draw(_ dirtyRect: NSRect) { - let radius = bounds.height / 2 let highContrast = NSWorkspace.shared.accessibilityDisplayShouldIncreaseContrast - let themed = EditorTabStripPalette.isOverThemedBackdrop(highContrast: highContrast) + let themed = EditorTabStripPalette.isOverThemedBackdrop(in: effectiveAppearance, highContrast: highContrast) + EditorTabStripPalette.drawing(self) { drawTrack(overThemedBackdrop: themed) } + } + + private func drawTrack(overThemedBackdrop themed: Bool) { + let radius = bounds.height / 2 EditorTabStripPalette.trackColor(overThemedBackdrop: themed).setFill() NSBezierPath(roundedRect: bounds, xRadius: radius, yRadius: radius).fill() diff --git a/apple/TableProTests/Services/ContentWindowTitlebarTests.swift b/apple/TableProTests/Services/ContentWindowTitlebarTests.swift index cb199f1998..e97ae23f56 100644 --- a/apple/TableProTests/Services/ContentWindowTitlebarTests.swift +++ b/apple/TableProTests/Services/ContentWindowTitlebarTests.swift @@ -8,8 +8,7 @@ import SwiftUI @testable import TablePro import Testing -/// The four content windows as the app builds them. Never ordered front and never closed: `close()` -/// on a test window over-releases it. +// Never ordered front, and closed only with isReleasedWhenClosed off: `close()` on a test window over-releases it. @MainActor struct ContentWindowTitlebarTests { private struct Built { @@ -73,21 +72,11 @@ struct ContentWindowTitlebarTests { } @Test( - "The titlebar stays opaque only in full screen with the toolbar hidden", - arguments: [ - (isFullScreen: false, toolbarVisible: false, transparent: true), - (isFullScreen: false, toolbarVisible: true, transparent: true), - (isFullScreen: true, toolbarVisible: true, transparent: true), - (isFullScreen: true, toolbarVisible: false, transparent: false), - ] + "The titlebar is transparent in a window and opaque in full screen", + arguments: [(isFullScreen: false, transparent: true), (isFullScreen: true, transparent: false)] ) - func transparencyFollowsTheSafeArea(state: (isFullScreen: Bool, toolbarVisible: Bool, transparent: Bool)) { - #expect( - ContentWindow.titlebarIsTransparent( - isFullScreen: state.isFullScreen, - toolbarVisible: state.toolbarVisible - ) == state.transparent - ) + func transparencyFollowsFullScreen(state: (isFullScreen: Bool, transparent: Bool)) { + #expect(ContentWindow.titlebarIsTransparent(isFullScreen: state.isFullScreen) == state.transparent) } @Test( @@ -113,7 +102,7 @@ struct ContentWindowTitlebarTests { } @Test( - "A full-screen window keeps a transparent titlebar while its toolbar is showing", + "The main window keeps an opaque titlebar in full screen while its toolbar is showing", .enabled( if: ProcessInfo.processInfo.isOperatingSystemAtLeast( OperatingSystemVersion(majorVersion: 26, minorVersion: 0, patchVersion: 0) @@ -122,8 +111,12 @@ struct ContentWindowTitlebarTests { ) ) func fullScreenWithAToolbar() throws { - let window = CompareSyncWindowController.makeWindow() - defer { window.toolbar = nil } + let window = TabWindowController.makeEditorWindow() + window.isReleasedWhenClosed = false + defer { + window.toolbar = nil + window.close() + } let toolbar = NSToolbar(identifier: "com.TablePro.tests.titlebar.\(UUID().uuidString)") toolbar.autosavesConfiguration = false window.toolbar = toolbar @@ -131,10 +124,36 @@ struct ContentWindowTitlebarTests { try #require(toolbar.isVisible) NotificationCenter.default.post(name: NSWindow.willEnterFullScreenNotification, object: window) + #expect(!window.titlebarAppearsTransparent) + + NotificationCenter.default.post(name: NSWindow.didExitFullScreenNotification, object: window) #expect(window.titlebarAppearsTransparent) + } - toolbar.isVisible = false - NotificationCenter.default.post(name: NSWindow.willEnterFullScreenNotification, object: window) - #expect(!window.titlebarAppearsTransparent) + @Test( + "A full-screen entry AppKit refuses gives the window its transparent titlebar back", + .enabled( + if: ProcessInfo.processInfo.isOperatingSystemAtLeast( + OperatingSystemVersion(majorVersion: 26, minorVersion: 0, patchVersion: 0) + ), + "the titlebar turns transparent from macOS 26" + ) + ) + func failedFullScreenEntry() throws { + let fixture = try OffscreenConnectionWindow(size: CGSize(width: 1_200, height: 800)) + defer { fixture.tearDown() } + let dataFile = DataFileWindowController(document: DataFileDocument()) + let dataFileWindow = try #require(dataFile.window) + defer { dataFileWindow.delegate = nil } + let windows: [(NSWindow, () -> Void)] = [ + (fixture.window, { fixture.controller.windowDidFailToEnterFullScreen(fixture.window) }), + (dataFileWindow, { dataFile.windowDidFailToEnterFullScreen(dataFileWindow) }), + ] + for (window, fail) in windows { + NotificationCenter.default.post(name: NSWindow.willEnterFullScreenNotification, object: window) + #expect(!window.titlebarAppearsTransparent) + fail() + #expect(window.titlebarAppearsTransparent) + } } } diff --git a/apple/TableProTests/Views/Main/EditorTabStripTrackThemeTests.swift b/apple/TableProTests/Views/Main/EditorTabStripTrackThemeTests.swift index b45127fa0f..c83369db81 100644 --- a/apple/TableProTests/Views/Main/EditorTabStripTrackThemeTests.swift +++ b/apple/TableProTests/Views/Main/EditorTabStripTrackThemeTests.swift @@ -84,12 +84,61 @@ struct EditorTabStripTrackThemeTests { } private static func center(of view: NSView) throws -> NSColor { + try color(of: view, atFraction: 0.5) + } + + // Left of a tab's centred title, inside its capsule. + private static func color(of view: NSView, atFraction fraction: CGFloat) throws -> NSColor { let bitmap = try #require(view.bitmapImageRepForCachingDisplay(in: view.bounds)) view.cacheDisplay(in: view.bounds, to: bitmap) - let color = try #require(bitmap.colorAt(x: bitmap.pixelsWide / 2, y: bitmap.pixelsHigh / 2)) + let x = Int(CGFloat(bitmap.pixelsWide) * fraction) + let color = try #require(bitmap.colorAt(x: x, y: bitmap.pixelsHigh / 2)) return try #require(color.usingColorSpace(.sRGB)) } + @Test( + "On an opaque titlebar's vibrant strip the track and the selected tab draw as on the transparent titlebar", + arguments: [(NSAppearance.Name.vibrantDark, NSAppearance.Name.darkAqua), (.vibrantLight, .aqua)] + ) + func vibrantStripDrawsLikeTheTransparentTitlebar(names: (vibrant: NSAppearance.Name, plain: NSAppearance.Name)) throws { + // Never ordered front and never closed: `close()` on a test window over-releases it. + let window = NSWindow( + contentRect: NSRect(x: 0, y: 0, width: 200, height: 100), + styleMask: [.titled], + backing: .buffered, + defer: true + ) + window.isReleasedWhenClosed = false + window.appearance = NSAppearance(named: names.plain) + let track = EditorTabTrackView(frame: NSRect(x: 0, y: 0, width: 120, height: 40)) + let tab = EditorTabItemView(item: .sample(isSelected: true)) + tab.frame = NSRect(x: 0, y: 50, width: 160, height: 28) + try ThemeTestFixture.adopting(.builtIn, appearance: .dark) { + for view in [track, tab] as [NSView] { + window.contentView?.addSubview(view) + defer { view.removeFromSuperview() } + view.appearance = nil + let plain = try Self.color(of: view, atFraction: 0.15) + view.appearance = NSAppearance(named: names.vibrant) + let vibrant = try Self.color(of: view, atFraction: 0.15) + #expect(ThemeTestFixture.matches(plain, vibrant), "\(type(of: view)) drew \(vibrant), not \(plain)") + } + } + } + + @Test("On an opaque titlebar's vibrant strip a window theme leaves the track the system's own") + func vibrantStripKeepsTheSystemTrackUnderATheme() throws { + try ThemeTestFixture.adopting([.windowBackdrop: ThemeTestFixture.windowHex], appearance: .dark) { + let vibrant = try #require(NSAppearance(named: .vibrantDark)) + let plain = try #require(NSAppearance(named: .darkAqua)) + #expect(!EditorTabStripPalette.isOverThemedBackdrop(in: vibrant, highContrast: false)) + #expect( + EditorTabStripPalette.isOverThemedBackdrop(in: plain, highContrast: false) + == EditorTabStripPalette.followsWindowBackdrop + ) + } + } + @Test("The selected tab stays the system's own fill under a theme") func selectedTabStaysSystem() throws { try ThemeTestFixture.adopting([.windowBackdrop: ThemeTestFixture.windowHex], appearance: .dark) { diff --git a/apple/scripts/probes/check-fullscreen-titlebar-backstop.sh b/apple/scripts/probes/check-fullscreen-titlebar-backstop.sh new file mode 100755 index 0000000000..55a669dd20 --- /dev/null +++ b/apple/scripts/probes/check-fullscreen-titlebar-backstop.sh @@ -0,0 +1,158 @@ +#!/usr/bin/env bash +# +# Check why ContentWindow keeps its titlebar opaque in full screen, and why the editor tab strip resolves its +# fills in the non-vibrant appearance (#4498). +# +# In full screen the titlebar moves into NSToolbarFullScreenWindow. With a custom window backgroundColor and a +# transparent titlebar, AppKit hides the titlebar backgrounds and shows an opaque NSOpaqueBackstop layer under +# one titlebar section, the sidebar's when the split has an inspector item. The system color keeps it hidden, +# but handing it back at willEnterFullScreen comes too late. An opaque titlebar hides it, and gives the +# titlebar accessory a vibrant appearance. The window copies the main window: sidebar, content, collapsed +# inspector, unified toolbar and a bottom titlebar accessory. +# +# Usage: +# scripts/probes/check-fullscreen-titlebar-backstop.sh +# +# Opens a window, enters full screen for a few seconds per case and leaves it. Exits 0 when all four cases +# hold, 1 when one does not, and 3 when the check could not run. + +set -uo pipefail + +WORK="$(mktemp -d)" +trap 'rm -rf "$WORK"' EXIT + +cat > "$WORK/main.swift" <<'SWIFT' +import AppKit + +let transparent = CommandLine.arguments.contains("--transparent") +let customColor = CommandLine.arguments.contains("--custom-color") +let handsBack = CommandLine.arguments.contains("--hand-back") + +final class ToolbarDelegate: NSObject, NSToolbarDelegate { + let ids: [NSToolbarItem.Identifier] = [.toggleSidebar, .sidebarTrackingSeparator, .flexibleSpace] + func toolbarDefaultItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] { ids } + func toolbarAllowedItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] { ids } + func toolbar( + _ toolbar: NSToolbar, + itemForItemIdentifier id: NSToolbarItem.Identifier, + willBeInsertedIntoToolbar flag: Bool + ) -> NSToolbarItem? { NSToolbarItem(itemIdentifier: id) } +} + +final class Pane: NSViewController { + override func loadView() { view = NSView() } +} + +final class Accessory: NSTitlebarAccessoryViewController { + let marker = NSView(frame: NSRect(x: 0, y: 0, width: 10, height: 10)) + override func loadView() { + view = NSView(frame: NSRect(x: 0, y: 0, width: 1, height: 36)) + view.addSubview(marker) + } +} + +func backstopShown(in window: NSWindow) -> Bool? { + var found: Bool? + func walk(_ layer: CALayer) { + if layer.name == "NSOpaqueBackstop" { found = (found ?? false) || !layer.isHidden } + layer.sublayers?.forEach(walk) + } + if let root = window.contentView?.superview?.layer { walk(root) } + return found +} + +final class AppDelegate: NSObject, NSApplicationDelegate { + var window: NSWindow! + let toolbarDelegate = ToolbarDelegate() + let accessory = Accessory() + + func applicationDidFinishLaunching(_ notification: Notification) { + window = NSWindow( + contentRect: NSRect(x: 100, y: 100, width: 1000, height: 600), + styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView], + backing: .buffered, + defer: false + ) + window.toolbarStyle = .unified + window.collectionBehavior.insert([.fullScreenPrimary, .managed]) + let split = NSSplitViewController() + let sidebar = NSSplitViewItem(sidebarWithViewController: Pane()) + sidebar.minimumThickness = 300 + split.addSplitViewItem(sidebar) + split.addSplitViewItem(NSSplitViewItem(viewController: Pane())) + let inspector = NSSplitViewItem(inspectorWithViewController: Pane()) + inspector.canCollapse = true + inspector.isCollapsed = true + split.addSplitViewItem(inspector) + window.contentViewController = split + let toolbar = NSToolbar(identifier: "backstop-probe") + toolbar.delegate = toolbarDelegate + window.toolbar = toolbar + accessory.layoutAttribute = .bottom + accessory.automaticallyAdjustsSize = false + accessory.fullScreenMinHeight = 36 + window.addTitlebarAccessoryViewController(accessory) + window.titlebarAppearsTransparent = transparent + if customColor { window.backgroundColor = NSColor(srgbRed: 0.16, green: 0.17, blue: 0.2, alpha: 1) } + if handsBack { + NotificationCenter.default.addObserver( + forName: NSWindow.willEnterFullScreenNotification, object: window, queue: nil + ) { [weak self] _ in + MainActor.assumeIsolated { self?.window.backgroundColor = .windowBackgroundColor } + } + } + window.makeKeyAndOrderFront(nil) + NSApp.activate(ignoringOtherApps: true) + DispatchQueue.main.asyncAfter(deadline: .now() + 1) { self.window.toggleFullScreen(nil) } + DispatchQueue.main.asyncAfter(deadline: .now() + 4) { self.report() } + } + + func report() { + guard window.styleMask.contains(.fullScreen), + let bar = NSApp.windows.first(where: { "\(type(of: $0))" == "NSToolbarFullScreenWindow" }) + else { + print("UNAVAILABLE: the window did not enter full screen") + exit(3) + } + let vibrant = accessory.marker.effectiveAppearance.name.rawValue.contains("Vibrant") + switch backstopShown(in: bar) { + case nil: print("UNAVAILABLE: no NSOpaqueBackstop layer in the full-screen toolbar window") + case let shown?: print("\(shown ? "backstop shown" : "backstop hidden"), \(vibrant ? "vibrant" : "not vibrant")") + } + window.toggleFullScreen(nil) + DispatchQueue.main.asyncAfter(deadline: .now() + 2) { exit(0) } + } +} + +let app = NSApplication.shared +app.setActivationPolicy(.regular) +let delegate = AppDelegate() +app.delegate = delegate +app.run() +SWIFT + +if ! swiftc -O "$WORK/main.swift" -o "$WORK/probe" 2>"$WORK/build.log"; then + cat "$WORK/build.log" + echo "INCONCLUSIVE: the probe did not compile" + exit 3 +fi + +custom="$("$WORK/probe" --transparent --custom-color)" +system="$("$WORK/probe" --transparent)" +handed="$("$WORK/probe" --transparent --custom-color --hand-back)" +opaque="$("$WORK/probe" --custom-color)" +echo "transparent titlebar, custom color: $custom" +echo "transparent titlebar, system color: $system" +echo "transparent titlebar, color handed back late: $handed" +echo "opaque titlebar, custom color: $opaque" + +case "$custom$system$handed$opaque" in + *UNAVAILABLE*) echo "INCONCLUSIVE"; exit 3 ;; +esac +if [[ "$custom" == "backstop shown, not vibrant" && "$system" == "backstop hidden, not vibrant" \ + && "$handed" == "backstop shown, not vibrant" && "$opaque" == "backstop hidden, vibrant" ]]; then + echo "PASS: a transparent titlebar shows the backstop under a custom color, an opaque one never does" + exit 0 +fi +echo "FAIL: AppKit changed; recheck ContentWindow.titlebarIsTransparent and EditorTabStripPalette.drawing" +exit 1 From a0323085f25d5f9732120076c5190b1579acadbf Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Fri, 27 Nov 2026 19:01:40 +0700 Subject: [PATCH 2/2] chore: add the changelog fragment for #4635 --- apple/changelog.d/4635.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 apple/changelog.d/4635.fixed.md diff --git a/apple/changelog.d/4635.fixed.md b/apple/changelog.d/4635.fixed.md new file mode 100644 index 0000000000..6538a386ce --- /dev/null +++ b/apple/changelog.d/4635.fixed.md @@ -0,0 +1 @@ +In full screen, a theme with a window background covered the top of the sidebar with a dark or light block.