mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-23 16:19:29 +00:00
Filter window titles and skip wellknown false positives
This commit is contained in:
@@ -14,6 +14,22 @@
|
||||
NSString *const MPWindowTitleKey = @"MPWindowTitleKey";
|
||||
NSString *const MPProcessIdentifierKey = @"MPProcessIdentifierKey";
|
||||
|
||||
NSSet<NSString *> *bogusWindowTitles() {
|
||||
static NSSet<NSString *> *titles;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
titles = [NSSet setWithArray:@[@"Item-0"]];
|
||||
});
|
||||
return titles;
|
||||
}
|
||||
|
||||
BOOL skipWindowTitle(NSString *windowTitle) {
|
||||
if(windowTitle.length <= 0) {
|
||||
return YES;
|
||||
}
|
||||
return [bogusWindowTitles() containsObject:windowTitle];
|
||||
}
|
||||
|
||||
@implementation NSRunningApplication (MPAdditions)
|
||||
|
||||
- (NSDictionary *)mp_infoDictionary {
|
||||
@@ -23,7 +39,8 @@ NSString *const MPProcessIdentifierKey = @"MPProcessIdentifierKey";
|
||||
NSDictionary *infoDict = nil;
|
||||
for(NSDictionary *windowDict in currentWindows) {
|
||||
NSString *windowTitle = windowDict[(NSString *)kCGWindowName];
|
||||
if(windowTitle.length <= 0) {
|
||||
/* skip a list of well know useless window-titles */
|
||||
if(skipWindowTitle(windowTitle)) {
|
||||
continue;
|
||||
}
|
||||
NSNumber *processId = windowDict[(NSString *)kCGWindowOwnerPID];
|
||||
|
||||
Reference in New Issue
Block a user