fix: fix situations from some crash reports

This commit is contained in:
Louis Pontoise
2021-08-30 23:19:43 +09:00
parent 6f33e3ae9f
commit c18aa4d91c
3 changed files with 14 additions and 6 deletions
+1 -1
View File
@@ -68,7 +68,7 @@ class SystemPermissions {
DispatchQueue.main.async {
if accessibility && screenRecording {
timer.invalidate()
permissionsWindow.close()
permissionsWindow?.close()
startupBlock()
} else {
if accessibility != permissionsWindow.accessibilityView.isPermissionGranted {
+6 -2
View File
@@ -83,8 +83,12 @@ class KeyboardEvents {
eventsOfInterest: eventMask,
callback: cgEventFlagsChangedHandler,
userInfo: nil)
let runLoopSource = CFMachPortCreateRunLoopSource(nil, eventTap, 0)
CFRunLoopAddSource(CFRunLoopGetMain(), runLoopSource, .commonModes)
if let eventTap = eventTap {
let runLoopSource = CFMachPortCreateRunLoopSource(nil, eventTap, 0)
CFRunLoopAddSource(CFRunLoopGetMain(), runLoopSource, .commonModes)
} else {
App.app.restart()
}
}
private static func addGlobalHandlerIfNeeded(_ shortcut: Shortcut) {
+7 -3
View File
@@ -28,9 +28,13 @@ private func observe_() {
eventsOfInterest: eventMask,
callback: mouseHandler,
userInfo: nil)
MouseEvents.toggle(false)
let runLoopSource = CFMachPortCreateRunLoopSource(nil, eventTap, 0)
CFRunLoopAddSource(BackgroundWork.mouseEventsThread.runLoop, runLoopSource, .commonModes)
if let eventTap = eventTap {
MouseEvents.toggle(false)
let runLoopSource = CFMachPortCreateRunLoopSource(nil, eventTap, 0)
CFRunLoopAddSource(BackgroundWork.mouseEventsThread.runLoop, runLoopSource, .commonModes)
} else {
App.app.restart()
}
}
private func mouseHandler(proxy: CGEventTapProxy, type: CGEventType, cgEvent: CGEvent, userInfo: UnsafeMutableRawPointer?) -> Unmanaged<CGEvent>? {