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.

Only the key window's hidden sidebar comes out on hover (#82) (#96)

Victor Kildahlfdd80a704320
diff --git a/Sources/Cra/UI/Windows/FloatingSidebar.swift b/Sources/Cra/UI/Windows/FloatingSidebar.swift
index 160211a..9f3a4d7 100644
--- a/Sources/Cra/UI/Windows/FloatingSidebar.swift
+++ b/Sources/Cra/UI/Windows/FloatingSidebar.swift
@@ -69,7 +69,7 @@ final class FloatingSidebarController {
let screenPoint = NSEvent.mouseLocation
let p = shell.convert(window.convertPoint(fromScreen: screenPoint), from: nil)
if !isShown {
- guard sidebarHidden(), FloatingSidebarGeometry.shouldReveal(at: p, in: shell.bounds, edgeToEdge: shell.edgeToEdge) else { return }
+ guard sidebarHidden(), isKey, FloatingSidebarGeometry.shouldReveal(at: p, in: shell.bounds, edgeToEdge: shell.edgeToEdge) else { return }
show()
} else if !staysShown(), FloatingSidebarGeometry.shouldHide(at: p, in: shell.bounds, sidebarWidth: shell.sidebarWidth,
pressedMouseButtons: NSEvent.pressedMouseButtons, edgeToEdge: shell.edgeToEdge) {
@@ -77,6 +77,18 @@ final class FloatingSidebarController {
}
}
+ /// The app's key window (nil while Cra is inactive); the tests stand one in.
+ var keyWindow: () -> NSWindow? = { NSApp.keyWindow }
+
+ /// Like Arc, only the key window's sidebar comes out on hover (GitHub #82): every window
+ /// polls the pointer, and one behind another would otherwise reveal over it. The key
+ /// window is often one of this window's own child windows (a page, DevTools, the panel).
+ var isKey: Bool {
+ var w = keyWindow()
+ while let c = w, c !== window { w = c.parent }
+ return w != nil
+ }
+
/// The sidebar's floating frame on screen, from the shell's layout.
private var targetFrame: NSRect {
let f = shell.frames(sidebarVisible: false, floating: true, fullscreen: false, width: shell.sidebarWidth).sidebar
diff --git a/Sources/Cra/UI/Windows/MainWindowController.swift b/Sources/Cra/UI/Windows/MainWindowController.swift
index 76860d6..3fd12c5 100644
--- a/Sources/Cra/UI/Windows/MainWindowController.swift
+++ b/Sources/Cra/UI/Windows/MainWindowController.swift
@@ -1473,7 +1473,7 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
private func setFloatingSidebar(_ show: Bool) {
guard let floatingSidebar else { return }
- if show { if !sidebarVisible { floatingSidebar.show() } } else { floatingSidebar.hide(animated: true) }
+ if show { if !sidebarVisible, floatingSidebar.isKey { floatingSidebar.show() } } else { floatingSidebar.hide(animated: true) }
}
private func installFloatingSidebar() {
diff --git a/Tests/FloatingSidebarTests.swift b/Tests/FloatingSidebarTests.swift
index 9d276c4..5566efb 100644
--- a/Tests/FloatingSidebarTests.swift
+++ b/Tests/FloatingSidebarTests.swift
@@ -81,6 +81,30 @@ enum FloatingSidebarTests {
drainAnimations()
expect(!sidebar.isShown && !shell.sidebarDetached && !shell.floatingSidebar,
"an uninterrupted hide still reattaches the sidebar normally")
+
+ // GitHub #82: like Arc, only the key window reveals, so a window behind another can't.
+ let page = NSWindow(contentRect: NSRect(x: -9990, y: -9990, width: 1380, height: 860),
+ styleMask: [.borderless], backing: .buffered, defer: false)
+ page.isReleasedWhenClosed = false
+ window.addChildWindow(page, ordered: .above)
+ let front = NSWindow(contentRect: window.frame, styleMask: [.borderless], backing: .buffered, defer: false)
+ front.isReleasedWhenClosed = false
+ var key: NSWindow? = window
+ sidebar.keyWindow = { key }
+ expect(sidebar.isKey, "the key window reveals")
+ key = page
+ expect(sidebar.isKey, "its page being key counts as the window")
+ sidebar.show()
+ key = panel
+ expect(sidebar.isKey, "its floating panel being key counts as the window")
+ sidebar.hide(animated: false)
+ key = front
+ expect(!sidebar.isKey, "a window behind the key window does not reveal")
+ key = nil
+ expect(!sidebar.isKey, "no key window (Cra inactive) does not reveal")
+ window.removeChildWindow(page)
+ page.close()
+ front.close()
window.close()
print("Floating sidebar: \(checks) checks passed")
}
diff --git a/docs/arc-reverse-engineering.md b/docs/arc-reverse-engineering.md
index 66da3b9..d8553f3 100644
--- a/docs/arc-reverse-engineering.md
+++ b/docs/arc-reverse-engineering.md
@@ -2063,3 +2063,18 @@ curves fitted per frame. "p" = Library reveal progress, 0 = space, 1 = Library o
mid-swipe flashed a system panel). The Spaces page follows Arc: sidebar = window − 56 pt, live on resize; cards scroll
sideways under two fingers (over card lists too) and Shift+wheel; a swipe that starts with the cards at their
end leaves the Library; the brush's theme editor sits flush with the card's right edge.
+
+## Hidden sidebar with two windows (Arc 1.171, 2 Nov 2026, issue #82, live Arc, HID pointer, window-id captures)
+
+Two new Arc windows, both with View ▸ Hide Sidebar and a tab selected, captured per window with
+`screencapture -l` (each window's own pixels, even where another window covers it).
+- [O] Stacked at the same frame, the pointer at the shared left edge: only the front (key) window's sidebar
+ comes out; the back window stays hidden and stays behind.
+- [O] The front window moved 400 pt right, so the back window's edge is uncovered and on top under the pointer:
+ the back (non-key) window does not reveal. The same motion at the key window's edge reveals it. So Arc
+ reveals only in the key window, not in whichever window is under the pointer.
+- [O] A pointer jump into the strip did not reveal; moving inside it did (a few points up or down). Cra
+ reveals on arrival.
+- [U] An inactive Arc (another app frontmost); hidden-sidebar windows of other apps over Arc's edge.
+- Cra: `FloatingSidebarController.isKey` gates both reveal paths (the 30 Hz poll and the shell's tracking
+ area): this window, or one of its child windows (page, DevTools, the floating panel), must be key.
diff --git a/docs/floating-sidebar-testing.md b/docs/floating-sidebar-testing.md
index 63b65f6..41d8bba 100644
--- a/docs/floating-sidebar-testing.md
+++ b/docs/floating-sidebar-testing.md
@@ -6,6 +6,7 @@ disposable AppKit panel, does not install the pointer poll, and does not post in
Checks cover the shared reveal strip (the 10 pt margin left of the page, plus 4 pt outside the window), window bounds, matching leave slack,
held-button retention outside those bounds and dismissal after release,
+only the key window (or one of its own child windows being key) revealing (GitHub #82),
re-entry during a hide animation, repeated reversals, anchoring while a hide is in
flight, and immediate dismissal while an animated hide is pending. The tests wait
for real AppKit animation completions; they do not establish physical hover behavior.
@@ -23,5 +24,8 @@ In an isolated CraDev profile, verify:
- While holding a mouse button for a window drag, tab reorder or context gesture,
move beyond those bounds. Automatic hover dismissal must wait until release;
explicit hide, toggle and window actions must still work.
+- Open a second window over the first, both with the sidebar hidden, and touch the front
+ window's left edge. Only the front (key) window's sidebar should come out. As in Arc, a
+ window that isn't key stays put even where its edge is uncovered (GitHub #82).
- Verify both compact and full toolbars. Page clicks outside the gutter and
full-screen page behavior should remain unchanged.