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.

Cra 0.1.22: edge-to-edge pages, Arc's refresh button, DevTools in every split pane

Victor68108cea7a2f
diff --git a/Sources/Cra/Model/SidebarModel.swift b/Sources/Cra/Model/SidebarModel.swift
index 3acf609..8fad12f 100644
--- a/Sources/Cra/Model/SidebarModel.swift
+++ b/Sources/Cra/Model/SidebarModel.swift
@@ -463,6 +463,9 @@ struct AppSettings: Codable, Equatable {
/// Arc's showSpaceHeaderOnSingleUnnamedSpaces: with only one space, its header (and the
/// dock's lone space icon) can be hidden, for people who don't use spaces.
var showSpaceHeaderOnSingleSpace: Bool = true
+ /// GitHub #24, not in Arc: the page fills the window with no margin and no rounded
+ /// card, like a traditional browser. Off by default.
+ var edgeToEdgeContent: Bool = false
init() {}
@@ -568,6 +571,7 @@ extension AppSettings {
httpsOnly = try c.decodeIfPresent(Bool.self, forKey: .httpsOnly) ?? false
searchSuggestions = try c.decodeIfPresent(Bool.self, forKey: .searchSuggestions) ?? true
showSpaceHeaderOnSingleSpace = try c.decodeIfPresent(Bool.self, forKey: .showSpaceHeaderOnSingleSpace) ?? true
+ edgeToEdgeContent = try c.decodeIfPresent(Bool.self, forKey: .edgeToEdgeContent) ?? false
}
}
diff --git a/Sources/Cra/Services/BrowserManager.swift b/Sources/Cra/Services/BrowserManager.swift
index b6a3f86..9c698f7 100644
--- a/Sources/Cra/Services/BrowserManager.swift
+++ b/Sources/Cra/Services/BrowserManager.swift
@@ -589,6 +589,18 @@ final class BrowserManager: NSObject, @preconcurrency CraBrowserDelegate {
/// CEF's window for the visible tab's DevTools, if any.
var visibleDevToolsWindow: NSWindow? { visibleTabID.flatMap { devToolsViews[$0]?.window } }
+ /// DevTools windows on screen, by tab: every pane's Chrome-style frontend (it docks
+ /// inside its own pane), and an Alloy frontend only for the focused tab (the shell
+ /// has one dock).
+ var visibleDevToolsWindows: [UUID: NSWindow] {
+ var out: [UUID: NSWindow] = [:]
+ for id in visibleTabIDs {
+ guard let w = devToolsViews[id]?.window else { continue }
+ if id == visibleTabID || runtimes[id]?.hostWindow != nil { out[id] = w }
+ }
+ return out
+ }
+
private func syncDevToolsVisibility() {
delegate?.browserManagerDevToolsChanged()
}
diff --git a/Sources/Cra/Services/Import/Importers.swift b/Sources/Cra/Services/Import/Importers.swift
index 4772a97..421822e 100644
--- a/Sources/Cra/Services/Import/Importers.swift
+++ b/Sources/Cra/Services/Import/Importers.swift
@@ -431,12 +431,14 @@ enum DiaImporter {
// MARK: - Applying
extension SidebarStore {
- struct ImportResult { var spaces = 0; var tabs = 0; var folders = 0; var archived = 0 }
+ struct ImportResult { var spaces = 0; var tabs = 0; var folders = 0; var archived = 0; var spaceIDs: [UUID] = [] }
- /// Merge a plan into the sidebar. Spaces with the same title merge; favorites
- /// and pinned tabs skip URLs that already exist in that section.
+ /// Add a plan to the sidebar. Like Dia, every imported space is a new one (importing
+ /// twice gives two of each), so people pick what to keep; a taken title gets a number
+ /// ("JYSK 2"). Favorites on the current space skip URLs it already has. `replacing`
+ /// spaces (a fresh install's empty one) are deleted afterwards and don't take titles.
@discardableResult
- func apply(_ plan: ImportPlan, includeArchive: Bool, includeSettings: Bool) -> ImportResult {
+ func apply(_ plan: ImportPlan, includeArchive: Bool, includeSettings: Bool, replacing: [UUID] = []) -> ImportResult {
var result = ImportResult()
// A pinned tab that has navigated still counts as present via its home URL.
@@ -488,26 +490,36 @@ extension SidebarStore {
let current = focusedSpace.favoritesContainerID
insert(plan.favorites, into: current, skip: existingURLs(under: current), pinned: true)
+ // Archive entries and link routes name spaces by title: point them at this import's spaces.
+ var imported: [String: UUID] = [:]
+ func spaceID(titled title: String) -> UUID? {
+ imported[title.lowercased()] ?? orderedSpaces.first { $0.title.caseInsensitiveCompare(title) == .orderedSame }?.id
+ }
+ func freeTitle(_ title: String) -> String {
+ let taken = Set(orderedSpaces.filter { !replacing.contains($0.id) }.map { $0.title.lowercased() })
+ guard taken.contains(title.lowercased()) else { return title }
+ var n = 2
+ while taken.contains("\(title) \(n)".lowercased()) { n += 1 }
+ return "\(title) \(n)"
+ }
+
for sp in plan.spaces {
- let space: Space
- if var existing = orderedSpaces.first(where: { $0.title.caseInsensitiveCompare(sp.title) == .orderedSame }) {
- if let t = sp.theme, existing.theme != t { existing.theme = t; updateSpace(existing) }
- space = existing
- } else {
- space = createSpace(title: sp.title, emoji: sp.emoji, theme: sp.theme, focus: false)
- result.spaces += 1
- }
+ let space = createSpace(title: freeTitle(sp.title), emoji: sp.emoji, theme: sp.theme, focus: false)
+ result.spaces += 1
+ result.spaceIDs.append(space.id)
+ if imported[sp.title.lowercased()] == nil { imported[sp.title.lowercased()] = space.id }
insert(sp.favorites, into: space.favoritesContainerID, skip: existingURLs(under: space.favoritesContainerID), pinned: true)
insert(sp.pinned, into: space.pinnedContainerID, skip: existingURLs(under: space.pinnedContainerID), pinned: true)
insert(sp.today, into: space.todayContainerID, skip: existingURLs(under: space.todayContainerID), pinned: false)
}
+ for id in replacing { deleteSpace(id) }
if includeArchive {
let known = Set(archive.compactMap { $0.item.tab?.url })
for e in plan.archive where !known.contains(e.url) {
var item = SidebarItem.tab(e.url, title: e.pageTitle, parent: nil)
item.title = e.customTitle
- let sid = orderedSpaces.first { $0.title == e.spaceTitle }?.id
+ let sid = e.spaceTitle.flatMap(spaceID(titled:))
appendArchived(ArchivedItem(archivedAt: e.archivedAt, reason: e.reason, sourceSpaceID: sid, wasPinned: false, item: item))
result.archived += 1
}
@@ -523,7 +535,7 @@ extension SidebarStore {
case .mostRecentSpace: return .mostRecentSpace
case .littleWindow: return .littleWindow
case .space(let title):
- return orderedSpaces.first { $0.title.caseInsensitiveCompare(title) == .orderedSame }.map { .space($0.id) } ?? .mostRecentSpace
+ return spaceID(titled: title).map { .space($0) } ?? .mostRecentSpace
}
}
if let d = plan.settings.defaultLinkDestination { settings.defaultLinkDestination = destination(d) }
diff --git a/Sources/Cra/UI/Onboarding/ImportFlow.swift b/Sources/Cra/UI/Onboarding/ImportFlow.swift
index 518cbff..6dee06a 100644
--- a/Sources/Cra/UI/Onboarding/ImportFlow.swift
+++ b/Sources/Cra/UI/Onboarding/ImportFlow.swift
@@ -436,12 +436,9 @@ final class ImportFlowModel {
let emptyBefore = firstRun && !selection.spaces.isEmpty
? store.orderedSpaces.filter { store.tabs(under: $0.pinnedContainerID).isEmpty && store.tabs(under: $0.todayContainerID).isEmpty }
: []
- let result = store.apply(selection, includeArchive: includeArchive, includeSettings: includeSettings)
- let importedTitles = Set(selection.spaces.map { $0.title.lowercased() })
- for space in emptyBefore where !importedTitles.contains(space.title.lowercased()) { store.deleteSpace(space.id) }
- importedSpaceID = selection.spaces.first.flatMap { first in
- store.orderedSpaces.first { $0.title.caseInsensitiveCompare(first.title) == .orderedSame }?.id
- }
+ let result = store.apply(selection, includeArchive: includeArchive, includeSettings: includeSettings,
+ replacing: emptyBefore.map(\.id))
+ importedSpaceID = result.spaceIDs.first
favicons.reset()
let creds = credentials
Task { @MainActor in
@@ -462,7 +459,7 @@ final class ImportFlowModel {
try? await Task.sleep(nanoseconds: 420_000_000)
categories[i].state = credentialsStaged ? .done : .failed
default:
- if categories[i].id == "spaces" { categories[i].detail = count(selection.spaces.count, "space") + (result.spaces < selection.spaces.count ? " (\(result.spaces) new)" : "") }
+ if categories[i].id == "spaces" { categories[i].detail = count(result.spaces, "space") }
if categories[i].id == "tabs" { categories[i].detail = count(result.tabs, "new tab") }
try? await Task.sleep(nanoseconds: 420_000_000)
categories[i].state = .done
diff --git a/Sources/Cra/UI/PaneToolbarView.swift b/Sources/Cra/UI/PaneToolbarView.swift
index e2dfa28..378f614 100644
--- a/Sources/Cra/UI/PaneToolbarView.swift
+++ b/Sources/Cra/UI/PaneToolbarView.swift
@@ -163,9 +163,10 @@ final class PaneToolbarView: NSView {
}
private func glyph(_ key: String, _ symbol: String, help: String, enabled: Bool = true, width: CGFloat = 26, iconSize: CGFloat = 13,
- tint: NSColor? = nil, action: @escaping (PaneToolbarView) -> Void) -> ToolbarGlyphButton {
+ tint: NSColor? = nil, animated: Bool = false, action: @escaping (PaneToolbarView) -> Void) -> ToolbarGlyphButton {
let b = button(key) { ToolbarGlyphButton() }
- b.configure(symbol: symbol, image: nil, help: help, enabled: enabled, width: width, iconSize: iconSize, tint: tint ?? model.fgDim)
+ b.configure(symbol: symbol, image: nil, help: help, enabled: enabled, width: width, iconSize: iconSize, tint: tint ?? model.fgDim,
+ animated: animated)
b.action = { [weak self] in if let self { action(self) } }
return b
}
@@ -195,7 +196,8 @@ final class PaneToolbarView: NSView {
l.append(glyph("back", "arrow.left", help: "Go Back (⌘[)", enabled: m.canGoBack, width: 37, iconSize: 15) { $0.navigate("goBack") })
l.append(glyph("forward", "arrow.right", help: "Go Forward (⌘])", enabled: m.canGoForward, width: 37, iconSize: 15) { $0.navigate("goForward") })
if !m.inSplit {
- l.append(glyph("reload", m.isLoading ? "xmark" : "arrow.clockwise", help: "Refresh (⌘R)", width: 37, iconSize: 15) { $0.navigate("reload") })
+ l.append(glyph("reload", m.isLoading ? "xmark" : "arrow.clockwise", help: "Refresh (⌘R)", width: 37, iconSize: 15,
+ animated: true) { $0.navigate("reload") })
}
case .developer:
if !m.inSplit { l.append(toggle()) }
@@ -378,6 +380,8 @@ final class ToolbarGlyphButton: NSView {
private var tip: ArcTooltipAnchorView?
private var enabled = true
private var contextClick = false
+ /// Arc turns the refresh arrow while it is pressed (NSImageView.pressTurn).
+ private var turnsOnPress = false
private var hovering = false { didSet { if hovering != oldValue { refreshFill() } } }
private var shown: (String?, NSImage?, CGFloat, NSColor, Bool)?
@@ -392,14 +396,19 @@ final class ToolbarGlyphButton: NSView {
required init?(coder: NSCoder) { fatalError() }
- func configure(symbol: String?, image: NSImage?, help: String, enabled: Bool, width: CGFloat, iconSize: CGFloat, tint: NSColor) {
+ /// `animated` swaps another symbol in the way Arc swaps refresh and stop.
+ func configure(symbol: String?, image: NSImage?, help: String, enabled: Bool, width: CGFloat, iconSize: CGFloat, tint: NSColor,
+ animated: Bool = false) {
self.width = width
self.enabled = enabled
if shown == nil || shown!.0 != symbol || shown!.1 !== image || shown!.2 != iconSize || shown!.3 != tint || shown!.4 != enabled {
+ let was = shown?.0
shown = (symbol, image, iconSize, tint, enabled)
if let symbol {
imageView.imageScaling = .scaleNone
- imageView.image = SidebarSymbols.image(symbol, size: iconSize)
+ let glyph = SidebarSymbols.image(symbol, size: iconSize)
+ if animated, was != nil, was != symbol { imageView.swapSymbol(glyph) } else { imageView.image = glyph }
+ turnsOnPress = animated && symbol == "arrow.clockwise"
imageView.contentTintColor = enabled ? tint : tint.withAlphaComponent(tint.alphaComponent * 0.4)
} else {
imageView.imageScaling = .scaleProportionallyUpOrDown
@@ -439,8 +448,13 @@ final class ToolbarGlyphButton: NSView {
override func mouseDown(with event: NSEvent) {
contextClick = event.modifierFlags.contains(.control) && menuProvider != nil
if contextClick, let menu = menuProvider?() { NSMenu.popUpContextMenu(menu, with: event, for: self) }
+ if !contextClick, turnsOnPress, enabled { imageView.pressTurn(true) }
+ }
+ override func mouseDragged(with event: NSEvent) {
+ if !contextClick, turnsOnPress, enabled { imageView.pressTurn(bounds.contains(convert(event.locationInWindow, from: nil))) }
}
override func mouseUp(with event: NSEvent) {
+ if turnsOnPress { imageView.pressTurn(false) }
if !contextClick, enabled, bounds.contains(convert(event.locationInWindow, from: nil)) { action() }
}
override func menu(for event: NSEvent) -> NSMenu? { menuProvider?() }
diff --git a/Sources/Cra/UI/Settings/SettingsKit.swift b/Sources/Cra/UI/Settings/SettingsKit.swift
index 300e449..5ef30dc 100644
--- a/Sources/Cra/UI/Settings/SettingsKit.swift
+++ b/Sources/Cra/UI/Settings/SettingsKit.swift
@@ -110,12 +110,19 @@ struct SettingsCardPane<Content: View>: View {
}
/// Form-style pane body (Dia's Tabs and Advanced): right-aligned labels, left-aligned controls.
+/// Scrolls like the card panes: the window has a fixed height, and without a scroll view a
+/// form taller than it squeezed its rows on top of each other.
struct SettingsFormPane<Content: View>: View {
@ViewBuilder let content: Content
var body: some View {
- VStack(alignment: .leading, spacing: SettingsMetrics.formGroupSpacing) { content }
- .padding(.top, SettingsMetrics.formTop)
- .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
+ ScrollView(.vertical) {
+ VStack(alignment: .leading, spacing: SettingsMetrics.formGroupSpacing) { content }
+ .padding(.top, SettingsMetrics.formTop)
+ .padding(.trailing, SettingsMetrics.paneInset)
+ .padding(.bottom, SettingsMetrics.paneInset)
+ .frame(maxWidth: .infinity, alignment: .topLeading)
+ }
+ .scrollIndicators(.automatic)
}
}
@@ -143,5 +150,6 @@ struct SettingsCheckbox: View {
@Binding var isOn: Bool
var body: some View {
Toggle(title, isOn: $isOn).toggleStyle(.checkbox).font(.system(size: 13))
+ .fixedSize(horizontal: false, vertical: true) // long titles wrap instead of truncating
}
}
diff --git a/Sources/Cra/UI/Settings/TabsPane.swift b/Sources/Cra/UI/Settings/TabsPane.swift
index b0ef53f..fb7b5c8 100644
--- a/Sources/Cra/UI/Settings/TabsPane.swift
+++ b/Sources/Cra/UI/Settings/TabsPane.swift
@@ -14,6 +14,7 @@ struct TabsPane: View {
SettingsCheckbox(title: "Show the New Tab button above tabs", isOn: $store.settings.newTabButtonAtTop)
SettingsCheckbox(title: "Haptic feedback when reordering tabs", isOn: $store.settings.hapticFeedbackOnReorder)
SettingsCheckbox(title: "Show toolbar above the page", isOn: $store.settings.showToolbar)
+ SettingsCheckbox(title: "Pages fill the window edge to edge", isOn: $store.settings.edgeToEdgeContent)
SettingsCheckbox(title: "Enable Picture in Picture when you leave a video tab", isOn: $store.settings.autoPictureInPicture)
}
// Arc's single-space mode ("Hide Space Header" on the space's menu), for people who
diff --git a/Sources/Cra/UI/ShellView.swift b/Sources/Cra/UI/ShellView.swift
index f231e51..423df6d 100644
--- a/Sources/Cra/UI/ShellView.swift
+++ b/Sources/Cra/UI/ShellView.swift
@@ -92,6 +92,8 @@ final class ShellView: NSView {
var sidebarVisible = true { didSet { needsLayout = true } }
var floatingSidebar = false { didSet { needsLayout = true } }
var contentFullscreen = false { didSet { needsLayout = true } }
+ /// Settings ▸ "Pages fill the window edge to edge" (GitHub #24): no margin, square cards.
+ var edgeToEdge = false { didSet { needsLayout = true } }
var showToolbar = true { didSet { needsLayout = true } }
var hasTab = false { didSet { needsLayout = true } }
var onEdgeHover: ((Bool) -> Void)?
@@ -422,10 +424,10 @@ final class ShellView: NSView {
super.mouseMoved(with: event)
let p = convert(event.locationInWindow, from: nil)
guard !sidebarVisible, !contentFullscreen else { return }
- if !floatingSidebar, FloatingSidebarGeometry.shouldReveal(at: p, in: bounds) {
+ if !floatingSidebar, FloatingSidebarGeometry.shouldReveal(at: p, in: bounds, edgeToEdge: edgeToEdge) {
onEdgeHover?(true)
} else if floatingSidebar, FloatingSidebarGeometry.shouldHide(at: p, in: bounds, sidebarWidth: sidebarWidth,
- pressedMouseButtons: NSEvent.pressedMouseButtons) {
+ pressedMouseButtons: NSEvent.pressedMouseButtons, edgeToEdge: edgeToEdge) {
onEdgeHover?(false)
}
}
@@ -457,25 +459,26 @@ final class ShellView: NSView {
return Frames(sidebar: NSRect(x: -width, y: 0, width: width, height: b.height),
handle: .zero, content: b, cornerRadius: 0, sidebarCorner: 0)
}
+ // Edge to edge the card fills what the sidebar leaves, square; the window's own
+ // corners round it where they meet.
+ let inset = edgeToEdge ? 0 : CraMetrics.contentInset
+ let radius = edgeToEdge ? 0 : CraMetrics.contentCornerRadius
if sidebarVisible {
- let inset = CraMetrics.contentInset
let content = NSRect(x: width, y: inset, width: max(0, b.width - width - inset), height: max(0, b.height - 2 * inset))
return Frames(sidebar: NSRect(x: 0, y: 0, width: width, height: b.height),
handle: NSRect(x: width - 4, y: 0, width: 8, height: b.height),
- content: content, cornerRadius: CraMetrics.contentCornerRadius, sidebarCorner: 0)
+ content: content, cornerRadius: radius, sidebarCorner: 0)
}
if floating {
// The floating sidebar hovers over the page; the card does not move (Arc).
let m = FloatingSidebarGeometry.margin
- let inset = CraMetrics.contentInset
return Frames(sidebar: NSRect(x: m, y: m, width: width, height: b.height - 2 * m),
- handle: .zero, content: b.insetBy(dx: inset, dy: inset), cornerRadius: CraMetrics.contentCornerRadius, sidebarCorner: 12)
+ handle: .zero, content: b.insetBy(dx: inset, dy: inset), cornerRadius: radius, sidebarCorner: 12)
}
// Sidebar hidden: Arc keeps the rounded card floating in its inset (measured 25 Oct:
// card edge 10 pt from the window edge after ⌘S), with a sidebar toggle in the bar.
- let inset = CraMetrics.contentInset
return Frames(sidebar: NSRect(x: -width - 20, y: 0, width: width, height: b.height),
- handle: .zero, content: b.insetBy(dx: inset, dy: inset), cornerRadius: CraMetrics.contentCornerRadius, sidebarCorner: 0)
+ handle: .zero, content: b.insetBy(dx: inset, dy: inset), cornerRadius: radius, sidebarCorner: 0)
}
private var cardCornerRadius: CGFloat = CraMetrics.contentCornerRadius
@@ -521,7 +524,8 @@ final class ShellView: NSView {
for c in paneCards {
c.showToolbar = toolbarVisible
// Several panes: every card is rounded; a single card follows the window state (square in fullscreen).
- c.cornerRadius = paneCards.count > 1 ? CraMetrics.contentCornerRadius : cardCornerRadius
+ // Edge to edge every card is square.
+ c.cornerRadius = paneCards.count > 1 && !edgeToEdge ? CraMetrics.contentCornerRadius : cardCornerRadius
if !animatingPanes, let f = layout.frames[c.tabID] {
if animated { c.animator().frame = f } else if c.frame != f { c.frame = f }
}
diff --git a/Sources/Cra/UI/Sidebar/List/SidebarRowViews.swift b/Sources/Cra/UI/Sidebar/List/SidebarRowViews.swift
index 3d684cd..bba122c 100644
--- a/Sources/Cra/UI/Sidebar/List/SidebarRowViews.swift
+++ b/Sources/Cra/UI/Sidebar/List/SidebarRowViews.swift
@@ -58,6 +58,98 @@ enum SidebarSymbols {
}
}
+extension NSImageView {
+ /// Arc's refresh ⇄ stop swap, fitted frame by frame to a 120 fps capture of Arc 1.170 (30 Oct): over
+ /// ~90 ms the old glyph fades while shrinking to 0.7 and the new one fades in growing from 0.7,
+ /// both easing in and out. (The system's Replace transition un-draws arrow.clockwise over 0.8 s.)
+ func swapSymbol(_ image: NSImage?) {
+ guard let superview, window != nil, let old = self.image, image != nil else { self.image = image; return }
+ let ghost = NSImageView(frame: frame)
+ ghost.wantsLayer = true
+ ghost.imageScaling = imageScaling
+ ghost.image = old
+ ghost.contentTintColor = contentTintColor
+ superview.addSubview(ghost, positioned: .above, relativeTo: self)
+ self.image = image
+ guard let layer, let ghostLayer = ghost.layer else { ghost.removeFromSuperview(); return }
+ CATransaction.begin()
+ CATransaction.setDisableActions(true)
+ CATransaction.setCompletionBlock { ghost.removeFromSuperview() }
+ // A press turn still settling goes out with the old glyph; the new one starts square.
+ ghostLayer.transform = layer.transform
+ for key in layer.animationKeys() ?? [] where key.hasPrefix("turn") {
+ if let turn = layer.animation(forKey: key) { ghostLayer.add(turn, forKey: key) }
+ layer.removeAnimation(forKey: key)
+ }
+ layer.transform = CATransform3DIdentity
+ layer.setValue(nil, forKey: "turn")
+ ghostLayer.opacity = 0
+ ghostLayer.add(Self.swapAnimation(ghostLayer, fadeIn: false), forKey: "swap")
+ layer.add(Self.swapAnimation(layer, fadeIn: true), forKey: "swap")
+ CATransaction.commit()
+ }
+
+ private static func swapAnimation(_ layer: CALayer, fadeIn: Bool) -> CAAnimationGroup {
+ let c = centre(of: layer)
+ var small = CATransform3DMakeTranslation(c.x, c.y, 0)
+ small = CATransform3DScale(small, 0.7, 0.7, 1)
+ small = CATransform3DTranslate(small, -c.x, -c.y, 0)
+ // Added to whatever turn the glyph has.
+ let scale = CABasicAnimation(keyPath: "transform")
+ scale.isAdditive = true
+ scale.fromValue = NSValue(caTransform3D: fadeIn ? small : CATransform3DIdentity)
+ scale.toValue = NSValue(caTransform3D: fadeIn ? CATransform3DIdentity : small)
+ let fade = CABasicAnimation(keyPath: "opacity")
+ fade.fromValue = fadeIn ? 0 : 1
+ fade.toValue = fadeIn ? 1 : 0
+ let group = CAAnimationGroup()
+ group.animations = [scale, fade]
+ group.duration = 0.09
+ group.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
+ return group
+ }
+
+ /// Arc's press on the refresh arrow (same capture): a quarter turn clockwise about the arrow's
+ /// circle while the button is down, back on release, 0.15 s ease-in-out each way. As in SwiftUI a
+ /// turn is added on top of one still running, so a quick click only nudges the arrow.
+ func pressTurn(_ down: Bool) {
+ guard let layer else { return }
+ let to: CGFloat = down ? .pi / 2 : 0
+ let from = layer.value(forKey: "turn") as? CGFloat ?? 0
+ guard to != from else { return }
+ layer.setValue(to, forKey: "turn")
+ let flipped = layer.contentsAreFlipped()
+ // arrow.clockwise's circle sits 1/16 of the image's height below the image's centre.
+ var c = Self.centre(of: layer)
+ c.y += (flipped ? 1 : -1) * (image?.size.height ?? 0) / 16
+ func turned(_ angle: CGFloat) -> CATransform3D {
+ var t = CATransform3DMakeTranslation(c.x, c.y, 0)
+ t = CATransform3DRotate(t, flipped ? angle : -angle, 0, 0, 1)
+ return CATransform3DTranslate(t, -c.x, -c.y, 0)
+ }
+ CATransaction.begin()
+ CATransaction.setDisableActions(true)
+ layer.transform = turned(to)
+ if window != nil {
+ // Even steps of angle, eased as a whole: a single matrix tween would swing the pivot.
+ let steps = 30
+ let turn = CAKeyframeAnimation(keyPath: "transform")
+ turn.values = (0...steps).map { NSValue(caTransform3D: turned((from - to) * CGFloat(steps - $0) / CGFloat(steps))) }
+ turn.isAdditive = true
+ turn.duration = 0.15
+ turn.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
+ turn.beginTime = layer.convertTime(CACurrentMediaTime(), from: nil)
+ layer.add(turn, forKey: "turn\(turn.beginTime)")
+ }
+ CATransaction.commit()
+ }
+
+ /// The layer's centre relative to its anchor: AppKit keeps a view layer's anchor where it likes.
+ private static func centre(of layer: CALayer) -> CGPoint {
+ CGPoint(x: layer.bounds.width * (0.5 - layer.anchorPoint.x), y: layer.bounds.height * (0.5 - layer.anchorPoint.y))
+ }
+}
+
enum SidebarText {
/// NSTextField draws its text this far in from its frame; labels are placed that much
/// further left so the text lands where SwiftUI's Text put it.
@@ -81,6 +173,9 @@ final class SidebarGlyphButton: NSView {
var action: () -> Void
let size: NSSize
private let glyph = NSImageView()
+ private var shownSymbol: String?
+ /// Arc turns the refresh arrow while it is pressed (NSImageView.pressTurn).
+ private var turnsOnPress = false
/// Stroked instead of the image (SidebarSymbols.closeMark).
private var mark: CAShapeLayer?
private var markMinus = false
@@ -102,6 +197,7 @@ final class SidebarGlyphButton: NSView {
layer?.cornerRadius = 7
layer?.cornerCurve = .continuous
glyph.image = SidebarSymbols.image(symbol, size: iconSize, weight: weight)
+ shownSymbol = symbol
glyph.imageScaling = .scaleNone
glyph.frame = bounds
glyph.autoresizingMask = [.width, .height]
@@ -115,11 +211,21 @@ final class SidebarGlyphButton: NSView {
required init?(coder: NSCoder) { fatalError() }
- func setSymbol(_ symbol: String, iconSize: CGFloat, weight: NSFont.Weight = .medium, help: String) {
- setGlyph(SidebarSymbols.image(symbol, size: iconSize, weight: weight), help: help)
+ /// `animated` swaps another symbol in the way Arc swaps refresh and stop.
+ func setSymbol(_ symbol: String, iconSize: CGFloat, weight: NSFont.Weight = .medium, help: String, animated: Bool = false) {
+ let image = SidebarSymbols.image(symbol, size: iconSize, weight: weight)
+ if animated, shownSymbol != nil, shownSymbol != symbol {
+ glyph.swapSymbol(image)
+ setHelp(help)
+ } else {
+ setGlyph(image, help: help)
+ }
+ shownSymbol = symbol
+ turnsOnPress = animated && symbol == "arrow.clockwise"
}
func setGlyph(_ image: NSImage?, help: String) {
+ shownSymbol = nil
glyph.image = image
glyph.isHidden = false
mark?.isHidden = true
@@ -138,6 +244,7 @@ final class SidebarGlyphButton: NSView {
mark = m
}
markMinus = minus
+ shownSymbol = nil
glyph.isHidden = true
mark?.isHidden = false
needsLayout = true
@@ -210,8 +317,14 @@ final class SidebarGlyphButton: NSView {
override func mouseEntered(with event: NSEvent) { hovering = true }
override func mouseExited(with event: NSEvent) { hovering = false }
- override func mouseDown(with event: NSEvent) {}
+ override func mouseDown(with event: NSEvent) {
+ if turnsOnPress, enabled { glyph.pressTurn(true) }
+ }
+ override func mouseDragged(with event: NSEvent) {
+ if turnsOnPress, enabled { glyph.pressTurn(bounds.contains(convert(event.locationInWindow, from: nil))) }
+ }
override func mouseUp(with event: NSEvent) {
+ if turnsOnPress { glyph.pressTurn(false) }
if enabled, bounds.contains(convert(event.locationInWindow, from: nil)) { action() }
}
}
diff --git a/Sources/Cra/UI/Sidebar/List/SidebarView.swift b/Sources/Cra/UI/Sidebar/List/SidebarView.swift
index 4e391ca..990d1f7 100644
--- a/Sources/Cra/UI/Sidebar/List/SidebarView.swift
+++ b/Sources/Cra/UI/Sidebar/List/SidebarView.swift
@@ -218,14 +218,15 @@ final class SidebarTopBarView: NSView {
}
private func button(_ key: String, symbol: String, help: String, size: CGFloat, height: CGFloat, iconSize: CGFloat,
- weight: NSFont.Weight = .regular, active: Bool?, enabled: Bool = true, action: @escaping () -> Void) -> SidebarGlyphButton {
+ weight: NSFont.Weight = .regular, active: Bool?, enabled: Bool = true, animated: Bool = false,
+ action: @escaping () -> Void) -> SidebarGlyphButton {
let b = buttons[key] ?? {
let b = SidebarGlyphButton(symbol: symbol, size: size, height: height, iconSize: iconSize, weight: weight, help: help, colors: colors, action: action)
buttons[key] = b
addSubview(b)
return b
}()
- b.setSymbol(symbol, iconSize: iconSize, weight: weight, help: help)
+ b.setSymbol(symbol, iconSize: iconSize, weight: weight, help: help, animated: animated)
b.colors = colors
b.active = active
b.enabled = enabled
@@ -247,11 +248,11 @@ final class SidebarTopBarView: NSView {
shown.append(button("toggle", symbol: "sidebar.left", help: "Hide Sidebar (⌘S)", size: 32, height: 32, iconSize: 15.5, active: active) { [weak self] in self?.actions.toggleSidebar() })
shown.append(button("back", symbol: "arrow.left", help: "Go Back (⌘[)", size: 32, height: 32, iconSize: 15, active: active, enabled: ui.canGoBack) { [weak self] in self?.actions.goBack() })
shown.append(button("forward", symbol: "arrow.right", help: "Go Forward (⌘])", size: 32, height: 32, iconSize: 15, active: active, enabled: ui.canGoForward) { [weak self] in self?.actions.goForward() })
- shown.append(button("reload", symbol: reloadSymbol, help: "Refresh (⌘R)", size: 32, height: 32, iconSize: 15, active: active) { [weak self] in self?.actions.reload() })
+ shown.append(button("reload", symbol: reloadSymbol, help: "Refresh (⌘R)", size: 32, height: 32, iconSize: 15, active: active, animated: true) { [weak self] in self?.actions.reload() })
} else if devNav {
shown.append(button("dback", symbol: "arrow.left", help: "Go Back (⌘[)", size: 34, height: 28, iconSize: 15, active: nil, enabled: ui.canGoBack) { [weak self] in self?.actions.goBack() })
shown.append(button("dforward", symbol: "arrow.right", help: "Go Forward (⌘])", size: 34, height: 28, iconSize: 15, active: nil, enabled: ui.canGoForward) { [weak self] in self?.actions.goForward() })
- shown.append(button("dreload", symbol: reloadSymbol, help: "Refresh (⌘R)", size: 24, height: 24, iconSize: 15, active: nil) { [weak self] in self?.actions.reload() })
+ shown.append(button("dreload", symbol: reloadSymbol, help: "Refresh (⌘R)", size: 24, height: 24, iconSize: 15, active: nil, animated: true) { [weak self] in self?.actions.reload() })
}
for (k, b) in buttons where !shown.contains(where: { $0 === b }) {
b.removeFromSuperview()
diff --git a/Sources/Cra/UI/Windows/FloatingSidebar.swift b/Sources/Cra/UI/Windows/FloatingSidebar.swift
index 32dadd2..dbc2037 100644
--- a/Sources/Cra/UI/Windows/FloatingSidebar.swift
+++ b/Sources/Cra/UI/Windows/FloatingSidebar.swift
@@ -63,10 +63,10 @@ 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) else { return }
+ guard sidebarHidden(), FloatingSidebarGeometry.shouldReveal(at: p, in: shell.bounds, edgeToEdge: shell.edgeToEdge) else { return }
show()
} else if FloatingSidebarGeometry.shouldHide(at: p, in: shell.bounds, sidebarWidth: shell.sidebarWidth,
- pressedMouseButtons: NSEvent.pressedMouseButtons) {
+ pressedMouseButtons: NSEvent.pressedMouseButtons, edgeToEdge: shell.edgeToEdge) {
hide(animated: true)
}
}
diff --git a/Sources/Cra/UI/Windows/FloatingSidebarGeometry.swift b/Sources/Cra/UI/Windows/FloatingSidebarGeometry.swift
index f927482..d05691e 100644
--- a/Sources/Cra/UI/Windows/FloatingSidebarGeometry.swift
+++ b/Sources/Cra/UI/Windows/FloatingSidebarGeometry.swift
@@ -7,20 +7,22 @@ enum FloatingSidebarGeometry {
/// outside the window (2–4 pt, as in Arc). Arc 1.170's own strip is 5 pt (measured 29 Oct:
/// out at 1–5 pt, not at 6 or 9 pt); the full margin is a deliberate choice, easier to hit.
static let revealInside: CGFloat = 10
+ /// Edge to edge there is no margin: the strip over the page is Arc's 5 pt.
+ static let revealInsideEdgeToEdge: CGFloat = 5
static let revealOutside: CGFloat = 4
static let margin: CGFloat = 8
static let leaveSlack: CGFloat = 24
- static func shouldReveal(at point: CGPoint, in bounds: CGRect) -> Bool {
+ static func shouldReveal(at point: CGPoint, in bounds: CGRect, edgeToEdge: Bool = false) -> Bool {
point.y >= bounds.minY && point.y <= bounds.maxY
- && point.x >= bounds.minX - revealOutside && point.x <= bounds.minX + revealInside
+ && point.x >= bounds.minX - revealOutside && point.x <= bounds.minX + (edgeToEdge ? revealInsideEdgeToEdge : revealInside)
}
static func shouldHide(at point: CGPoint, in bounds: CGRect, sidebarWidth: CGFloat,
- pressedMouseButtons: Int) -> Bool {
+ pressedMouseButtons: Int, edgeToEdge: Bool = false) -> Bool {
// Window movement can put the pointer outside the panel briefly. Preserve
// the active drag/context gesture; the next released-pointer check dismisses.
- guard pressedMouseButtons == 0, !shouldReveal(at: point, in: bounds) else { return false }
+ guard pressedMouseButtons == 0, !shouldReveal(at: point, in: bounds, edgeToEdge: edgeToEdge) else { return false }
return !bounds.contains(point) || point.x > bounds.minX + sidebarWidth + margin + leaveSlack
}
}
diff --git a/Sources/Cra/UI/Windows/MainWindowController.swift b/Sources/Cra/UI/Windows/MainWindowController.swift
index 17ddf04..b855ea2 100644
--- a/Sources/Cra/UI/Windows/MainWindowController.swift
+++ b/Sources/Cra/UI/Windows/MainWindowController.swift
@@ -92,6 +92,7 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
shell.sidebarWidth = CGFloat(store.prefs.sidebarWidth)
shell.sidebarVisible = sidebarVisible
shell.showToolbar = store.settings.showToolbar
+ shell.edgeToEdge = store.settings.edgeToEdgeContent
lastSidebarVisible = sidebarVisible
window.trafficLightsHidden = !sidebarVisible
lastSidebarWidth = CGFloat(store.prefs.sidebarWidth)
@@ -172,7 +173,10 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
installFloatingSidebar()
observeStore()
refresh()
- shell.onDevToolsFrame = { [weak self] rect in self?.positionDevToolsWindow(rect) }
+ shell.onDevToolsFrame = { [weak self] rect in
+ guard let self, let id = self.browsers.visibleTabID else { return }
+ self.positionDevToolsWindow(rect, tab: id)
+ }
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
@@ -311,6 +315,7 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
let factors = SplitPaneLayout.normalizedFactors(ids: panes, stored: split?.split?.widthFactors ?? [:])
let empty = Set(panes.filter { store.item($0)?.isEmptyTab == true })
if shell.showToolbar != store.settings.showToolbar { shell.showToolbar = store.settings.showToolbar }
+ if shell.edgeToEdge != store.settings.edgeToEdgeContent { shell.edgeToEdge = store.settings.edgeToEdgeContent }
shell.setPanes(panes, factors: factors, orientation: split?.split?.orientation ?? .horizontal, focused: selected, empty: empty, animated: true)
// A page is on screen in one window at a time. Arc keeps the tab selected in every window
// that has it open: the window in use holds the page, the others show a blurred snapshot
@@ -732,20 +737,20 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
}
}
releaseUnfocusedEmbeddedPage()
- if let dev = browsers.visibleDevToolsWindow, dev.parent === window {
- raisePageWindows(above: dev)
+ if browsers.visibleDevToolsWindows.values.contains(where: { $0.parent === window }) {
+ raisePageWindows()
} else {
raiseOverlayPanels()
}
}
- /// Moves the page's view from its Chrome window into its card (EmbeddedPages). With
+ /// Moves the page's view from its Chrome window into its card (EmbeddedPages). With its
/// DevTools open the page goes back: Chrome's docked frontend lays it out in its window.
private func embedPage(_ id: UUID, from w: NSWindow) {
guard EmbeddedPages.isEnabled else { return }
guard let views = EmbeddedPages.pageViews(of: w) else { return }
let target: NSView
- if browsers.visibleDevToolsWindow != nil, let cv = w.contentView {
+ if browsers.devToolsViews[id]?.window != nil, let cv = w.contentView {
EmbeddedPages.unmarkHost(w)
target = cv
} else if let card = shell.paneCards.first(where: { $0.tabID == id }) {
@@ -823,12 +828,15 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
lastPaneFrames = frames
let focusRect = (browsers.visibleTabID.flatMap { frames[$0] }) ?? frames.values.first!
let focusPage = browsers.visibleTabID.map { pageRect(forBody: focusRect, tab: $0) } ?? focusRect
- let live = pageWindowsFollowLive || shell.devToolsFrontendDocked
+ let devTools = browsers.visibleDevToolsWindows
+ let live = pageWindowsFollowLive || shell.devToolsFrontendDocked || !devTools.isEmpty
for id in browsers.visibleTabIDs {
guard let w = browsers.runtime(for: id)?.hostWindow else { continue }
let body = frames[id] ?? focusRect
let page = pageRect(forBody: body, tab: id)
let target = window.convertToScreen(page)
+ // Chrome's docked frontend spans its pane's body, under the page.
+ if devTools[id] != nil, browsers.devToolsDockedState[id] ?? true { positionDevToolsWindow(body, tab: id) }
if w.frame != target { w.setFrame(target, display: live) }
updatePageCorners(w, page: page, body: body)
// A switch can show the page before its card exists; the card is laid out by now.
@@ -874,8 +882,8 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
NSAnimationContext.runAnimationGroup { ctx in
ctx.duration = duration
ctx.timingFunction = timing
- if shell.devToolsFrontendDocked, let dev = browsers.visibleDevToolsWindow, dev.parent === window,
- let focusID = browsers.visibleTabID, let body = frames[focusID] {
+ for (id, dev) in browsers.visibleDevToolsWindows where dev.parent === window {
+ guard browsers.runtime(for: id)?.hostWindow != nil, let body = frames[id] else { continue }
dev.animator().setFrame(window.convertToScreen(body), display: true)
}
overlayPanel?.animator().setFrame(window.convertToScreen(focusPage), display: true)
@@ -925,7 +933,7 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
/// from the body's edges while the body is still resizing, so the page follows at
/// once instead of waiting for the frontend's next layout.
private func pageRect(forBody body: NSRect, tab: UUID) -> NSRect {
- guard tab == browsers.visibleTabID, shell.devToolsFrontendDocked,
+ guard browsers.devToolsViews[tab] != nil, browsers.runtime(for: tab)?.hostWindow != nil,
browsers.devToolsDockedState[tab] ?? true,
let p = browsers.devToolsPlaceholders[tab] else { return body }
let right = max(0, p.frontendSize.width - p.bounds.maxX)
@@ -947,17 +955,23 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
w.styleMask.remove([.titled, .resizable])
ChromiumWindowCorners.setSquare(true, for: w)
}
- // The whole mask, not only the corner set: a rebuilt layer would otherwise keep
- // whatever radius and clipping it came with.
- let radius = shell.contentFullscreen ? 0 : CraMetrics.contentCornerRadius
- if layer.cornerRadius != radius { layer.cornerRadius = radius }
- if layer.cornerCurve != .continuous { layer.cornerCurve = .continuous }
- if !layer.masksToBounds { layer.masksToBounds = true }
// Chromium's content view is flipped, so its layer's MinY edge is the top.
let bottomLeft: CACornerMask = cv.isFlipped ? .layerMinXMaxYCorner : .layerMinXMinYCorner
let bottomRight: CACornerMask = cv.isFlipped ? .layerMaxXMaxYCorner : .layerMaxXMinYCorner
let topLeft: CACornerMask = cv.isFlipped ? .layerMinXMinYCorner : .layerMinXMaxYCorner
let topRight: CACornerMask = cv.isFlipped ? .layerMaxXMinYCorner : .layerMaxXMaxYCorner
+ // The whole mask, not only the corner set: a rebuilt layer would otherwise keep
+ // whatever radius and clipping it came with.
+ if layer.cornerCurve != .continuous { layer.cornerCurve = .continuous }
+ if !layer.masksToBounds { layer.masksToBounds = true }
+ // Edge to edge the card is square, but a page window is not clipped by the main
+ // window: where it meets the window's corners it takes their radius.
+ if shell.edgeToEdge {
+ roundAtWindowCorners(layer, rect: page, flipped: cv.isFlipped)
+ return
+ }
+ let radius = shell.contentFullscreen ? 0 : CraMetrics.contentCornerRadius
+ if layer.cornerRadius != radius { layer.cornerRadius = radius }
var corners: CACornerMask = []
// A fullscreen card is square.
if !shell.contentFullscreen, abs(page.minY - body.minY) < 0.5 {
@@ -972,6 +986,25 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
if layer.maskedCorners != corners { layer.maskedCorners = corners }
}
+ /// Edge to edge: a child window (page or DevTools) is not clipped by the main window, so
+ /// the corners of `rect` (window coordinates) that sit on the window's corners take its radius.
+ private func roundAtWindowCorners(_ layer: CALayer, rect: NSRect, flipped: Bool) {
+ guard let window else { return }
+ let radius = window.styleMask.contains(.fullScreen) || shell.contentFullscreen ? 0 : LittleWindow.cornerRadius(of: window)
+ let w = shell.bounds
+ var corners: CACornerMask = []
+ if abs(rect.minY - w.minY) < 0.5 {
+ if abs(rect.minX - w.minX) < 0.5 { corners.insert(flipped ? .layerMinXMaxYCorner : .layerMinXMinYCorner) }
+ if abs(rect.maxX - w.maxX) < 0.5 { corners.insert(flipped ? .layerMaxXMaxYCorner : .layerMaxXMinYCorner) }
+ }
+ if abs(rect.maxY - w.maxY) < 0.5 {
+ if abs(rect.minX - w.minX) < 0.5 { corners.insert(flipped ? .layerMinXMinYCorner : .layerMinXMaxYCorner) }
+ if abs(rect.maxX - w.maxX) < 0.5 { corners.insert(flipped ? .layerMaxXMinYCorner : .layerMaxXMaxYCorner) }
+ }
+ if layer.cornerRadius != radius { layer.cornerRadius = radius }
+ if layer.maskedCorners != corners { layer.maskedCorners = corners }
+ }
+
/// Chromium lays its frameless window's content view out below a 22 pt title bar
/// that Cra hides, leaving a blank band over the page; make it fill the window.
private func fillContentView(_ w: NSWindow) {
@@ -980,15 +1013,17 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
if cv.frame != full { cv.frame = full }
}
- /// Shows the visible tab's DevTools window and hides the other tabs'. Chrome-style
- /// pages get Chrome's dockable frontend (see CraCEF's DevToolsClient): its window
- /// spans the card body under the page, which is laid over the placeholder it
- /// reports. Alloy pages keep the shell's own split with CEF's window on the right.
+ /// Shows the visible tabs' DevTools windows (each split pane keeps its own) and hides
+ /// the other tabs'. Chrome-style pages get Chrome's dockable frontend (see CraCEF's
+ /// DevToolsClient): its window spans the pane's body under the page, which is laid
+ /// over the placeholder it reports. Alloy pages keep the shell's own split with CEF's
+ /// window on the right, for the focused tab only.
func browserManagerDevToolsChanged() {
guard let window else { return }
let visible = browsers.visibleDevToolsWindow
+ let shown = browsers.visibleDevToolsWindows
for (_, view) in browsers.devToolsViews {
- if let w = view.window, w !== visible { w.orderOut(nil) }
+ if let w = view.window, !shown.values.contains(where: { $0 === w }) { w.orderOut(nil) }
}
let selfDock = visible != nil && browsers.visibleRuntime?.hostWindow != nil
let docked = browsers.visibleTabID.flatMap { browsers.devToolsDockedState[$0] } ?? true
@@ -1001,20 +1036,23 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
shell.needsLayout = true
shell.layoutSubtreeIfNeeded()
}
- guard let w = visible else {
- if shell.frontendPageRect != nil { shell.frontendPageRect = nil }
- positionPageWindows(lastPaneFrames)
- return
- }
- if selfDock && !docked {
- detachDevToolsWindow(w)
- positionPageWindows(lastPaneFrames)
- return
+ if visible == nil, shell.frontendPageRect != nil { shell.frontendPageRect = nil }
+ var attached = false
+ for id in browsers.visibleTabIDs {
+ guard let w = shown[id] else { continue }
+ let chrome = browsers.runtime(for: id)?.hostWindow != nil
+ if chrome, browsers.devToolsDockedState[id] == false {
+ detachDevToolsWindow(w, tab: id)
+ continue
+ }
+ attachDevToolsWindow(w, selfDock: chrome, tab: id)
+ // Chrome's frontend spans its pane's body (positionPageWindows keeps it there);
+ // Alloy's sits in the shell's dock.
+ if !chrome { positionDevToolsWindow((shell.devToolsHost.superview ?? shell.contentContainer).convert(shell.devToolsHost.frame, to: nil), tab: id) }
+ w.orderFront(nil)
+ attached = true
}
- attachDevToolsWindow(w, selfDock: selfDock)
- positionDevToolsWindow((shell.devToolsHost.superview ?? shell.contentContainer).convert(shell.devToolsHost.frame, to: nil))
- w.orderFront(nil)
- raisePageWindows(above: w)
+ if attached { raisePageWindows() }
positionPageWindows(lastPaneFrames)
}
@@ -1040,7 +1078,7 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
return s
}
- private func attachDevToolsWindow(_ w: NSWindow, selfDock: Bool) {
+ private func attachDevToolsWindow(_ w: NSWindow, selfDock: Bool, tab: UUID) {
guard let window else { return }
if w.parent !== window {
// CEF made a normal window; strip its chrome so only the DevTools content shows.
@@ -1061,67 +1099,81 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
w.backgroundColor = .clear
window.addChildWindow(w, ordered: .above)
fillContentView(w)
- if selfDock { setDevToolsTitleBarInset(nil) }
+ if selfDock { setDevToolsTitleBarInset(nil, tab: tab) }
}
- if let cv = w.contentView {
- cv.wantsLayer = true
- cv.layer?.cornerRadius = CraMetrics.contentCornerRadius
- cv.layer?.cornerCurve = .continuous
- // Frontend-docked: the window spans the card body, so both bottom corners are
- // card corners. Shell-docked (Alloy): it sits right of the page.
- let bottom: CACornerMask = cv.isFlipped ? [.layerMinXMaxYCorner, .layerMaxXMaxYCorner] : [.layerMinXMinYCorner, .layerMaxXMinYCorner]
- cv.layer?.maskedCorners = selfDock ? bottom : [.layerMaxXMaxYCorner, .layerMaxXMinYCorner]
- cv.layer?.masksToBounds = true
+ updateDevToolsCorners(w, tab: tab)
+ }
+
+ private func updateDevToolsCorners(_ w: NSWindow, tab: UUID) {
+ guard let cv = w.contentView else { return }
+ cv.wantsLayer = true
+ guard let layer = cv.layer else { return }
+ layer.cornerCurve = .continuous
+ layer.masksToBounds = true
+ if shell.edgeToEdge, let window {
+ roundAtWindowCorners(layer, rect: window.convertFromScreen(w.frame), flipped: cv.isFlipped)
+ return
}
+ layer.cornerRadius = CraMetrics.contentCornerRadius
+ // Frontend-docked: the window spans the card body, so both bottom corners are
+ // card corners, and the top ones too without the toolbar (else they showed past the
+ // page's rounded top corners). Shell-docked (Alloy): it sits right of the page.
+ let selfDock = browsers.runtime(for: tab)?.hostWindow != nil
+ let bottom: CACornerMask = cv.isFlipped ? [.layerMinXMaxYCorner, .layerMaxXMaxYCorner] : [.layerMinXMinYCorner, .layerMaxXMinYCorner]
+ let all: CACornerMask = [.layerMinXMinYCorner, .layerMaxXMinYCorner, .layerMinXMaxYCorner, .layerMaxXMaxYCorner]
+ layer.maskedCorners = selfDock ? (shell.showToolbar ? bottom : all) : [.layerMaxXMaxYCorner, .layerMaxXMinYCorner]
}
/// "Undock into separate window": the frontend's window becomes a floating window of its own.
- private func detachDevToolsWindow(_ w: NSWindow) {
+ private func detachDevToolsWindow(_ w: NSWindow, tab: UUID) {
guard let window else { return }
- if w.parent === window {
- window.removeChildWindow(w)
- // A normal titled window, like Chrome's undocked "DevTools - <url>" (the
- // frontend draws under a real title bar; attach strips all of this again).
- w.styleMask.remove(.fullSizeContentView)
- w.styleMask.insert([.titled, .closable, .miniaturizable, .resizable])
- ChromiumWindowCorners.setSquare(false, for: w)
- ChromiumChildHover.setDocked(false, for: w)
- w.titlebarAppearsTransparent = false
- w.titleVisibility = .visible
- if let url = selectedTab?.tab?.url {
- w.title = "DevTools - " + url.replacingOccurrences(of: "^[a-z]+://", with: "", options: .regularExpression)
- }
- for type in [NSWindow.ButtonType.closeButton, .miniaturizeButton, .zoomButton] { w.standardWindowButton(type)?.isHidden = false }
- w.hasShadow = true
- w.isMovable = true
- w.isOpaque = true
- w.backgroundColor = .windowBackgroundColor
- if let cv = w.contentView {
- cv.layer?.cornerRadius = 0
- cv.layer?.masksToBounds = false
- }
- let f = window.frame
- let size = NSSize(width: min(1100, f.width * 0.8), height: min(760, f.height * 0.8))
- w.setFrame(NSRect(x: f.midX - size.width / 2 + 40, y: f.midY - size.height / 2 - 20, width: size.width, height: size.height), display: true)
- setDevToolsTitleBarInset(w)
+ guard w.parent === window else {
+ // Already floating: show it again after a tab switch without taking the keys.
+ if !w.isVisible { w.orderFront(nil) }
+ return
}
+ window.removeChildWindow(w)
+ // A normal titled window, like Chrome's undocked "DevTools - <url>" (the
+ // frontend draws under a real title bar; attach strips all of this again).
+ w.styleMask.remove(.fullSizeContentView)
+ w.styleMask.insert([.titled, .closable, .miniaturizable, .resizable])
+ ChromiumWindowCorners.setSquare(false, for: w)
+ ChromiumChildHover.setDocked(false, for: w)
+ w.titlebarAppearsTransparent = false
+ w.titleVisibility = .visible
+ if let url = browsers.runtime(for: tab)?.browser.currentURL, !url.isEmpty {
+ w.title = "DevTools - " + url.replacingOccurrences(of: "^[a-z]+://", with: "", options: .regularExpression)
+ }
+ for type in [NSWindow.ButtonType.closeButton, .miniaturizeButton, .zoomButton] { w.standardWindowButton(type)?.isHidden = false }
+ w.hasShadow = true
+ w.isMovable = true
+ w.isOpaque = true
+ w.backgroundColor = .windowBackgroundColor
+ if let cv = w.contentView {
+ cv.layer?.cornerRadius = 0
+ cv.layer?.masksToBounds = false
+ }
+ let f = window.frame
+ let size = NSSize(width: min(1100, f.width * 0.8), height: min(760, f.height * 0.8))
+ w.setFrame(NSRect(x: f.midX - size.width / 2 + 40, y: f.midY - size.height / 2 - 20, width: size.width, height: size.height), display: true)
+ setDevToolsTitleBarInset(w, tab: tab)
w.makeKeyAndOrderFront(nil)
}
/// CEF's frame view keeps a frameless window's content view at full window size, so
/// the undocked window's title bar covers the top of the frontend; move the
/// frontend's layout down by the title bar's height instead (0 when docked).
- private func setDevToolsTitleBarInset(_ w: NSWindow?) {
+ private func setDevToolsTitleBarInset(_ w: NSWindow?, tab: UUID) {
let inset = w.map { max(0, $0.frame.height - $0.contentLayoutRect.height) } ?? 0
let css = inset > 0 ? "body{margin-top:\(Int(inset))px!important;height:calc(100% - \(Int(inset))px)!important}" : ""
- currentBrowser?.executeJavaScript("(function(){var s=document.getElementById('cra-titlebar-inset');"
+ browsers.runtime(for: tab)?.browser.executeJavaScript("(function(){var s=document.getElementById('cra-titlebar-inset');"
+ "if(!s){s=document.createElement('style');s.id='cra-titlebar-inset';document.head.appendChild(s);}"
+ "s.textContent='\(css)';})();", inDevTools: true)
}
- /// Page windows go above the DevTools window (which spans the body when the frontend
- /// docks), and the overlay panel above everything.
- private func raisePageWindows(above dev: NSWindow) {
+ /// Page windows go above the DevTools windows (each spans its pane's body when the
+ /// frontend docks), and the overlay panel above everything.
+ private func raisePageWindows() {
guard let window else { return }
// Child windows ignore orderWindow:relativeTo:; re-adding a child puts it above its siblings.
for id in browsers.visibleTabIDs {
@@ -1133,12 +1185,13 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
raiseOverlayPanels()
}
- private func positionDevToolsWindow(_ rectInWindow: NSRect) {
- guard let window, let w = browsers.visibleDevToolsWindow, w.parent === window else { return }
+ private func positionDevToolsWindow(_ rectInWindow: NSRect, tab id: UUID) {
+ guard let window, let v = browsers.devToolsViews[id], let w = v.window, w.parent === window else { return }
let onScreen = window.convertToScreen(rectInWindow)
if w.frame != onScreen { w.setFrame(onScreen, display: true) }
fillContentView(w)
- if let cv = w.contentView, let id = browsers.visibleTabID, let v = browsers.devToolsViews[id], v.frame != cv.bounds {
+ updateDevToolsCorners(w, tab: id)
+ if let cv = w.contentView, v.frame != cv.bounds {
v.frame = cv.bounds
}
}
@@ -2101,11 +2154,14 @@ final class CraWindow: NSWindow {
/// press just past the card's edge still counts. Movable-by-background only drags,
/// and the toolbar takes a click as "edit URL", so the strip's presses are handled
/// here: a double-click runs the title bar action, anything else drags the window.
- private static let titleStripHeight = CraMetrics.contentInset + 4
+ /// Edge to edge there is no margin, so only the 4 pt reaching into the toolbar (or the page) is left.
+ private var titleStripHeight: CGFloat {
+ (contentView as? ShellView)?.edgeToEdge == true ? 4 : CraMetrics.contentInset + 4
+ }
override func sendEvent(_ event: NSEvent) {
if event.type == .leftMouseDown, !styleMask.contains(.fullScreen),
- let content = contentView, event.locationInWindow.y >= content.bounds.height - Self.titleStripHeight,
+ let content = contentView, event.locationInWindow.y >= content.bounds.height - titleStripHeight,
isTitleStrip(content.hitTest(content.convert(event.locationInWindow, from: nil))) {
if event.clickCount == 2 { performTitleDoubleClickAction() } else { performDrag(with: event) }
return
diff --git a/Sources/CraCEF/CraCEF.mm b/Sources/CraCEF/CraCEF.mm
index e5a770c..8b47745 100644
--- a/Sources/CraCEF/CraCEF.mm
+++ b/Sources/CraCEF/CraCEF.mm
@@ -481,6 +481,14 @@ public:
std::string disabled = command_line->GetSwitchValue("disable-features");
command_line->AppendSwitchWithValue("disable-features",
(disabled.empty() ? "" : disabled + ",") + "WebRtcHideLocalIpsWithMdns");
+ // --load-extension loads after the restored tabs start loading. The first extension
+ // with webRequest or declarativeNetRequest makes Chromium reset the profile's URL
+ // loader factories (WebRequestAPI::UpdateMayHaveProxies), which strands a navigation
+ // already in flight: the tab stayed blank and "loading" for good. Proxying from the
+ // start leaves nothing to reset (it also covers such an extension installed later).
+ std::string enabled = command_line->GetSwitchValue("enable-features");
+ command_line->AppendSwitchWithValue("enable-features",
+ (enabled.empty() ? "" : enabled + ",") + "ForceWebRequestProxyForTest");
// Kerberos/NTLM single sign-on (ADFS /adfs/ls/wia and the like). Chromium only sends
// the OS ticket to allowlisted hosts, and IT sets that list as a Chrome or Edge policy,
// which CEF never reads. Without it those logins fail with ERR_INVALID_AUTH_CREDENTIALS.
diff --git a/Tests/FloatingSidebarTests.swift b/Tests/FloatingSidebarTests.swift
index 0a70ca2..14b9cc4 100644
--- a/Tests/FloatingSidebarTests.swift
+++ b/Tests/FloatingSidebarTests.swift
@@ -77,6 +77,12 @@ enum FloatingSidebarTests {
expect(!FloatingSidebarGeometry.shouldReveal(at: CGPoint(x: 15.9, y: 100), in: bounds), "further outside does not reveal")
expect(!FloatingSidebarGeometry.shouldReveal(at: CGPoint(x: 22, y: 9.9), in: bounds), "above the window does not reveal")
expect(!FloatingSidebarGeometry.shouldReveal(at: CGPoint(x: 22, y: 890.1), in: bounds), "below the window does not reveal")
+ // Edge to edge (GitHub #24) there is no margin; only Arc's 5 pt strip over the page reveals.
+ expect(FloatingSidebarGeometry.shouldReveal(at: CGPoint(x: 25, y: 100), in: bounds, edgeToEdge: true), "edge to edge: 5 pt reveals")
+ expect(!FloatingSidebarGeometry.shouldReveal(at: CGPoint(x: 25.1, y: 100), in: bounds, edgeToEdge: true), "edge to edge: the page past 5 pt does not reveal")
+ expect(FloatingSidebarGeometry.shouldReveal(at: CGPoint(x: 16, y: 100), in: bounds, edgeToEdge: true), "edge to edge: just outside the window still reveals")
+ expect(!FloatingSidebarGeometry.shouldHide(at: CGPoint(x: 24, y: 100), in: bounds, sidebarWidth: 328, pressedMouseButtons: 0, edgeToEdge: true),
+ "edge to edge: the reveal strip does not hide what it revealed")
expect(!FloatingSidebarGeometry.shouldHide(at: CGPoint(x: 17, y: 100), in: bounds, sidebarWidth: 328, pressedMouseButtons: 0),
"the outside reveal strip does not hide what it revealed")
expect(!FloatingSidebarGeometry.shouldHide(at: CGPoint(x: 380, y: 100), in: bounds, sidebarWidth: 328, pressedMouseButtons: 0),
@@ -133,6 +139,7 @@ final class ShellView: NSView {
let resizeHandle = NSView()
var sidebarWidth: CGFloat = 328
var contentFullscreen = false
+ var edgeToEdge = false
var sidebarDetached = false
var floatingSidebar = false
struct Frames { let sidebar: NSRect }
diff --git a/docs/arc-reverse-engineering.md b/docs/arc-reverse-engineering.md
index 7626170..4475a66 100644
--- a/docs/arc-reverse-engineering.md
+++ b/docs/arc-reverse-engineering.md
@@ -1246,6 +1246,12 @@ the arm64 slice. [O] = observed, [I] = inferred.
- [O] Arc's preference is `topBarURLEnabled` in company.thebrowser.Browser (View ▸ Show Toolbar).
- [O] Row 1 (AX): traffic lights 16×16 at x 12/35/58, y 16. Sidebar toggle 32×32 at x 77, y 7. Go back, Go forward
and Reload are 32×32 at x 241/275/309 (2 pt apart, ending 6 pt from the sidebar edge), y 7. No ⌄ menu.
+- [O] Refresh ⇄ stop (120 fps capture of the toolbar button without the pointer, 30 Oct 2026; click and ⌘R alike):
+ when loading starts the ↻ cross-fades into the ✕ over ~10 frames (~85 ms), and back the same way when it ends.
+ Fitted per frame: the old glyph shrinks 1 → ~0.7 as it fades, the new one grows ~0.7 → 1 as it appears, both on
+ an ease-in-out curve (new opacity 0.02, 0.11, 0.37, 0.48 … 0.96). No rotation. Driven by the load state (Arc's
+ ReloadIcon isReloading), not the press. An AXPress on "Reload this page" showed no swap at all. The system
+ Replace symbol transition is NOT it: for arrow.clockwise it un-draws the arrow over ~0.8 s.
- [O] Row 2: the URL pill spans x 8…338 (8 pt in from both sides of a 347 pt sidebar), y 46…81 (36 pt), corner
radius ≈10, fill ≈5% black over the light theme. It shows only the host ("youtube.com", no lock or globe):
AX static text at x 20, 13 pt regular (ink 77 pt wide, the width of SF 13 regular). Favorites start at y 90.