Add a blacklist of executable names (for wine.bin). Prefer the front window title...
authorJoe Wreschnig <joe.wreschnig@gmail.com>
Sat, 17 Aug 2013 11:51:13 +0000 (13:51 +0200)
committerJoe Wreschnig <joe.wreschnig@gmail.com>
Sat, 17 Aug 2013 11:51:13 +0000 (13:51 +0200)
Categories/NSRunningApplication+NJPossibleNames.m
Classes/NJInputController.m
Info.plist

index 895134cb9aef5319c700ba983093d34e467a1b77..7a7bd6378d7a6287ff4b7a60cd60002637328b7c 100644 (file)
 
 @implementation NSRunningApplication (NJPossibleNames)
 
+- (NSArray *)windowTitles {
+    NSMutableArray *titles = [[NSMutableArray alloc] initWithCapacity:4];
+    NSArray *windows = CFBridgingRelease(CGWindowListCopyWindowInfo(kCGWindowListOptionAll, kCGNullWindowID));
+    for (NSDictionary *props in windows) {
+        NSNumber *pid = props[(id)kCGWindowOwnerPID];
+        if (pid.longValue == self.processIdentifier && props[(id)kCGWindowName])
+            [titles addObject:props[(id)kCGWindowName]];
+    }
+    return titles;
+}
+
+- (NSString *)frontWindowTitle {
+    return self.windowTitles[0];
+}
+
 - (NSArray *)possibleMappingNames {
     NSMutableArray *names = [[NSMutableArray alloc] initWithCapacity:4];
     if (self.bundleIdentifier)
@@ -20,6 +35,8 @@
         [names addObject:[self.bundleURL.lastPathComponent stringByDeletingPathExtension]];
     if (self.executableURL)
         [names addObject:self.executableURL.lastPathComponent];
+    if (self.frontWindowTitle)
+        [names addObject:self.frontWindowTitle];
     return names;
 }
 
         @"com.macromedia.Flash Player Debugger.app",
         @"com.macromedia.Flash Player.app",
         ];
-    BOOL probablyWrong = [genericBundles containsObject:self.bundleIdentifier];
+    NSArray *genericExecutables = @[ @"wine.bin" ];
+    BOOL probablyWrong = ([genericBundles containsObject:self.bundleIdentifier]
+                          || [genericExecutables containsObject:self.localizedName]);
     if (!probablyWrong && self.localizedName)
         return self.localizedName;
     else if (!probablyWrong && self.bundleIdentifier)
         return self.bundleIdentifier;
     else if (self.bundleURL)
         return [self.bundleURL.lastPathComponent stringByDeletingPathExtension];
+    else if (self.frontWindowTitle)
+        return self.frontWindowTitle;
     else if (self.executableURL)
         return self.executableURL.lastPathComponent;
     else if (self.localizedName)
index face5e7dba0f9add12b27bd5aabb7c41749917fd..5ba9828e29b77cc8b0f16da682e3dfecc4692f94 100644 (file)
@@ -266,10 +266,10 @@ static CVReturn displayLink_update_cb(CVDisplayLinkRef displayLink,
 - (void)mappingsSet {
     [self postLoadProcess];
     [NSNotificationCenter.defaultCenter
-     postNotificationName:NJEventMappingListChanged
-     object:self
-     userInfo:@{ NJMappingListKey: _mappings,
-     NJMappingKey: _currentMapping }];
+        postNotificationName:NJEventMappingListChanged
+        object:self
+        userInfo:@{ NJMappingListKey: _mappings,
+                    NJMappingKey: _currentMapping }];
 }
 
 - (void)mappingsChanged {
index 9917f03b67b2004f345fd3340ad60ef17b7ce902..1e6b7d947703ca53701717c290957477180adbfb 100644 (file)
@@ -46,7 +46,7 @@
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
-       <string>598</string>
+       <string>605</string>
        <key>LSApplicationCategoryType</key>
        <string>public.app-category.utilities</string>
        <key>NSHumanReadableCopyright</key>