Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546import Foundationimport ParcelPlatform
@MainActorfunc checkNativeFocusMakePrimary(_ session: RealitySession) async throws { try TabViewConsoleSession.requireUnlockedConsole() try requireUncontestedDefaultShortcuts(voiceOverEnabled: VoiceOverStatus.isRunning) try session.configure(layout: "side") let owned = try await session.startingWindows([.textEdit, .textEdit, .textEdit]) try await session.start() try await session.tiles(owned)
for useShortcut in [false, true] { let before = try session.readFrames(owned) let primaryIndex = try NativeFocusFrameOracle.primaryIndex(in: before) guard let selectedIndex = before.indices.first(where: { $0 != primaryIndex }) else { throw RealityError("Native focus promotion needs a primary and a secondary real window") } let targets = try NativeFocusFrameOracle.promotedFrames(before, selecting: selectedIndex) let selected = owned[selectedIndex] let primary = owned[primaryIndex] let stale = owned.first { $0.id != selected.id && $0.id != primary.id } guard let stale else { throw RealityError("Native focus promotion needs a distinct stale selection") }
try await session.apps.focus(stale) try await session.apps.focus(selected) try await session.expect("Native focus selects \(selected.id) without moving any real frames") { try RealApps.focusedID($0) == selected.id && FrameOracle.frames($0, ids: owned.map(\.id)) == before } // Native CG focus is the only barrier; do not wait for Parcel's asynchronous focus snapshot. if useShortcut { try requireUncontestedDefaultShortcuts(voiceOverEnabled: VoiceOverStatus.isRunning) try await session.driver.key(RealityInputDefaults.binding(.makePrimary)) } else { try await session.command("make-primary") } try await session.expect( "\(useShortcut ? "Default shortcut" : "IPC command") promotes natively focused \(selected.id)" ) { let frames = try FrameOracle.frames($0, ids: owned.map(\.id)) return zip(frames, targets).allSatisfy { $0.matches($1) } && RealApps.focusedID($0) == selected.id } }}