Skip to content

Commit

Permalink
Update window.h
Browse files Browse the repository at this point in the history
Fix: error when current window is minimized
  • Loading branch information
yms2772 authored Sep 7, 2023
1 parent ef191f2 commit de675b4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion window/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -380,6 +380,9 @@ MData get_active(void) {
} else {
CFRelease(element);
}
} else {
result.CgID = win;
result.AxID = element;
}
CFRelease(focused);

Expand Down

0 comments on commit de675b4

Please sign in to comment.