From 1894929139c16ab69f7c20fd7e4332ae3ff9470f Mon Sep 17 00:00:00 2001 From: Joe Wreschnig Date: Sat, 17 Aug 2013 14:02:13 +0200 Subject: [PATCH] Since this runs every time the foreground application changes, reduce the number of windows we have to process to those on-screen and excluding desktop ones. --- Categories/NSRunningApplication+NJPossibleNames.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Categories/NSRunningApplication+NJPossibleNames.m b/Categories/NSRunningApplication+NJPossibleNames.m index 7a7bd63..5957a50 100644 --- a/Categories/NSRunningApplication+NJPossibleNames.m +++ b/Categories/NSRunningApplication+NJPossibleNames.m @@ -11,8 +11,10 @@ @implementation NSRunningApplication (NJPossibleNames) - (NSArray *)windowTitles { + static CGWindowListOption s_OPTIONS = (kCGWindowListOptionOnScreenOnly + | kCGWindowListExcludeDesktopElements); NSMutableArray *titles = [[NSMutableArray alloc] initWithCapacity:4]; - NSArray *windows = CFBridgingRelease(CGWindowListCopyWindowInfo(kCGWindowListOptionAll, kCGNullWindowID)); + NSArray *windows = CFBridgingRelease(CGWindowListCopyWindowInfo(s_OPTIONS, kCGNullWindowID)); for (NSDictionary *props in windows) { NSNumber *pid = props[(id)kCGWindowOwnerPID]; if (pid.longValue == self.processIdentifier && props[(id)kCGWindowName]) -- 2.30.2