From 803a141088a63078704a2b7c3f9a7ad5cd5344a0 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 31 Oct 2026 10:00:03 -0700 Subject: [PATCH] refactor(mac): set a window's AX messaging timeout through Window Adds Window::set_messaging_timeout and uses it in settle.rs (the look at a window after a drag, 3 raw AX sites) and in Window::note_arrival. Same call on the same element; nothing changes at runtime. It is not one of the shared Backend operations, but it bounds the frame query, so the raw AX call leaves settle.rs with the frame read. The window manager's timeouts list and the animator keep calling AccessibilityApi: they hold elements (app elements, lane handles), not Windows. Verified: macOS fake-CC type-check (tools/fast-check) PASS. Not verified: cannot run or unit-test on Linux. --- komorebi-for-mac/komorebi/src/settle.rs | 5 ++--- komorebi-for-mac/komorebi/src/window.rs | 8 +++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/komorebi-for-mac/komorebi/src/settle.rs b/komorebi-for-mac/komorebi/src/settle.rs index 8c9fd60a..75492363 100644 --- a/komorebi-for-mac/komorebi/src/settle.rs +++ b/komorebi-for-mac/komorebi/src/settle.rs @@ -8,7 +8,6 @@ //! and any that are not where they are to be are sent there again, and looked at once more after //! that. -use crate::accessibility::AccessibilityApi; use crate::animation::animator; use crate::core::Rect; use crate::window::Snapping; @@ -184,9 +183,9 @@ impl WindowManager { return Ok(0); } - let _ = AccessibilityApi::set_messaging_timeout(&window.element, LOOK_TIMEOUT); + let _ = window.set_messaging_timeout(LOOK_TIMEOUT); let rect = window.frame().map(Rect::from); - let _ = AccessibilityApi::set_messaging_timeout(&window.element, 0.0); + let _ = window.set_messaging_timeout(0.0); if let Ok(rect) = rect && is_off(&rect, &layout) diff --git a/komorebi-for-mac/komorebi/src/window.rs b/komorebi-for-mac/komorebi/src/window.rs index 1b9b441b..51aabbad 100644 --- a/komorebi-for-mac/komorebi/src/window.rs +++ b/komorebi-for-mac/komorebi/src/window.rs @@ -574,6 +574,12 @@ impl Window { MacosApi::window_rect(&self.element) } + /// How long an Accessibility call to this window's app may block, in seconds (0 restores the + /// system default). Not an operation of the shared `Backend`; it bounds the frame query. + pub fn set_messaging_timeout(&self, seconds: f32) -> Result<(), AccessibilityError> { + AccessibilityApi::set_messaging_timeout(&self.element, seconds) + } + pub fn alive(&self) -> bool { AccessibilityApi::copy_attribute_names(&self.element).is_some() } @@ -959,7 +965,7 @@ impl Window { } // the window manager is waiting for this, and so is every window after this one - let _ = AccessibilityApi::set_messaging_timeout(&self.element, ARRIVAL_TIMEOUT); + let _ = self.set_messaging_timeout(ARRIVAL_TIMEOUT); match self.frame() { Ok(actual) => arrival::report(self.id, *target, Rect::from(actual)),