File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -131,8 +131,6 @@ final class LoopManager {
131131 )
132132
133133 func start( ) {
134- multitouchTrigger. prepare ( )
135-
136134 accessibilityCheckerTask = Task ( priority: . background) { [ weak self] in
137135 for await status in AccessibilityManager . shared. stream ( initial: true ) {
138136 guard let self, !Task. isCancelled else {
Original file line number Diff line number Diff line change @@ -18,8 +18,14 @@ final class MultitouchGestureBlocker {
1818 private var activeCount : Int = 0
1919
2020 func start( ) {
21- activeCount += 1
22- guard monitor == nil else { return }
21+ if let monitor, monitor. isEnabled {
22+ activeCount += 1
23+ return
24+ }
25+
26+ monitor? . stop ( )
27+ monitor = nil
28+ activeCount = 0
2329
2430 log. info ( " Starting gesture blocker " )
2531
@@ -32,11 +38,22 @@ final class MultitouchGestureBlocker {
3238 CGEventType ( rawValue: UInt32 ( NSEvent . EventType. smartMagnify. rawValue) )
3339 ] . compactMap ( \. self)
3440
35- monitor = ActiveEventMonitor ( " gesture_blocker " , events: eventTypes) { _ in . ignore }
36- monitor? . start ( )
41+ let newMonitor = ActiveEventMonitor ( " gesture_blocker " , events: eventTypes) { _ in . ignore }
42+ newMonitor. start ( )
43+
44+ guard newMonitor. isEnabled else {
45+ log. warn ( " Failed to start gesture blocker " )
46+ newMonitor. stop ( )
47+ return
48+ }
49+
50+ monitor = newMonitor
51+ activeCount = 1
3752 }
3853
3954 func stop( ) {
55+ guard activeCount > 0 || monitor != nil else { return }
56+
4057 activeCount = max ( 0 , activeCount - 1 )
4158 guard activeCount == 0 else { return }
4259
You can’t perform that action at this time.
0 commit comments