File tree 1 file changed +19
-0
lines changed
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,25 @@ MMRect getWindowRect(const WindowHandle windowHandle) {
109
109
110
110
bool focusWindow (const WindowHandle windowHandle) {
111
111
112
+ CGWindowListOption listOptions =
113
+ kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements ;
114
+ CFArrayRef windowList =
115
+ CGWindowListCopyWindowInfo (listOptions, kCGNullWindowID );
116
+ bool activated = false ;
117
+ for (NSDictionary *info in (NSArray *)windowList) {
118
+ NSNumber *ownerPid = info[(id )kCGWindowOwnerPID ];
119
+ NSNumber *windowNumber = info[(id )kCGWindowNumber ];
120
+ if ([windowNumber intValue ] == windowHandle) {
121
+ NSRunningApplication *app = [NSRunningApplication
122
+ runningApplicationWithProcessIdentifier: [ownerPid intValue ]];
123
+ [app activateWithOptions: NSApplicationActivateIgnoringOtherApps];
124
+ activated = true ;
125
+ }
126
+ }
127
+ if (windowList) {
128
+ CFRelease (windowList);
129
+ }
130
+
112
131
NSDictionary *windowInfo = getWindowInfo (windowHandle);
113
132
if (windowInfo == nullptr || windowHandle < 0 ) {
114
133
NSLog (@" Could not find window info for window handle %lld " , windowHandle);
You can’t perform that action at this time.
0 commit comments