Add windowID to info dictionary

This commit is contained in:
Michael Starke
2020-12-02 17:33:01 +01:00
parent e99f2e2619
commit 784afaee97
2 changed files with 6 additions and 4 deletions

View File

@@ -13,9 +13,11 @@
NS_ASSUME_NONNULL_BEGIN
APPKIT_EXTERN NSString *const MPWindowIDKey;
APPKIT_EXTERN NSString *const MPWindowTitleKey;
APPKIT_EXTERN NSString *const MPProcessIdentifierKey;
@interface NSRunningApplication (MPAdditions)
@property (readonly, copy) NSDictionary *mp_infoDictionary;

View File

@@ -10,11 +10,10 @@
#import <AppKit/AppKit.h>
NSString *const MPWindowIDKey = @"MPWindowIDKey";
NSString *const MPWindowTitleKey = @"MPWindowTitleKey";
NSString *const MPProcessIdentifierKey = @"MPProcessIdentifierKey";
BOOL skipWindowTitle(NSString *windowTitle) {
if(windowTitle.length <= 0) {
return YES;
@@ -45,11 +44,12 @@ BOOL skipWindowTitle(NSString *windowTitle) {
NSNumber *processId = windowDict[(NSString *)kCGWindowOwnerPID];
if(processId && [processId isEqualToNumber:@(self.processIdentifier)]) {
NSNumber *number = (NSNumber *)windowDict[(NSString *)kCGWindowNumber];
NSUInteger zIndex = [windowNumbers indexOfObject:number];
NSNumber *windowId = (NSNumber *)windowDict[(NSString *)kCGWindowNumber];
NSUInteger zIndex = [windowNumbers indexOfObject:windowId];
if(zIndex < minZIndex) {
minZIndex = zIndex;
infoDict = @{
MPWindowIDKey: windowId,
MPWindowTitleKey: windowTitle,
MPProcessIdentifierKey : processId
};