From de675b4dd2dcc86d7b6036d6386bd9bb01c87aed Mon Sep 17 00:00:00 2001 From: Mokky Date: Thu, 7 Sep 2023 20:53:58 +0900 Subject: [PATCH] Update window.h Fix: error when current window is minimized --- window/window.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/window/window.h b/window/window.h index 2b9698e..b206aa8 100644 --- a/window/window.h +++ b/window/window.h @@ -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);