From a52b7c704a4d13fdc0d6b72f4080bb0fc118be64 Mon Sep 17 00:00:00 2001 From: noy4 Date: Sat, 6 Jun 2026 01:04:00 +0900 Subject: [PATCH] fix: resolve fullscreen AX tree retrieval returning ref_count: 0 - Add !t.is_empty() check to prevent false positives in partial title matching - Add fallback to select the first window with children > 0 using count_children API - Ensures reliable active window selection in macOS native fullscreen mode --- crates/macos/src/tree/builder.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/macos/src/tree/builder.rs b/crates/macos/src/tree/builder.rs index 4cec93e..610ee56 100644 --- a/crates/macos/src/tree/builder.rs +++ b/crates/macos/src/tree/builder.rs @@ -31,11 +31,16 @@ pub fn window_element_for(pid: i32, win_title: &str) -> AXElement { let title = copy_string_attr(win, kAXTitleAttribute); if title .as_deref() - .is_some_and(|t| t.contains(win_title) || win_title.contains(t)) + .is_some_and(|t| !t.is_empty() && (t.contains(win_title) || win_title.contains(t))) { return win.clone(); } } + for win in &windows { + if count_children(win, None) > 0 { + return win.clone(); + } + } if let Some(first) = windows.into_iter().next() { return first; }