Update window.h

Fix: error when current window is minimized
This commit is contained in:
Mokky 2023-09-07 20:53:58 +09:00 committed by GitHub
parent ef191f2dfd
commit de675b4dd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -367,11 +367,11 @@ MData get_active(void) {
if (focused == NULL) { return result; } // Verify
AXUIElementRef element;
CGWindowID win = 0;
// Retrieve the currently focused window
if (AXUIElementCopyAttributeValue(focused, kAXFocusedWindowAttribute, (CFTypeRef*) &element)
== kAXErrorSuccess && element) {
CGWindowID win = 0;
// Use undocumented API to get WID
if (_AXUIElementGetWindow(element, &win) == kAXErrorSuccess && win) {
// Manually set internals
@ -380,6 +380,9 @@ MData get_active(void) {
} else {
CFRelease(element);
}
} else {
result.CgID = win;
result.AxID = element;
}
CFRelease(focused);