From: Joe Wreschnig Date: Sat, 17 Aug 2013 12:02:13 +0000 (+0200) Subject: Since this runs every time the foreground application changes, reduce the number... X-Git-Tag: version-1.2~14 X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=commitdiff_plain;h=1894929139c16ab69f7c20fd7e4332ae3ff9470f;ds=sidebyside 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. --- 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])