diff --git a/Sources/MWBMac/Permissions.swift b/Sources/MWBMac/Permissions.swift index 860ae65..7e2c8b4 100644 --- a/Sources/MWBMac/Permissions.swift +++ b/Sources/MWBMac/Permissions.swift @@ -23,6 +23,17 @@ public struct PermissionState: Equatable, Sendable { /// Accessibility granted. public let post: Bool + /// A state with both grants named explicitly. + /// + /// Public so another target can build one without asking TCC: a menu bar or + /// a snapshot needs a "nothing granted yet" value before `preflight()` has + /// ever run, and `preflight()` is a system query, not a constructor + /// (app-engine request 1, authorised by the lead). + public init(listen: Bool, post: Bool) { + self.listen = listen + self.post = post + } + /// True when both permissions are granted. public var isComplete: Bool { listen && post } } diff --git a/Sources/mwb/Engine.swift b/Sources/mwb/Engine.swift index 42d3164..077ed3a 100644 --- a/Sources/mwb/Engine.swift +++ b/Sources/mwb/Engine.swift @@ -62,8 +62,9 @@ public struct EngineSnapshot: Sendable { public var controlled: String? /// Whether ALL-machines mode is on. public var broadcasting = false - /// Input Monitoring / Accessibility as macOS reports them. - public var permissions = Permissions.preflight() + /// Input Monitoring / Accessibility as macOS reports them. The default is + /// "neither", not a `preflight()`: building a snapshot must not query TCC. + public var permissions = PermissionState(listen: false, post: false) /// Whether the event tap is installed. public var tapRunning = false /// False when the process could not make a `CGEventSource`, so nothing this diff --git a/docs/features/input-capture/README.md b/docs/features/input-capture/README.md index bbffc5d..e8edf67 100644 --- a/docs/features/input-capture/README.md +++ b/docs/features/input-capture/README.md @@ -300,7 +300,8 @@ public final class Cursor: Sendable { var isDecoupled: Bool { get } func restoreEverything() // atexit / signal handler } -public struct PermissionState: Equatable, Sendable { let listen, post: Bool; var isComplete: Bool } +public struct PermissionState: Equatable, Sendable { public init(listen: Bool, post: Bool) + let listen, post: Bool; var isComplete: Bool } public enum Permissions { static let healthCheckInterval: TimeInterval // 5 static func preflight() -> PermissionState