Since this runs every time the foreground application changes, reduce the number...
[enjoyable.git] / Categories / NSRunningApplication+NJPossibleNames.m
index 7a7bd63..5957a50 100644 (file)
 @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])