public import CoreGraphics public enum SpaceKind: Int, Codable, Sendable { case desktop = 0 case system = 2 case fullscreen = 4 } public struct NativeSpace: Equatable, Codable, Sendable { public let id: UInt64 public let kind: SpaceKind public let desktopNumber: Int? public init(id: UInt64, kind: SpaceKind, desktopNumber: Int? = nil) { self.id = id self.kind = kind self.desktopNumber = desktopNumber } } public struct NativeDisplaySpaces: Equatable, Codable, Sendable { public let displayID: String public let currentSpace: UInt64 public let spaces: [NativeSpace] public init(displayID: String, currentSpace: UInt64, spaces: [NativeSpace]) { self.displayID = displayID self.currentSpace = currentSpace self.spaces = spaces } } public enum SpaceDestination: Equatable, Sendable { case desktop(Int) case next case previous case backAndForth } public struct SpaceDragWindow: Equatable, Sendable { public let id: CGWindowID public let titleBar: CGRect public let isFullscreen: Bool public init(id: CGWindowID, titleBar: CGRect, isFullscreen: Bool) { self.id = id self.titleBar = titleBar self.isFullscreen = isFullscreen } } public protocol SpaceReading: Sendable { func snapshot() async throws -> [NativeDisplaySpaces] func spaces(for window: CGWindowID) async throws -> [UInt64] func stageManagerEnabled() async throws -> Bool } public protocol SpaceHotKeyReading: Sendable { func read() throws -> [SymbolicHotKey] } public struct SystemSpaceHotKeys: SpaceHotKeyReading { public init() {} public func read() throws -> [SymbolicHotKey] { try SymbolicHotKeys.read() } } public enum SpaceMouseEvent: Equatable, Sendable { case down(CGPoint) case drag(CGPoint) case up(CGPoint) } public protocol SpaceEventPosting: Sendable { func prepare() throws func validateTarget(_ window: CGWindowID, at point: CGPoint) throws func hotKey(_ key: HotKey) throws func mouse(_ event: SpaceMouseEvent) throws func windowFrame(_ window: CGWindowID) throws -> CGRect func cursorPosition() throws -> CGPoint func restoreCursor(_ point: CGPoint) throws } public struct SpaceCommandResult: Equatable, Sendable { public let displayID: String public let source: UInt64 public let destination: UInt64 public let followed: Bool public let verificationSamples: Int public init(displayID: String, source: UInt64, destination: UInt64, followed: Bool, verificationSamples: Int) { self.displayID = displayID self.source = source self.destination = destination self.followed = followed self.verificationSamples = verificationSamples } } public enum SpaceCommandError: Error, Equatable, Sendable { case busy case inputBusy case pointerBusy case displayUnavailable case desktopUnavailable(Int) case noAdjacentSpace case noPreviousSpace case shortcutDisabled(SpaceShortcutAction) case shortcutUnbound(SpaceShortcutAction) case fullscreen case stageManager case titleBarUnavailable case windowUnavailable case dragNotVerified case switchNotVerified case moveNotVerified case returnNotVerified case malformedSnapshot case symbolUnavailable(String) case cleanupFailed(operation: String, cleanup: String) }