From e40f859c3a60a3d64fafc8147d4c2a7d3f8e6a45 Mon Sep 17 00:00:00 2001 From: Louis Pontoise Date: Thu, 12 Mar 2020 00:18:31 +0900 Subject: [PATCH] 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 --- src/logic/Applications.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/logic/Applications.swift b/src/logic/Applications.swift index 009bda81..517b292f 100644 --- a/src/logic/Applications.swift +++ b/src/logic/Applications.swift @@ -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" } } }