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.

Little Window opens over a full-screen app, as Little Arc does (#186)

Victorca6877c28858
diff --git a/Sources/Cra/App/AppDelegate.swift b/Sources/Cra/App/AppDelegate.swift
index 3553960..c67d0c8 100644
--- a/Sources/Cra/App/AppDelegate.swift
+++ b/Sources/Cra/App/AppDelegate.swift
@@ -492,7 +492,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
@discardableResult
func openLittleWindow(url: String, activate: Bool = true, opener: CraBrowser? = nil, space: UUID? = nil) -> LittleWindowController {
let w = makeLittleWindow(url: url, opener: opener, space: space)
- if activate { w.show() } else { w.window?.orderFront(nil) }
+ if activate { w.show() } else { w.orderFrontInBackground() }
return w
}
@@ -538,8 +538,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
let comps = URLComponents(url: u, resolvingAgainstBaseURL: false)
func q(_ name: String) -> String? { comps?.queryItems?.first { $0.name == name }?.value }
// Actions keep their target: a key Little Window stays key (perform routes to it).
- // A background test instance (CRA_TEST_BACKGROUND) never comes to the front.
- if (u.host != "action" || keyLittleWindow == nil) && !HitchMonitor.background {
+ // A background test instance (CRA_TEST_BACKGROUND) never comes to the front. A Little
+ // Window opens on the Space in use, so the browser window stays where it is (#186).
+ let little = u.host == "open" && q("little") == "1"
+ if (u.host != "action" || keyLittleWindow == nil) && !little && !HitchMonitor.background {
main.showWindow(nil)
NSApp.activate(ignoringOtherApps: true)
}
@@ -559,7 +561,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
// space=<id> (#168): a real, normal space, as Air Traffic Control routes to; an unknown
// or incognito one opens where it did before, in the space in use.
let space = q("space").flatMap(UUID.init(uuidString:)).flatMap { store.space($0) != nil && !store.isIncognito(space: $0) ? $0 : nil }
- if q("little") == "1" {
+ if little {
openLittleWindow(url: url, space: space)
} else if let space {
// Held: useNormalWindow(forSpace:) can change which window is main.
diff --git a/Sources/Cra/UI/Windows/LittleWindowController.swift b/Sources/Cra/UI/Windows/LittleWindowController.swift
index 68b69fb..2356928 100644
--- a/Sources/Cra/UI/Windows/LittleWindowController.swift
+++ b/Sources/Cra/UI/Windows/LittleWindowController.swift
@@ -183,7 +183,7 @@ final class LittleWindowController: NSWindowController, NSWindowDelegate, @preco
?? LittleMetrics.defaultSize
let window = LittleWindow(contentRect: NSRect(origin: .zero, size: size),
styleMask: parent != nil ? [.borderless]
- : [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
+ : [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView, .nonactivatingPanel],
backing: .buffered, defer: false)
shell = LittleShellView(frame: window.contentView!.bounds)
super.init(window: window)
@@ -230,6 +230,11 @@ final class LittleWindowController: NSWindowController, NSWindowDelegate, @preco
window.standardWindowButton(.miniaturizeButton)?.isHidden = true
window.standardWindowButton(.zoomButton)?.isHidden = true
} else {
+ // Little Arc is a non-activating panel (AX subrole AXSystemDialog), so it opens over
+ // the app in front even when that app is full screen (#186). An ordinary window can't
+ // join another app's full-screen Space: macOS switched to the desktop to show it.
+ // Primary keeps the page's own full screen.
+ window.collectionBehavior = [.fullScreenPrimary, .fullScreenAuxiliary]
placeWindow()
}
@@ -311,6 +316,7 @@ final class LittleWindowController: NSWindowController, NSWindowDelegate, @preco
window.addChildWindow(w, ordered: .above)
positionHostWindow(shell.convert(shell.page.frame, to: nil))
w.orderFront(nil)
+ rejoinPage()
// The command bar and the spaces popup stay above the page window.
if commandPanel.parent === window { window.removeChildWindow(commandPanel); window.addChildWindow(commandPanel, ordered: .above) }
}
@@ -337,6 +343,26 @@ final class LittleWindowController: NSWindowController, NSWindowDelegate, @preco
b.setFocused(true)
}
+ /// Shows the window without making it key (a link opened in the background).
+ func orderFrontInBackground() {
+ window?.orderFront(nil)
+ rejoinPage()
+ }
+
+ /// The page window is an ordinary window, which can't join another app's full-screen
+ /// Space: shown before this window, or by Chromium before it hands it over, it lands on the
+ /// desktop, and making it key switched Spaces (#186). Ordered in again as this window's
+ /// child, it joins this window's Space.
+ private func rejoinPage() {
+ guard let window, window.isVisible, window.isOnActiveSpace,
+ let host = browser?.hostWindow, host.parent === window, !host.isOnActiveSpace else { return }
+ window.removeChildWindow(host)
+ host.orderOut(nil)
+ window.addChildWindow(host, ordered: .above)
+ host.orderFront(nil)
+ if commandPanel.parent === window { window.removeChildWindow(commandPanel); window.addChildWindow(commandPanel, ordered: .above) }
+ }
+
/// Where the window lands: centred on the screen under the pointer, cascaded
/// off other little windows.
private func placeWindow() {
@@ -370,6 +396,7 @@ final class LittleWindowController: NSWindowController, NSWindowDelegate, @preco
if let host, host.parent === window { host.alphaValue = 0 } // orderOut would detach the child
window.setFrame(start, display: false)
window.makeKeyAndOrderFront(nil)
+ rejoinPage()
NSApp.activate(ignoringOtherApps: true)
// NSWindow frame animation (animationResizeTime is overridden to 120 ms).
window.setFrame(final, display: true, animate: true)
@@ -1210,7 +1237,9 @@ final class LittleShellView: NSView {
/// Traffic lights at Arc's spots (x 17/39/61, centred on the strip), always in
/// colour like the main window.
-final class LittleWindow: NSWindow {
+/// A panel like Little Arc's, so it can open on another app's full-screen Space (#186), that
+/// otherwise acts as the window it was: main when titled, Escape left to the page and the app.
+final class LittleWindow: NSPanel {
/// Window buttons stay coloured while inactive (see CraWindow).
@objc(_hasActiveAppearanceForStandardWindowButton:)
func hasActiveAppearance(forStandardWindowButton type: UInt) -> Bool { true }
@@ -1218,6 +1247,21 @@ final class LittleWindow: NSWindow {
override func animationResizeTime(_ newFrame: NSRect) -> TimeInterval { LittleMetrics.openDuration }
/// A Peek is borderless (Arc's card has no title bar) but still takes the keyboard.
override var canBecomeKey: Bool { true }
+ /// A panel never becomes main; a titled window did, and the browser window's active look
+ /// and the page's hover state follow the main window.
+ override var canBecomeMain: Bool { styleMask.contains(.titled) }
+ /// NSPanel closes itself on Escape; a window passes it on.
+ override func cancelOperation(_ sender: Any?) {
+ nextResponder?.tryToPerform(#selector(cancelOperation(_:)), with: sender)
+ }
+ /// A non-activating panel takes clicks without bringing Cra forward; a window brings it.
+ override func sendEvent(_ event: NSEvent) {
+ if styleMask.contains(.nonactivatingPanel), !NSApp.isActive,
+ [.leftMouseDown, .rightMouseDown, .otherMouseDown].contains(event.type) {
+ NSApp.activate(ignoringOtherApps: true)
+ }
+ super.sendEvent(event)
+ }
/// macOS's corner radius for this window (16 pt on macOS 26, larger than Arc's
/// 10), read from the frame view's private `_cornerRadius`.
diff --git a/docs/arc-reverse-engineering.md b/docs/arc-reverse-engineering.md
index 4208f51..a249e39 100644
--- a/docs/arc-reverse-engineering.md
+++ b/docs/arc-reverse-engineering.md
@@ -3120,3 +3120,21 @@ Arc Max's renameDownloads: a finished download is renamed on disk and a card abo
- Cra: TidyDownloads (CraCore: prompt with Cra's own examples, the name's checks, a free name), TidyDownloadsService
(FoundationModels, renames the file, DownloadHistory.move, revert), DownloadRenameCard (SidebarView, over the bin).
Settings ▸ Max ▸ Tidy Downloads, off by default.
+
+## Little Arc over a full-screen app (Arc 1.171, 5 Nov 2026, issue #186, Victor's Arc + a test full-screen app)
+
+- [O] With another app full screen on its own Space, `open -a Arc https://example.com/…` (a link from another app)
+ opened Little Arc on that full-screen Space (CGSCopySpacesForWindows: the full-screen Space, type 4), and the
+ active Space stayed there. Cra 0.1.30 switched to the desktop Space (type 0) and opened the Little Window there.
+- [O AX] Little Arc's AX subrole is `AXSystemDialog` at window level 0, with no window buttons among its AX
+ children (an `AXCloseButton` attribute is still there). In AppKit only a titled `NSPanel` with
+ `.nonactivatingPanel` reports that subrole (NSWindow: AXStandardWindow; NSPanel: AXDialog; utility panel:
+ AXFloatingWindow; borderless: AXUnknown).
+- [O, stand-in app] Why it matters: an ordinary window can't join another app's full-screen Space. With `.fullScreenAuxiliary`,
+ `.moveToActiveSpace`, `.canJoinAllApplications` (macOS 13) or no activation at all, a stand-in app's new window
+ still landed on the desktop. A titled non-activating `NSPanel` with `.fullScreenAuxiliary` lands on the full-screen
+ Space, and `NSApp.activate` afterwards doesn't switch Spaces. With `.fullScreenPrimary` added it still enters
+ its own full screen (page video).
+- [O, Cra test copy] Child windows: a child ordered in before its parent is on screen, or shown by its owner before it was
+ attached (Chromium's page window), stays on the desktop Space. Making it key then switches Spaces. Ordering it
+ out and adding it again as a child, after the parent is on screen, puts it on the parent's Space.