macOS: Simplify detecting the type of an Apple event

Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
Roopesh Chander 2019-05-20 16:26:02 +05:30
parent 40b1f0bac8
commit 70d19691a7
2 changed files with 2 additions and 10 deletions

View File

@ -13,9 +13,5 @@ class LaunchedAtLoginDetector {
}
private func isOpenEvent(_ event: NSAppleEventDescriptor) -> Bool {
if let eventClassDescriptor = event.attributeDescriptor(forKeyword: keyEventClassAttr),
let eventIdDescriptor = event.attributeDescriptor(forKeyword: keyEventIDAttr) {
return eventClassDescriptor.typeCodeValue == kCoreEventClass && eventIdDescriptor.typeCodeValue == kAEOpenApplication
}
return false
return event.eventClass == kCoreEventClass && event.eventID == kAEOpenApplication
}

View File

@ -19,11 +19,7 @@ class MacAppStoreUpdateDetector {
}
private func isQuitEvent(_ event: NSAppleEventDescriptor) -> Bool {
if let eventClassDescriptor = event.attributeDescriptor(forKeyword: keyEventClassAttr),
let eventIdDescriptor = event.attributeDescriptor(forKeyword: keyEventIDAttr) {
return eventClassDescriptor.typeCodeValue == kCoreEventClass && eventIdDescriptor.typeCodeValue == kAEQuitApplication
}
return false
return event.eventClass == kCoreEventClass && event.eventID == kAEQuitApplication
}
private func getExecutablePath(from pid: pid_t) -> String? {