Skip to content

armgit / cra

Public Imported from GitHub
0

The open-source Arc replacement for macOS. Spaces, pinned tabs, split view, Little Windows and Arc's shortcuts on Chromium, with your Arc sidebar imported in one go.

Sidebar follows its window's active state like Arc's: no live blur while a window comes back from the Dock (#156)

Victor33891ddda016
diff --git a/Packages/CraCore/Sources/CraCore/SidebarBackdrop.swift b/Packages/CraCore/Sources/CraCore/SidebarBackdrop.swift
index ace92fa..8ad0172 100644
--- a/Packages/CraCore/Sources/CraCore/SidebarBackdrop.swift
+++ b/Packages/CraCore/Sources/CraCore/SidebarBackdrop.swift
@@ -70,6 +70,17 @@ public struct SidebarBackdrop: Equatable, Sendable {
liftBottom: full ? vibrant.liftBottom : vibrant.liftInactive)
}
+ /// Whether a window's sidebar draws its active look. It is AppKit's `followsWindowActiveState`, and so
+ /// Arc's sidebar: the app is active and the window holds key or main. Cra's page windows are children of
+ /// the window and take key while a page has focus, so they count as the window. Measured on
+ /// NSVisualEffectView (GitHub #156): minimizing goes inactive at once, while the app is still active,
+ /// and a restore from the Dock keeps the flat fill through the genie until the window is main again,
+ /// about 0.4 s after the app became active. Following the app instead asked for a live capture of a
+ /// window still flying out of the Dock, which showed matte or sharp frames as it landed.
+ public static func windowActive(appActive: Bool, miniaturized: Bool, holdsKeyOrMain: Bool) -> Bool {
+ appActive && !miniaturized && holdsKeyOrMain
+ }
+
/// The white lift over the floating sidebar's material (dark hudWindow), light themes. Under
/// Reduce transparency that material is its opaque dark fill, 38, which is Arc's floating panel
/// under the space colour (GitHub #156: 156/64/72 at #F25E6B 0.8), so the lift goes.
diff --git a/Packages/CraCore/Tests/CraCoreTests/SidebarBackdropTests.swift b/Packages/CraCore/Tests/CraCoreTests/SidebarBackdropTests.swift
index 3b0c57b..9ff26e1 100644
--- a/Packages/CraCore/Tests/CraCoreTests/SidebarBackdropTests.swift
+++ b/Packages/CraCore/Tests/CraCoreTests/SidebarBackdropTests.swift
@@ -54,6 +54,18 @@ struct SidebarBackdropTests {
#expect(SidebarBackdrop.floatingLift(dark: true, reduceTransparency: true, lift: 0.35) == 0.15)
}
+ /// AppKit's material follows its window, not the app (GitHub #156): a window restored from the Dock
+ /// is miniaturized and holds neither key nor main for the whole genie, although the app is active.
+ @Test func activeLookFollowsTheWindowLikeAppKit() {
+ #expect(SidebarBackdrop.windowActive(appActive: true, miniaturized: false, holdsKeyOrMain: true))
+ // Restore from the Dock: the app activates first, the window becomes main at the end.
+ #expect(!SidebarBackdrop.windowActive(appActive: true, miniaturized: true, holdsKeyOrMain: false))
+ // Minimized while the app stays active, or another window of the app in front.
+ #expect(!SidebarBackdrop.windowActive(appActive: true, miniaturized: false, holdsKeyOrMain: false))
+ // Another app in front: the window stays main but the app isn't active.
+ #expect(!SidebarBackdrop.windowActive(appActive: false, miniaturized: false, holdsKeyOrMain: true))
+ }
+
@Test func logLineNamesTheState() {
#expect(resolve(solid: true).logLine(active: true, reduceTransparency: false) == "blur, active, dim 0.30")
#expect(resolve(solid: true, fullscreen: true).logLine(active: true, reduceTransparency: false) == "desktop tint, active, dim 0.30")
diff --git a/Sources/Cra/UI/Windows/MainWindowController.swift b/Sources/Cra/UI/Windows/MainWindowController.swift
index b04f69b..45d99f6 100644
--- a/Sources/Cra/UI/Windows/MainWindowController.swift
+++ b/Sources/Cra/UI/Windows/MainWindowController.swift
@@ -192,11 +192,42 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
shell.onPaneFrames = { [weak self] frames in self?.positionPageWindows(frames) }
shell.onAnimatePaneFrames = { [weak self] frames, d, timing in self?.animatePageWindows(to: frames, duration: d, timing: timing) }
NotificationCenter.default.addObserver(forName: NSApplication.didBecomeActiveNotification, object: nil, queue: .main) { [weak self] _ in
- Task { @MainActor in self?.shell.windowActive = true; self?.sidebarUI.appActive = true }
+ Task { @MainActor in self?.refreshMaterialActive(); self?.sidebarUI.appActive = true }
}
NotificationCenter.default.addObserver(forName: NSApplication.didResignActiveNotification, object: nil, queue: .main) { [weak self] _ in
- Task { @MainActor in self?.shell.windowActive = false; self?.sidebarUI.appActive = false }
+ Task { @MainActor in self?.refreshMaterialActive(); self?.sidebarUI.appActive = false }
}
+ // Any window: key and main move between this window, its page windows and other windows.
+ for name in [NSWindow.didBecomeKeyNotification, NSWindow.didResignKeyNotification, NSWindow.didBecomeMainNotification,
+ NSWindow.didResignMainNotification, NSWindow.didMiniaturizeNotification, NSWindow.didDeminiaturizeNotification] {
+ NotificationCenter.default.addObserver(forName: name, object: nil, queue: .main) { [weak self] _ in
+ MainActor.assumeIsolated { self?.refreshMaterialActive() }
+ }
+ }
+ }
+
+ /// The sidebar's material follows this window's active state, as AppKit's does for Arc's sidebar
+ /// (SidebarBackdrop.windowActive, GitHub #156). Going inactive waits one turn of the run loop: key
+ /// moving between this window and one of its page windows resigns one before the other takes it,
+ /// and the sidebar must not flash its flat fill in between.
+ private func refreshMaterialActive() {
+ if materialActiveNow() { shell.windowActive = true; return }
+ guard shell.windowActive else { return }
+ DispatchQueue.main.async { [weak self] in
+ guard let self, !self.materialActiveNow() else { return }
+ self.shell.windowActive = false
+ }
+ }
+
+ private func materialActiveNow() -> Bool {
+ guard let window, !isTornDown else { return false }
+ func holds(_ w: NSWindow?) -> Bool {
+ var w = w
+ while let x = w { if x === window { return true }; w = x.parent }
+ return false
+ }
+ return SidebarBackdrop.windowActive(appActive: NSApp.isActive, miniaturized: window.isMiniaturized,
+ holdsKeyOrMain: holds(NSApp.keyWindow) || holds(NSApp.mainWindow))
}
required init?(coder: NSCoder) { fatalError() }
@@ -2709,7 +2740,7 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
func windowDidBecomeKey(_ notification: Notification) {
guard (notification.object as? NSWindow) === window else { return }
- shell.windowActive = true
+ refreshMaterialActive()
browsers.windowVisibilityChanged(covered: false)
reclaimPages()
}
diff --git a/docs/arc-reverse-engineering.md b/docs/arc-reverse-engineering.md
index 4dc0678..b9bb237 100644
--- a/docs/arc-reverse-engineering.md
+++ b/docs/arc-reverse-engineering.md
@@ -2189,6 +2189,22 @@ Theme palettes in a hand-built space can be borrowed; only the `background` styl
capture at all, solid themes rest at dim 1, lift 0.63 active or inactive (Arc's value doesn't move when its
fullscreen swipe lands, Cra's stepped from the inactive 212), light vibrant themes at their inactive look, and the floating sidebar drops its white lift so the
dark material's fill shows under the colour like Arc's panel (Cra pinned − floating 45/46/45, Arc 54/46/45); cra.log adds ", reduce transparency" and the diagnostics export names the setting.
+- [O] Activation and fullscreen with Reduce transparency off (4 Nov 2026, issue #156 on 0.1.29; built-in XDR display,
+ 120 fps ScreenCaptureKit samples; a probe window with a hudWindow NSVisualEffectView beside a copy of ShellView's
+ backdrop logic, logging both layer trees every 4 ms; an offline Arc 1.171; a Cra test copy with a solid #F25E6B 0.8
+ space). AppKit's material follows its window, not the app: minimizing goes flat as the window resigns main/key, while
+ the app is still active, and a restore from the Dock while another app is active keeps the opaque fill through the
+ genie until the window is main again, 0.41 s after `didBecomeActive`. Cra followed the app, so it re-inserted the live
+ capture at activation, 0.43 s before the window had landed. That's a capture of a window still flying out of the Dock:
+ the reporter's matte (substitute colour) or sharp frames on restore. Cra now uses `SidebarBackdrop.windowActive`: app
+ active, not miniaturized, and the key or main window is this window or one of its child windows (page, DevTools).
+ Measured after the change: Dock restore active at +0.46 s (before: +0.03 s), minimize flat at once, plain activations
+ unchanged (one step at +0.03 s), the command bar's panel keeps the sidebar active. Not reproduced here: a dropout on
+ a plain activation (Arc, AppKit and Cra all switch in one frame, no matte or sharp frame). Fullscreen: AppKit swaps the
+ capture for the desktop tint at `willEnterFullScreen`, the same frame as Cra; Arc's sidebar jumps at the start of the
+ zoom (16/12/31 → 41/33/50 on its default theme) and steps ~2 levels when the Space settles (45/30/43 → 43/30/45), and
+ Cra does the same (189/112/120 → 216/133/137 at the start, 220/124/123 → 218/124/126 at the end), so no fullscreen
+ difference against Arc reproduced on this Mac.
- [O] Tab list scroller: AppKit overlay scroller (AXScrollBar, 17 pt track) shown while scrolling, then faded;
the knob is 4 pt wide, 3 pt in from the sidebar edge, white 49 % on a dark theme, no track. Cra:
`SidebarScroller`, 10 pt wide so it stays in the gutter right of the rows (knob on Arc's exact columns).