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.

Peek and Little Window bars take clicks, Capture scrolls, ⌥⌘N from any app (#195)

Victor25d236a9682f
diff --git a/Packages/CraCore/Sources/CraCore/GlobalShortcut.swift b/Packages/CraCore/Sources/CraCore/GlobalShortcut.swift
new file mode 100644
index 0000000..fb7b122
--- /dev/null
+++ b/Packages/CraCore/Sources/CraCore/GlobalShortcut.swift
@@ -0,0 +1,30 @@
+import Foundation
+
+/// A shortcut that works while another app is in front: Arc's "Open Little Arc when I press ⌥⌘N"
+/// (globalLittleBrowserHotkeyEnabled, GitHub #195). macOS takes it from every app, so only a chord
+/// with ⌘, ⌃ or ⌥ qualifies: a lone key or ⇧ and a key would stop that key typing anywhere.
+public enum GlobalShortcut {
+ /// Carbon's modifier bits for RegisterEventHotKey (cmdKey, shiftKey, optionKey, controlKey).
+ public static let carbonCommand: UInt32 = 1 << 8
+ public static let carbonShift: UInt32 = 1 << 9
+ public static let carbonOption: UInt32 = 1 << 11
+ public static let carbonControl: UInt32 = 1 << 12
+
+ /// The chord to register, or nil when there is none to take from other apps.
+ public static func registrable(_ chords: [KeyChord], enabled: Bool) -> KeyChord? {
+ guard enabled else { return nil }
+ return chords.first { chord in
+ !chord.key.isEmpty && !chord.keys.intersection([.command, .control, .option]).isEmpty
+ }
+ }
+
+ /// NSEvent-style modifier bits (KeyChord.Modifiers) as Carbon's.
+ public static func carbonModifiers(_ modifiers: KeyChord.Modifiers) -> UInt32 {
+ var out: UInt32 = 0
+ if modifiers.contains(.command) { out |= carbonCommand }
+ if modifiers.contains(.shift) { out |= carbonShift }
+ if modifiers.contains(.option) { out |= carbonOption }
+ if modifiers.contains(.control) { out |= carbonControl }
+ return out
+ }
+}
diff --git a/Packages/CraCore/Sources/CraCore/SidebarModel.swift b/Packages/CraCore/Sources/CraCore/SidebarModel.swift
index 988a2db..ee80e98 100644
--- a/Packages/CraCore/Sources/CraCore/SidebarModel.swift
+++ b/Packages/CraCore/Sources/CraCore/SidebarModel.swift
@@ -475,6 +475,9 @@ public struct AppSettings: Codable, Equatable {
/// Arc's "Open a Peek window when clicking on links with Shift held"
/// (shiftClickModalEntryPointEnabled).
public var peekOnShiftClick: Bool = true
+ /// Arc's "Open Little Arc when I press ⌥⌘N" (globalLittleBrowserHotkeyEnabled, on by default):
+ /// New Little Window's shortcut works from every app, full-screen ones too (GitHub #195).
+ public var littleWindowShortcutEverywhere: Bool = true
/// GitHub #183, not in Arc (Chrome's way): a page's "Open Link in New Tab" leaves the page in
/// front and the new tab loading behind it (LinkMenu). Off like Arc, which switches to it.
public var openLinksInBackground: Bool = false
@@ -684,6 +687,7 @@ extension AppSettings {
peekLinksToOtherSites = try c.decodeIfPresent(Bool.self, forKey: .peekLinksToOtherSites) ?? true
peekInEveryTab = try c.decodeIfPresent(Bool.self, forKey: .peekInEveryTab) ?? false
peekOnShiftClick = try c.decodeIfPresent(Bool.self, forKey: .peekOnShiftClick) ?? true
+ littleWindowShortcutEverywhere = try c.decodeIfPresent(Bool.self, forKey: .littleWindowShortcutEverywhere) ?? true
openLinksInBackground = try c.decodeIfPresent(Bool.self, forKey: .openLinksInBackground) ?? false
folderPreviews = try c.decodeIfPresent(Bool.self, forKey: .folderPreviews) ?? true
hapticFeedbackOnReorder = try c.decodeIfPresent(Bool.self, forKey: .hapticFeedbackOnReorder) ?? true
diff --git a/Packages/CraCore/Tests/CraCoreTests/GlobalShortcutTests.swift b/Packages/CraCore/Tests/CraCoreTests/GlobalShortcutTests.swift
new file mode 100644
index 0000000..566b699
--- /dev/null
+++ b/Packages/CraCore/Tests/CraCoreTests/GlobalShortcutTests.swift
@@ -0,0 +1,30 @@
+import CraCore
+import Testing
+
+/// New Little Window's shortcut from any app (Arc's "Open Little Arc when I press ⌥⌘N", GitHub #195).
+struct GlobalShortcutTests {
+ private let optCmdN = KeyChord(key: "n", modifiers: KeyChord.Modifiers([.option, .command]).rawValue)
+
+ @Test func theFirstChordIsTakenWhileTheSettingIsOn() {
+ #expect(GlobalShortcut.registrable([optCmdN], enabled: true) == optCmdN)
+ #expect(GlobalShortcut.registrable([optCmdN], enabled: false) == nil)
+ #expect(GlobalShortcut.registrable([], enabled: true) == nil)
+ }
+
+ /// A key without ⌘, ⌃ or ⌥ would stop typing that key in every app.
+ @Test func aChordThatTypesIsNeverTakenFromOtherApps() {
+ let shiftN = KeyChord(key: "n", modifiers: KeyChord.Modifiers.shift.rawValue)
+ let tab = KeyChord(key: KeyChord.tab, modifiers: 0)
+ #expect(GlobalShortcut.registrable([shiftN, tab], enabled: true) == nil)
+ #expect(GlobalShortcut.registrable([shiftN, optCmdN], enabled: true) == optCmdN)
+ let ctrlSpace = KeyChord(key: " ", modifiers: KeyChord.Modifiers.control.rawValue)
+ #expect(GlobalShortcut.registrable([ctrlSpace], enabled: true) == ctrlSpace)
+ }
+
+ /// Carbon's cmdKey 0x100, shiftKey 0x200, optionKey 0x800, controlKey 0x1000.
+ @Test func modifiersInCarbonBits() {
+ #expect(GlobalShortcut.carbonModifiers([.option, .command]) == 0x900)
+ #expect(GlobalShortcut.carbonModifiers([.shift, .control]) == 0x1200)
+ #expect(GlobalShortcut.carbonModifiers([]) == 0)
+ }
+}
diff --git a/Sources/Cra/App/AppDelegate.swift b/Sources/Cra/App/AppDelegate.swift
index 25b630f..eb6802e 100644
--- a/Sources/Cra/App/AppDelegate.swift
+++ b/Sources/Cra/App/AppDelegate.swift
@@ -1,4 +1,5 @@
import AppKit
+import Carbon.HIToolbox
import CraCEF
import SwiftUI
@@ -50,6 +51,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
CraCEFRuntime.setOwnContextMenus(EmbeddedPages.isEnabled)
CraCEFRuntime.setDocumentStartScript(PageScript.mainWorld, isolatedScript: PageScript.isolatedWorld, world: PageScript.world)
startContentBlocking()
+ observeGlobalShortcut()
SoftwareUpdater.shared.start(app: self)
buildMenus()
store.hasPage = { [unowned self] in self.runtime(for: $0).map { !$0.discarded } ?? false }
@@ -241,6 +243,29 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
}
}
+ /// Arc's "Open Little Arc when I press ⌥⌘N" (#195): New Little Window's shortcut from any app,
+ /// following the setting, the shortcut's binding and the keyboard layout. A test copy in the
+ /// background leaves the shortcut to the installed Cra.
+ private func observeGlobalShortcut() {
+ guard !HitchMonitor.background else { return }
+ let hotkey = GlobalHotkey { [weak self] in self?.perform("newLittleWindow") }
+ globalHotkey = hotkey
+ let chord = { [store, bindings] in
+ GlobalShortcut.registrable(bindings.action("newLittleWindow")?.shortcuts ?? [], enabled: store.settings.littleWindowShortcutEverywhere)
+ }
+ observeChanges(of: chord) { hotkey.set($0) }
+ // The same chord on another layout can be another key.
+ DistributedNotificationCenter.default().addObserver(forName: NSNotification.Name(kTISNotifySelectedKeyboardInputSourceChanged as String),
+ object: nil, queue: .main) { _ in
+ MainActor.assumeIsolated {
+ hotkey.set(nil)
+ hotkey.set(chord())
+ }
+ }
+ }
+
+ private var globalHotkey: GlobalHotkey?
+
private func observeContentBlocking() {
observeChanges(of: { [store] in store.settings.blockAdsAndTrackers }, apply: CraCEFRuntime.setContentBlockingEnabled)
}
@@ -624,6 +649,13 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
TestGesture.openMenu(at: NSPoint(x: g[0], y: w.frame.height - g[1]), in: w, right: dict["button"] == "right")
return
}
+ // clickAt=x,y: a click there through the event queue, as the pointer's would go (#195);
+ // target=little as for menuAt.
+ 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)
+ return
+ }
if let st = dict["status"] { main.browserManager(statusMessage: st); return }
// tidy: the divider's Tidy on the window's space, without hovering it; undoTidy: ⌘Z's.
if dict["tidy"] != nil { TidyTabsService.shared.tidy(store.focusedSpace(window: main.windowID).id, store: store); return }
diff --git a/Sources/Cra/Services/GlobalHotkey.swift b/Sources/Cra/Services/GlobalHotkey.swift
new file mode 100644
index 0000000..20125cd
--- /dev/null
+++ b/Sources/Cra/Services/GlobalHotkey.swift
@@ -0,0 +1,79 @@
+import AppKit
+import Carbon.HIToolbox
+
+/// Arc's "Open Little Arc when I press ⌥⌘N" (GitHub #195): New Little Window's shortcut works
+/// from every app, full-screen ones included, while the setting is on. A Carbon hot key, as Arc's
+/// GlobalHotkeyManager uses: it needs no Accessibility permission and sees no other key presses.
+/// While Cra is in front the hot key takes the press before the menu does; both open a Little Window.
+@MainActor
+final class GlobalHotkey {
+ private let run: () -> Void
+ private var ref: EventHotKeyRef?
+ private var handler: EventHandlerRef?
+ private var registered: (chord: KeyChord, code: UInt32)?
+ private static let signature: OSType = 0x4352_4C57 // "CRLW"
+
+ init(run: @escaping () -> Void) {
+ self.run = run
+ var spec = EventTypeSpec(eventClass: OSType(kEventClassKeyboard), eventKind: UInt32(kEventHotKeyPressed))
+ let me = Unmanaged.passUnretained(self).toOpaque()
+ InstallEventHandler(GetApplicationEventTarget(), { _, event, context in
+ guard let event, let context else { return OSStatus(eventNotHandledErr) }
+ var id = EventHotKeyID()
+ GetEventParameter(event, EventParamName(kEventParamDirectObject), EventParamType(typeEventHotKeyID), nil,
+ MemoryLayout<EventHotKeyID>.size, nil, &id)
+ guard id.signature == GlobalHotkey.signature else { return OSStatus(eventNotHandledErr) }
+ let hotkey = Unmanaged<GlobalHotkey>.fromOpaque(context).takeUnretainedValue()
+ MainActor.assumeIsolated { hotkey.run() }
+ return noErr
+ }, 1, &spec, me, &handler)
+ }
+
+ /// Registers `chord` (nil: none), replacing what was registered.
+ func set(_ chord: KeyChord?) {
+ let code = chord.flatMap(Self.keyCode(for:))
+ if let registered, let chord, let code, registered.chord == chord, registered.code == code { return }
+ if let ref { UnregisterEventHotKey(ref) }
+ ref = nil
+ registered = nil
+ guard let chord, let code else { return }
+ var newRef: EventHotKeyRef?
+ let status = RegisterEventHotKey(code, GlobalShortcut.carbonModifiers(chord.keys), EventHotKeyID(signature: Self.signature, id: 1),
+ GetApplicationEventTarget(), 0, &newRef)
+ guard status == noErr, let newRef else {
+ CraLog.note("global shortcut: \(chord.display) not registered (\(status))")
+ return
+ }
+ ref = newRef
+ registered = (chord, code)
+ }
+
+ /// The key that types `chord.key` on the current keyboard layout (Carbon hot keys take key
+ /// codes): Danish ⌥⌘N is the same key as US, but a Dvorak "n" is not.
+ static func keyCode(for chord: KeyChord) -> UInt32? {
+ let special: [String: Int] = [Shortcut.tab: kVK_Tab, Shortcut.left: kVK_LeftArrow, Shortcut.right: kVK_RightArrow,
+ Shortcut.up: kVK_UpArrow, Shortcut.down: kVK_DownArrow, Shortcut.delete: kVK_Delete]
+ if let code = special[chord.key] { return UInt32(code) }
+ if let scalar = chord.key.unicodeScalars.first, chord.key.unicodeScalars.count == 1, (0xF704...0xF70F).contains(scalar.value) {
+ let fKeys = [kVK_F1, kVK_F2, kVK_F3, kVK_F4, kVK_F5, kVK_F6, kVK_F7, kVK_F8, kVK_F9, kVK_F10, kVK_F11, kVK_F12]
+ let i = Int(scalar.value - 0xF704)
+ return i < fKeys.count ? UInt32(fKeys[i]) : nil
+ }
+ guard let source = TISCopyCurrentKeyboardLayoutInputSource()?.takeRetainedValue(),
+ let data = TISGetInputSourceProperty(source, kTISPropertyUnicodeKeyLayoutData) else { return nil }
+ let layout = Unmanaged<CFData>.fromOpaque(data).takeUnretainedValue() as Data
+ return layout.withUnsafeBytes { raw -> UInt32? in
+ guard let base = raw.baseAddress?.assumingMemoryBound(to: UCKeyboardLayout.self) else { return nil }
+ for code in 0..<UInt16(128) {
+ var dead: UInt32 = 0
+ var chars = [UniChar](repeating: 0, count: 4)
+ var length = 0
+ let status = UCKeyTranslate(base, code, UInt16(kUCKeyActionDown), 0, UInt32(LMGetKbdType()),
+ OptionBits(kUCKeyTranslateNoDeadKeysBit), &dead, chars.count, &length, &chars)
+ guard status == noErr, length > 0 else { continue }
+ if String(utf16CodeUnits: chars, count: length).lowercased() == chord.key { return UInt32(code) }
+ }
+ return nil
+ }
+ }
+}
diff --git a/Sources/Cra/Services/TestGesture.swift b/Sources/Cra/Services/TestGesture.swift
index 61d6a1e..276c2ae 100644
--- a/Sources/Cra/Services/TestGesture.swift
+++ b/Sources/Cra/Services/TestGesture.swift
@@ -19,6 +19,18 @@ enum TestGesture {
}
}
+ /// A click at a point of the window, through the app's event queue: AppKit routes it as it
+ /// routes the pointer's (the window's sendEvent, first-click rules, hit testing), so a test
+ /// sees what a real click there does, while the pointer and the front app stay put.
+ static func click(at point: NSPoint, in window: NSWindow) {
+ for (type, pressure) in [(NSEvent.EventType.leftMouseDown, Float(1)), (.leftMouseUp, 0)] {
+ guard let e = NSEvent.mouseEvent(with: type, location: point, modifierFlags: [], timestamp: ProcessInfo.processInfo.systemUptime,
+ windowNumber: window.windowNumber, context: nil, eventNumber: 0, clickCount: 1,
+ pressure: pressure) else { return }
+ NSApp.postEvent(e, atStart: false)
+ }
+ }
+
/// Opens the menu a click (or a right-click) at a point of the window would open, without
/// the pointer: the hit view gets the mouse-down, or the nearest view with a menu(for:)
/// pops its menu. The menu tracks until Esc or a pick, so tests read it through AX.
diff --git a/Sources/Cra/UI/Settings/TabsPane.swift b/Sources/Cra/UI/Settings/TabsPane.swift
index 3019435..bdb9b0c 100644
--- a/Sources/Cra/UI/Settings/TabsPane.swift
+++ b/Sources/Cra/UI/Settings/TabsPane.swift
@@ -35,6 +35,9 @@ struct TabsPane: View {
// Arc." with an "Air Traffic Control…" button.
SettingsFormRow(label: "Links:") {
SettingsCheckbox(title: "Links from other apps open in a Little Window", isOn: $store.settings.openExternalLinksInLittleWindow)
+ // Arc's "Open Little Arc when I press ⌥⌘N" (#195): New Little Window's shortcut from any app.
+ SettingsCheckbox(title: "Open a Little Window when I press \(KeyBindingRegistry.shared.action("newLittleWindow")?.primary?.display ?? "⌥⌘N") in any app",
+ isOn: $store.settings.littleWindowShortcutEverywhere)
SettingsCheckbox(title: "Open a Peek window when clicking on links to other sites", isOn: $store.settings.peekLinksToOtherSites)
SettingsCheckbox(title: "In every tab, not only Favorites and Pinned tabs", isOn: $store.settings.peekInEveryTab)
.disabled(!store.settings.peekLinksToOtherSites)
diff --git a/Sources/Cra/UI/Windows/CaptureOverlay.swift b/Sources/Cra/UI/Windows/CaptureOverlay.swift
index 18e685d..dd1f6eb 100644
--- a/Sources/Cra/UI/Windows/CaptureOverlay.swift
+++ b/Sources/Cra/UI/Windows/CaptureOverlay.swift
@@ -113,7 +113,8 @@ final class CaptureView: NSView {
enum Mode { case selecting, dragging(start: CGPoint), captured(CGRect) }
var finish: ((CaptureOverlay.Action?, Data?) -> Void)?
- private let shot: CGImage
+ /// The page as shown: taken again while it scrolls under the mode (#195).
+ private var shot: CGImage
private weak var browser: CraBrowser?
private let scale: CGFloat
private var mode: Mode = .selecting
@@ -143,6 +144,13 @@ final class CaptureView: NSView {
private var pendingProbe: CGPoint?
private var pointer: CGPoint?
+ // Scrolling under the mode (#195): the page's devicePixelRatio (its zoom times the display's
+ // scale), and one new picture at a time, the latest wish waiting.
+ private var pageRatio: CGFloat?
+ private var refreshing = false
+ private var refreshAgain = false
+ private var settleRefresh: DispatchWorkItem?
+
/// While a choice made in the menu is being carried out, losing the keys isn't a cancel.
private(set) var isSettled = true
@@ -198,6 +206,11 @@ final class CaptureView: NSView {
override func acceptsFirstMouse(for event: NSEvent?) -> Bool { true }
func start() {
+ browser?.evaluate(inIsolatedWorld: PageScript.world, params: #"{"expression":"devicePixelRatio","returnByValue":true}"#) { [weak self] result, _ in
+ let ratio = result.flatMap { try? JSONSerialization.jsonObject(with: Data($0.utf8)) as? [String: Any] }
+ .flatMap { ($0["result"] as? [String: Any])?["value"] as? Double }
+ DispatchQueue.main.async { if let ratio, ratio > 0 { self?.pageRatio = ratio } }
+ }
addTrackingArea(NSTrackingArea(rect: .zero, options: [.mouseMoved, .activeAlways, .inVisibleRect, .cursorUpdate, .mouseEnteredAndExited], owner: self))
bubble.appear()
if let p = window?.mouseLocationOutsideOfEventStream, bounds.contains(convert(p, from: nil)) {
@@ -209,6 +222,8 @@ final class CaptureView: NSView {
func stop() {
link?.invalidate()
link = nil
+ settleRefresh?.cancel()
+ settleRefresh = nil
}
/// Greyscale by Rec. 601 luma in the image's own (gamma) values, times `CaptureStyle.dim`, which
@@ -305,7 +320,61 @@ final class CaptureView: NSView {
}
}
- override func scrollWheel(with event: NSEvent) {}
+ // MARK: Scrolling
+
+ /// Arc scrolls the page under the mode: the wheel goes to the page, as a wheel over it would,
+ /// and the picture is taken again as it moves (#195). Not while dragging or once captured.
+ override func scrollWheel(with event: NSEvent) {
+ guard case .selecting = mode, let browser, browser.isCreated, !browser.isClosed else { return }
+ let p = convert(event.locationInWindow, from: nil)
+ // Points to CSS pixels: the page's zoom is its devicePixelRatio over the display's scale.
+ let css = scale / (pageRatio ?? scale)
+ // A wheel's lines are Chrome's 40 px each; a trackpad's deltas are points.
+ let line: CGFloat = event.hasPreciseScrollingDeltas ? 1 : 40
+ let dx = -event.scrollingDeltaX * line * css, dy = -event.scrollingDeltaY * line * css
+ guard dx != 0 || dy != 0 else { return }
+ let params: [String: Any] = ["type": "mouseWheel", "x": p.x * css, "y": p.y * css, "deltaX": dx, "deltaY": dy, "pointerType": "mouse"]
+ guard let json = (try? JSONSerialization.data(withJSONObject: params)).flatMap({ String(data: $0, encoding: .utf8) }) else { return }
+ browser.sendDevToolsMethod("Input.dispatchMouseEvent", params: json) { [weak self] _, _ in
+ DispatchQueue.main.async { self?.refreshShot() }
+ }
+ // Smooth scrolling and momentum keep the page moving after the last event.
+ settleRefresh?.cancel()
+ let settle = DispatchWorkItem { [weak self] in self?.refreshShot() }
+ settleRefresh = settle
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.25, execute: settle)
+ }
+
+ /// A new picture of the page for the grey page, the lens and the capture.
+ private func refreshShot() {
+ guard let browser, browser.isCreated, !browser.isClosed, case .selecting = mode else { return }
+ if refreshing { refreshAgain = true; return }
+ refreshing = true
+ browser.sendDevToolsMethod("Page.captureScreenshot", params: #"{"format":"png","captureBeyondViewport":false,"optimizeForSpeed":true}"#) { [weak self] shot, _ in
+ DispatchQueue.main.async {
+ guard let self else { return }
+ self.refreshing = false
+ if case .selecting = self.mode, let image = MainWindowController.screenshotImage(shot) { self.show(image) }
+ if self.refreshAgain {
+ self.refreshAgain = false
+ self.refreshShot()
+ }
+ }
+ }
+ }
+
+ private func show(_ image: CGImage) {
+ shot = image
+ let grey = Self.dimmed(image)
+ CATransaction.begin()
+ CATransaction.setDisableActions(true)
+ colourLayer.contents = image
+ greyFull.contents = grey
+ greyHoled.contents = grey
+ CATransaction.commit()
+ // What is under the pointer moved with the page.
+ if let pointer { probe(pointer) }
+ }
// MARK: Keys
diff --git a/Sources/Cra/UI/Windows/LittleWindowController.swift b/Sources/Cra/UI/Windows/LittleWindowController.swift
index 267f5b8..adb33f5 100644
--- a/Sources/Cra/UI/Windows/LittleWindowController.swift
+++ b/Sources/Cra/UI/Windows/LittleWindowController.swift
@@ -1280,6 +1280,14 @@ final class LittleWindow: NSPanel {
[.leftMouseDown, .rightMouseDown, .otherMouseDown].contains(event.type) {
NSApp.activate(ignoringOtherApps: true)
}
+ // The page is a Chromium child window. With it key, a press on the bar reached the button
+ // but its release never came, so Back, Forward, Refresh, the address and "Open in" did
+ // nothing (GitHub #195). The browser window makes the window under a click key first for
+ // its own children (MainWindowController.installChildClickMonitor); this window does too.
+ if [.leftMouseDown, .rightMouseDown, .otherMouseDown].contains(event.type), !isKeyWindow, canBecomeKey,
+ NSApp.isActive, NSApp.keyWindow?.parent === self {
+ makeKey()
+ }
super.sendEvent(event)
}
diff --git a/Sources/Cra/UI/Windows/MainWindowController.swift b/Sources/Cra/UI/Windows/MainWindowController.swift
index 86695c3..116995e 100644
--- a/Sources/Cra/UI/Windows/MainWindowController.swift
+++ b/Sources/Cra/UI/Windows/MainWindowController.swift
@@ -1605,7 +1605,7 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
return w.convertToScreen(view.convert(view.bounds, to: nil))
}
- private static func screenshotImage(_ shot: String?) -> CGImage? {
+ static func screenshotImage(_ shot: String?) -> CGImage? {
guard let shot, let o = try? JSONSerialization.jsonObject(with: Data(shot.utf8)) as? [String: Any],
let b64 = o["data"] as? String, let png = Data(base64Encoded: b64),
let source = CGImageSourceCreateWithData(png as CFData, nil) else { return nil }
diff --git a/docs/arc-reverse-engineering.md b/docs/arc-reverse-engineering.md
index 0df0a6b..1b05b27 100644
--- a/docs/arc-reverse-engineering.md
+++ b/docs/arc-reverse-engineering.md
@@ -3141,3 +3141,24 @@ Arc Max's renameDownloads: a finished download is renamed on disk and a card abo
- [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.
+
+## Little Arc's ⌥⌘N from any app, Capture scrolling, and clicks on a Peek's bar (Arc 1.171, 5 Nov 2026, issue #195)
+
+- [O strings] Arc registers Little Arc's shortcut as a system-wide hot key: `GlobalHotkeyListenerClient.registerLittleBrowserShortcut`,
+ a Carbon `RegisterEventHotKey` (`EventHotKeyID`, "Failed to register hotkey."), behind the setting
+ `globalLittleBrowserHotkeyEnabled` ("Open Little Arc when I press ⌥⌘N", `onToggleGlobalLittleBrowserHotkey`). It is on by
+ default (not in Victor's defaults; Arc's help and guides say ⌥⌘N works from any app). Cra: GlobalHotkey (Carbon, no
+ Accessibility permission) registers New Little Window's binding while Settings ▸ Tabs ▸ Links "Open a Little Window when I
+ press ⌥⌘N in any app" is on (GlobalShortcut in CraCore: only chords with ⌘, ⌃ or ⌥). A background test copy registers none.
+ Checked in a test copy: ⌥⌘N with VS Code in front opened an empty Little Window with its command bar.
+- [reporter] Arc's Capture lets the page scroll under it. Cra's draws over a picture of the page, so while choosing it now
+ sends the wheel to the page (`Input.dispatchMouseEvent` mouseWheel, points to CSS pixels by the page's devicePixelRatio,
+ 40 px per wheel line) and takes the picture again as it moves (one at a time, and once more 0.25 s after the last event for
+ smooth scrolling and momentum). Checked: 25 HID wheel steps scrolled a long page 1000 px with the mode on, the grey picture
+ following. WebKit pages don't scroll under it (no Input domain there).
+- [O, Cra test copy] Why a Peek's Back, Forward and Refresh (and Little Window's strip) did nothing: the page is a Chromium child
+ window of the Little Window. With it key, a HID press on the bar reached the button but the release never reached the app (no
+ local monitor saw it), and the buttons act on the release. The main window avoids this for its own children by making the
+ window under a press key first (installChildClickMonitor), but a Peek's page is a grandchild of the browser window, and a
+ Little Window has no such monitor. LittleWindow.sendEvent now does the same for its children. A press while the browser
+ window itself was key always worked (its monitor made the Peek key), which is why it looked intermittent.