mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 07:02:39 +00:00
fixed various issues with Autotype determining the wrong window title
This commit is contained in:
@@ -263,6 +263,9 @@ static MPAutotypeDaemon *_sharedInstance;
|
|||||||
|
|
||||||
- (NSDictionary *)_infoDictionaryForApplication:(NSRunningApplication *)application {
|
- (NSDictionary *)_infoDictionaryForApplication:(NSRunningApplication *)application {
|
||||||
NSArray *currentWindows = CFBridgingRelease(CGWindowListCopyWindowInfo(kCGWindowListExcludeDesktopElements, kCGNullWindowID));
|
NSArray *currentWindows = CFBridgingRelease(CGWindowListCopyWindowInfo(kCGWindowListExcludeDesktopElements, kCGNullWindowID));
|
||||||
|
NSArray *windowNumbers = [NSWindow windowNumbersWithOptions:NSWindowNumberListAllApplications];
|
||||||
|
NSUInteger minZIndex = NSNotFound;
|
||||||
|
NSDictionary *infoDict = nil;
|
||||||
for(NSDictionary *windowDict in currentWindows) {
|
for(NSDictionary *windowDict in currentWindows) {
|
||||||
NSString *windowTitle = windowDict[(NSString *)kCGWindowName];
|
NSString *windowTitle = windowDict[(NSString *)kCGWindowName];
|
||||||
if(windowTitle.length <= 0) {
|
if(windowTitle.length <= 0) {
|
||||||
@@ -270,13 +273,19 @@ static MPAutotypeDaemon *_sharedInstance;
|
|||||||
}
|
}
|
||||||
NSNumber *processId = windowDict[(NSString *)kCGWindowOwnerPID];
|
NSNumber *processId = windowDict[(NSString *)kCGWindowOwnerPID];
|
||||||
if(processId && [processId isEqualToNumber:@(application.processIdentifier)]) {
|
if(processId && [processId isEqualToNumber:@(application.processIdentifier)]) {
|
||||||
return @{
|
|
||||||
kMPWindowTitleKey: windowDict[(NSString *)kCGWindowName],
|
NSNumber *number = (NSNumber *)windowDict[(NSString *)kCGWindowNumber];
|
||||||
|
NSUInteger zIndex = [windowNumbers indexOfObject:number];
|
||||||
|
if(zIndex < minZIndex) {
|
||||||
|
minZIndex = zIndex;
|
||||||
|
infoDict = @{
|
||||||
|
kMPWindowTitleKey: windowTitle,
|
||||||
kMPProcessIdentifierKey : processId
|
kMPProcessIdentifierKey : processId
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil;
|
}
|
||||||
|
return infoDict;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_presentSelectionWindow:(NSArray *)candidates {
|
- (void)_presentSelectionWindow:(NSArray *)candidates {
|
||||||
|
|||||||
Reference in New Issue
Block a user