fix: don't observe daemons to avoid infinite loops (closes #170)

There is a risk of not showing some windows, like CopyQ, but the reward is less risk of trying to observe some buggy daemon process that will never succeed
This commit is contained in:
Louis Pontoise committed 2020-03-12 00:20:05 +09:00
1 parent 6018a531e8
commit e40f859c3a
1 file changed
+2 -3
+2 -3
View File
@@ -1,4 +1,5 @@
import Cocoa
import ApplicationServices
class Applications {
static var list = [Application]()
@@ -64,9 +65,7 @@ class Applications {
}
private static func filterApplications(_ apps: [NSRunningApplication]) -> [NSRunningApplication] {
// it would be nice to filter with $0.activationPolicy != .prohibited (see https://stackoverflow.com/a/26002033/2249756)
// however some daemon processes can sometimes create windows, so we can't filter them out (e.g. CopyQ is .prohibited for some reason)
return apps.filter { $0.bundleIdentifier != nil }
return apps.filter { $0.activationPolicy != .prohibited || $0.bundleIdentifier == "io.github.hluk.CopyQ" }
}
}