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.
Mouse back and forward buttons over the sidebar switch spaces, like Arc (#233)
Victor2b9510058687
diff --git a/Packages/CraCore/Sources/CraCore/MouseButtonSpaceSwitch.swift b/Packages/CraCore/Sources/CraCore/MouseButtonSpaceSwitch.swiftnew file mode 100644index 0000000..a34eccb--- /dev/null+++ b/Packages/CraCore/Sources/CraCore/MouseButtonSpaceSwitch.swift@@ -0,0 +1,21 @@+/// A mouse's back and forward buttons switch spaces over the sidebar (issue #233). Arc 1.171's+/// `SidebarView.otherMouseUp:` sends its spaces reducer `focusPreviousSpace` for button 3 (back)+/// and `focusNextSpace` for button 4 (forward), the actions behind Spaces ▸ Previous/Next Space+/// (docs/arc-reverse-engineering.md, "Mouse back and forward buttons"). Over a page the buttons+/// stay Chromium's history back and forward.+public enum MouseButtonSpaceSwitch {+ /// AppKit's `buttonNumber` for a mouse's back button (the fourth button).+ public static let back = 3+ /// AppKit's `buttonNumber` for a mouse's forward button (the fifth button).+ public static let forward = 4++ /// The space step a released button makes, −1 for the previous space and +1 for the next, or+ /// nil for a button that doesn't switch spaces.+ public static func offset(buttonNumber: Int) -> Int? {+ switch buttonNumber {+ case back: -1+ case forward: 1+ default: nil+ }+ }+}diff --git a/Packages/CraCore/Tests/CraCoreTests/MouseButtonSpaceSwitchTests.swift b/Packages/CraCore/Tests/CraCoreTests/MouseButtonSpaceSwitchTests.swiftnew file mode 100644index 0000000..5db09a2--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/MouseButtonSpaceSwitchTests.swift@@ -0,0 +1,21 @@+import CraCore+import Testing++/// A mouse's back and forward buttons over the sidebar switch spaces like Arc 1.171 (issue #233).+struct MouseButtonSpaceSwitchTests {+ /// Arc's `SidebarView.otherMouseUp:` sends `focusPreviousSpace` for button 3 (back) and+ /// `focusNextSpace` for button 4 (forward), the actions behind Spaces ▸ Previous/Next Space.+ @Test(.bug("https://github.com/VictorKildahl/cra/issues/233"))+ func backGoesToThePreviousSpaceAndForwardToTheNext() {+ #expect(MouseButtonSpaceSwitch.offset(buttonNumber: 3) == -1)+ #expect(MouseButtonSpaceSwitch.offset(buttonNumber: 4) == 1)+ }++ /// Left, right and middle buttons keep their own jobs (a middle click closes a tab, #208).+ @Test(.bug("https://github.com/VictorKildahl/cra/issues/233"))+ func otherButtonsDoNotSwitch() {+ for button in [0, 1, 2, 5, 6, -1] {+ #expect(MouseButtonSpaceSwitch.offset(buttonNumber: button) == nil)+ }+ }+}diff --git a/Sources/Cra/App/AppDelegate.swift b/Sources/Cra/App/AppDelegate.swiftindex 40a59e8..a7e3a8e 100644--- a/Sources/Cra/App/AppDelegate.swift+++ b/Sources/Cra/App/AppDelegate.swift@@ -740,10 +740,18 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {return}// clickAt=x,y: a click there through the event queue, as the pointer's would go (#195);- // target=little as for menuAt.+ // target=little as for menuAt. button=back|forward: that mouse button released there,+ // handed to what the window's otherMouseUp monitor runs (#233); AppKit can't make a+ // window's event with button 3 or 4.if let g = dict["clickAt"]?.split(separator: ",").compactMap({ Double($0) }), g.count == 2,let w = dict["target"] == "little" ? littleWindows.last?.window : main.window {- TestGesture.click(at: NSPoint(x: g[0], y: w.frame.height - g[1]), in: w)+ let point = NSPoint(x: g[0], y: w.frame.height - g[1])+ if let b = dict["button"], let button = ["back": MouseButtonSpaceSwitch.back, "forward": MouseButtonSpaceSwitch.forward][b] {+ let taken = TestGesture.otherMouseUp(at: point, in: w).map { main.mouseButtonSwitchesSpace(button, $0) } ?? false+ CraLog.note("mouse \(b) at \(Int(g[0])),\(Int(g[1])): \(taken ? "switched space" : "passed on")")+ return+ }+ TestGesture.click(at: point, in: w)return}if let st = dict["status"] { main.browserManager(statusMessage: st); return }diff --git a/Sources/Cra/Services/TestGesture.swift b/Sources/Cra/Services/TestGesture.swiftindex 358920f..4202289 100644--- a/Sources/Cra/Services/TestGesture.swift+++ b/Sources/Cra/Services/TestGesture.swift@@ -31,6 +31,13 @@ enum TestGesture {}}+ /// An other-button release at a point of the window, as the window's event monitors see it+ /// (its button number is AppKit's, not the one a test means).+ static func otherMouseUp(at point: NSPoint, in window: NSWindow) -> NSEvent? {+ NSEvent.mouseEvent(with: .otherMouseUp, location: point, modifierFlags: [], timestamp: ProcessInfo.processInfo.systemUptime,+ windowNumber: window.windowNumber, context: nil, eventNumber: 0, clickCount: 1, pressure: 0)+ }+/// A key press through the app's event queue, routed as the keyboard's are (key equivalents,/// the page, then Cra's own keys), with the characters a layout gives: the test picks the/// layout's characters while the menu bar's key equivalents follow the selected one.diff --git a/Sources/Cra/UI/Windows/MainWindowController.swift b/Sources/Cra/UI/Windows/MainWindowController.swiftindex b3805d9..9aa91dc 100644--- a/Sources/Cra/UI/Windows/MainWindowController.swift+++ b/Sources/Cra/UI/Windows/MainWindowController.swift@@ -2066,12 +2066,16 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserMtarget.makeKey()return event}+ // A mouse's back and forward buttons over the sidebar switch spaces, like Arc's+ // SidebarView (issue #233); over a page they stay Chromium's history back and forward.// Middle-click on a sidebar tab closes it, like Arc and Chrome. Anywhere else, a page// included, the click goes on to whatever is under it. The row is found under the click// itself: a remembered hover outlived its row when the tab joined a split, and a middle// click inside a split pane closed that tab (GitHub #208).middleClickMonitor = NSEvent.addLocalMonitorForEvents(matching: .otherMouseUp) { [weak self] event in- guard let self, event.buttonNumber == 2, let window = self.window, let target = event.window,+ guard let self else { return event }+ if self.mouseButtonSwitchesSpace(event.buttonNumber, event) { return nil }+ guard event.buttonNumber == 2, let window = self.window, let target = event.window,target === window || target.parent === window,let id = SpaceListView.tabID(under: event) else { return event }self.middleClickClose(id)@@ -2344,14 +2348,29 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserMreturn v as? NSScrollView}+ /// A mouse's back or forward button released over the sidebar: the previous or next space,+ /// wrapping as Spaces ▸ Previous/Next Space do (Arc's SidebarView, issue #233). Returns false+ /// for any other button, or one released anywhere else.+ func mouseButtonSwitchesSpace(_ button: Int, _ event: NSEvent) -> Bool {+ guard let offset = MouseButtonSpaceSwitch.offset(buttonNumber: button), isOverSidebar(event) else { return false }+ store.focusSpace(offset: offset, window: windowID)+ return true+ }++ /// Whether `event` is over this window's sidebar, docked or floating, in a window that has+ /// spaces to switch (not a Little Window).+ private func isOverSidebar(_ event: NSEvent) -> Bool {+ let host = shell.sidebarHost+ return (shell.sidebarVisible || shell.floatingSidebar) && event.window != nil && event.window === host.window+ && host.bounds.contains(host.convert(event.locationInWindow, from: nil)) && !isStandalone+ }+/// Shift + wheel, or a sideways wheel, over the sidebar: past a flick the next or previous/// space comes in on the space change's spring, and before the first space the Library/// slides in, as a swipe would bring it (Arc 1.171, WheelSpaceSwitch). Returns false for a/// wheel the sidebar doesn't take.private func wheelSwitchesSpace(_ event: NSEvent) -> Bool {- let host = shell.sidebarHost- guard shell.sidebarVisible || shell.floatingSidebar, event.window != nil, event.window === host.window,- host.bounds.contains(host.convert(event.locationInWindow, from: nil)), !isStandalone else { return false }+ guard isOverSidebar(event) else { return false }let dx = event.scrollingDeltaX// On the Spaces page the cards scroll first; once they can't scroll that way the wheel pages,// which leaves the Library when it heads for the next space, and over the rail it leaves atdiff --git a/Tests/Scenarios/mouse-buttons-switch-spaces.scenario b/Tests/Scenarios/mouse-buttons-switch-spaces.scenarionew file mode 100644index 0000000..7151f8a--- /dev/null+++ b/Tests/Scenarios/mouse-buttons-switch-spaces.scenario@@ -0,0 +1,23 @@+# promise: #233+# A mouse's back and forward buttons released over the sidebar switch spaces, as in Arc (its+# SidebarView sends focusPreviousSpace for button 3 and focusNextSpace for button 4); over the page+# they are left to Chromium's history back and forward (#233). Each step reads which space the window+# shows (themeShown).+budget rss=600 stalls50=10+seed sidebar.json {"version":1,"spaceOrder":["A0000000-0000-0000-0000-000000000001","A0000000-0000-0000-0000-000000000002"],"spaces":[{"id":"A0000000-0000-0000-0000-000000000001","title":"Home","emoji":"🏠","theme":{"colors":["#8389FF","#8389FF"],"intensity":0.5,"noise":0,"appearance":"light","accent":"#8389FF","solid":true,"key":["#8389FF"]},"favoritesContainerID":"C0000000-0000-0000-0000-000000000011","pinnedContainerID":"C0000000-0000-0000-0000-000000000012","todayContainerID":"C0000000-0000-0000-0000-000000000013","createdAt":"2026-11-06T08:00:00Z"},{"id":"A0000000-0000-0000-0000-000000000002","title":"Work","emoji":"💼","theme":{"colors":["#8389FF","#8389FF"],"intensity":0.5,"noise":0,"appearance":"light","accent":"#8389FF","solid":true,"key":["#8389FF"]},"favoritesContainerID":"C0000000-0000-0000-0000-000000000021","pinnedContainerID":"C0000000-0000-0000-0000-000000000022","todayContainerID":"C0000000-0000-0000-0000-000000000023","createdAt":"2026-11-06T08:00:00Z"}],"items":[{"id":"C0000000-0000-0000-0000-000000000011","children":[],"isUnread":false,"createdAt":"2026-11-06T08:00:00Z","data":{"container":{"_0":{"favorites":{"spaceID":"A0000000-0000-0000-0000-000000000001"}}}}},{"id":"C0000000-0000-0000-0000-000000000012","children":[],"isUnread":false,"createdAt":"2026-11-06T08:00:00Z","data":{"container":{"_0":{"pinned":{"spaceID":"A0000000-0000-0000-0000-000000000001"}}}}},{"id":"C0000000-0000-0000-0000-000000000013","children":[],"isUnread":false,"createdAt":"2026-11-06T08:00:00Z","data":{"container":{"_0":{"today":{"spaceID":"A0000000-0000-0000-0000-000000000001"}}}}},{"id":"C0000000-0000-0000-0000-000000000021","children":[],"isUnread":false,"createdAt":"2026-11-06T08:00:00Z","data":{"container":{"_0":{"favorites":{"spaceID":"A0000000-0000-0000-0000-000000000002"}}}}},{"id":"C0000000-0000-0000-0000-000000000022","children":[],"isUnread":false,"createdAt":"2026-11-06T08:00:00Z","data":{"container":{"_0":{"pinned":{"spaceID":"A0000000-0000-0000-0000-000000000002"}}}}},{"id":"C0000000-0000-0000-0000-000000000023","children":[],"isUnread":false,"createdAt":"2026-11-06T08:00:00Z","data":{"container":{"_0":{"today":{"spaceID":"A0000000-0000-0000-0000-000000000002"}}}}}]}+cra://debug?windowSize=1280x800+wait 2+cra://debug?themeShown=start+expect-log Cra theme shown start: space=Home+cra://debug?clickAt=120,400&button=forward+expect-log Cra: mouse forward at 120,400: switched space+cra://debug?themeShown=forward+expect-log Cra theme shown forward: space=Work+cra://debug?clickAt=120,400&button=back+expect-log Cra: mouse back at 120,400: switched space+cra://debug?themeShown=back+expect-log Cra theme shown back: space=Home+cra://debug?clickAt=800,400&button=forward+expect-log Cra: mouse forward at 800,400: passed on+cra://debug?themeShown=page+expect-log Cra theme shown page: space=Homediff --git a/Tests/promises.lock b/Tests/promises.lockindex 290b2d7..80f6be5 100644--- a/Tests/promises.lock+++ b/Tests/promises.lock@@ -355,3 +355,6 @@#226 Packages/CraCore/Tests/CraCoreTests/ToolbarCompositionTests.swift::theURLFieldHasTheSlidersWithoutExtensions a7173c578717#226 Tests/Scenarios/site-controls-no-extensions.scenario c1c5b5365539#227 Tests/Scenarios/quit-during-web-store-install.scenario a3e3b0c8eb2b+#233 Packages/CraCore/Tests/CraCoreTests/MouseButtonSpaceSwitchTests.swift::backGoesToThePreviousSpaceAndForwardToTheNext 10b4dc8a4a65+#233 Packages/CraCore/Tests/CraCoreTests/MouseButtonSpaceSwitchTests.swift::otherButtonsDoNotSwitch 07b725a8e6f5+#233 Tests/Scenarios/mouse-buttons-switch-spaces.scenario 79148e8b3ebbdiff --git a/docs/arc-reverse-engineering.md b/docs/arc-reverse-engineering.mdindex 38de10d..c6e111e 100644--- a/docs/arc-reverse-engineering.md+++ b/docs/arc-reverse-engineering.md@@ -2733,6 +2733,24 @@ tap with a real Shift key held around them; the space read from each window's `sLibrary in or out like its button. On the Spaces page the cards take the wheel first (10 pt per line, as in Arc)and the wheel leaves the Library only at their end.+## Mouse back and forward buttons (Arc 1.172.1, 7 Nov 2026, issue #233, static: main binary arm64)++Reported on #233: in Arc a mouse's back and forward buttons over the sidebar switch spaces.+- [O static] `Arc.SidebarView` implements `otherMouseUp:` (method list 0x1036918e0, with `hitTest:`, `mouseDown:`,+ `menuForEvent:`; imp 0x100313594 → 0x1003134a0). Behind a Bool stored property being true (not identified),+ `buttonNumber` 3 sends the spaces reducer's empty case 3 and 4 sends case 2. That enum's empty cases, in order+ (`__swift5_fieldmd`): `didTriggerCreateSpaceGesture`, `didTapCreateSpaceButton`, `focusNextSpace`,+ `focusPreviousSpace`, `iconPickerWillClose`. So back (3) = `focusPreviousSpace`, forward (4) = `focusNextSpace`, on+ the button's release; the press does nothing there. No `otherMouseUp:` on the page, where Chromium's own+ back/forward runs.+- [O static] NSEvent helpers next to `PageSwipeController` (0x100a0d608…0x100a0d6b8): `otherMouseDown` with button+ 2, `otherMouseUp` with button 3 and with button 4.+- [U] Whether `focusNextSpace` wraps at the last space or opens the Library before the first; what the Bool gate is.+ Not checked live (Victor was using the Mac).+- Cra: `MouseButtonSpaceSwitch` (CraCore) maps 3 → −1 and 4 → +1. The window's `otherMouseUp` monitor, over the+ sidebar (docked or floating, not a Little Window), calls `focusSpace(offset:)` like Spaces ▸ Previous/Next Space+ (which wrap) and swallows the event; anywhere else the event goes on. Scenario `mouse-buttons-switch-spaces`.+### Extension action icons, badges and tooltips (Arc 1.171, 2 Nov 2026, issue #106, offline Arc + probe)- [O live] Offline Arc (fake home with the Storable*.json files minus both sync states, `--load-extension` witha probe, pinned through the fake profile's `extensions.pinned_extensions`). Probe: red top-level `icons`, bluediff --git a/docs/release-checklist.md b/docs/release-checklist.mdindex d32dcaa..a7f1e4d 100644--- a/docs/release-checklist.md+++ b/docs/release-checklist.md@@ -41,6 +41,10 @@ built release app with a test profile. Note anything that fails in the release's- **#7:** click a tab while moving the pointer a few points on a trackpad. It opens.- **#3, #208:** a middle click on a sidebar tab row closes it; one in a page never does. ⇧⌘Jopens Downloads in the sidebar; Esc or the back arrow closes the Library.+- **#233:** with a real mouse, its back button over the sidebar goes to the previous space and+ forward to the next, docked and in the hidden sidebar (⌘S); over a page they still go back and+ forward in the tab's history. The scenario hands the button to the window's handler, so only a+ real mouse proves the monitor sees it.- **#12:** a two-finger swipe in the hidden sidebar (⌘S) switches spaces, and the next spacedraws mid-swipe. There is one link bubble only, and the dashed ring shows only on across-space keyboard switch.