]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
macOS: Simplify detecting the type of an Apple event
authorRoopesh Chander <roop@roopc.net>
Mon, 20 May 2019 10:56:02 +0000 (16:26 +0530)
committerRoopesh Chander <roop@roopc.net>
Mon, 20 May 2019 11:12:28 +0000 (16:42 +0530)
Signed-off-by: Roopesh Chander <roop@roopc.net>
WireGuard/WireGuard/UI/macOS/LaunchedAtLoginDetector.swift
WireGuard/WireGuard/UI/macOS/MacAppStoreUpdateDetector.swift

index 53a4dae5acc6abf33fc4a971f181764eb87125f3..185aced37bd7d29fb8f53e1962bd9db57828557c 100644 (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
 }
index 7fbb011bdbe44e6060eacc925487040235e15d63..68608ca12fad3b5363993c8b6c014cc76fd7248b 100644 (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? {