aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-05-20 16:26:02 +0530
committerRoopesh Chander <roop@roopc.net>2019-05-20 16:42:28 +0530
commit70d19691a7d9c24fd968801f1721010a67399d06 (patch)
tree359a5d9fce6ae621269f3fed74215881a162bf03
parentmacOS: Don't show manage window when launched at login (diff)
downloadwireguard-apple-70d19691a7d9c24fd968801f1721010a67399d06.tar.xz
wireguard-apple-70d19691a7d9c24fd968801f1721010a67399d06.zip
macOS: Simplify detecting the type of an Apple event
Signed-off-by: Roopesh Chander <roop@roopc.net>
-rw-r--r--WireGuard/WireGuard/UI/macOS/LaunchedAtLoginDetector.swift6
-rw-r--r--WireGuard/WireGuard/UI/macOS/MacAppStoreUpdateDetector.swift6
2 files changed, 2 insertions, 10 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/LaunchedAtLoginDetector.swift b/WireGuard/WireGuard/UI/macOS/LaunchedAtLoginDetector.swift
index 53a4dae..185aced 100644
--- a/WireGuard/WireGuard/UI/macOS/LaunchedAtLoginDetector.swift
+++ b/WireGuard/WireGuard/UI/macOS/LaunchedAtLoginDetector.swift
@@ -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
}
diff --git a/WireGuard/WireGuard/UI/macOS/MacAppStoreUpdateDetector.swift b/WireGuard/WireGuard/UI/macOS/MacAppStoreUpdateDetector.swift
index 7fbb011..68608ca 100644
--- a/WireGuard/WireGuard/UI/macOS/MacAppStoreUpdateDetector.swift
+++ b/WireGuard/WireGuard/UI/macOS/MacAppStoreUpdateDetector.swift
@@ -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? {