Skip to content

Commit

Permalink
Merge pull request #612 from yms2772/master
Browse files Browse the repository at this point in the history
Fix: panic occurs when current window is minimized on macOS
  • Loading branch information
vcaesar committed Sep 15, 2023
2 parents ef191f2 + de675b4 commit a780825
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 a780825

Please sign in to comment.