input-capture: public init for PermissionState (app-engine request 1)
Cross-lane edit, authorised by the lead. The struct declared two public lets and no init, so the memberwise one was internal and no other target could build a value — `EngineSnapshot.permissions` had to default to `Permissions.preflight()`, i.e. a TCC query, just to have a value to hold. The default is now `PermissionState(listen: false, post: false)`, which is also the honest value before `start()` has read anything. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
1 parent
8125cb1ede
commit
76d1053aaf
3 files changed
+16
-3
No files matched your search
@@ -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 }
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user