From 7c2e1bea8a603728ae58a20c0d8e26c398216a54 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 31 Oct 2026 09:59:11 -0700 Subject: [PATCH] refactor(mac): name the Window liveness check alive, as the shared Backend does Renames Window::is_valid to Window::alive (window.rs, reaper.rs, workspace.rs, macos_backend.rs). Same body (the element still answers a copy-attribute-names query), so nothing changes at runtime. Application::is_valid is a different type and keeps its name. This is the 'alive' operation of the step 6 list. Verified: macOS fake-CC type-check (tools/fast-check) PASS. Not verified: cannot run or unit-test on Linux. --- komorebi-for-mac/komorebi/src/macos_backend.rs | 4 ++-- komorebi-for-mac/komorebi/src/reaper.rs | 2 +- komorebi-for-mac/komorebi/src/window.rs | 6 +++--- komorebi-for-mac/komorebi/src/workspace.rs | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/komorebi-for-mac/komorebi/src/macos_backend.rs b/komorebi-for-mac/komorebi/src/macos_backend.rs index 4811c567..3bef4cd4 100644 --- a/komorebi-for-mac/komorebi/src/macos_backend.rs +++ b/komorebi-for-mac/komorebi/src/macos_backend.rs @@ -118,7 +118,7 @@ impl MacosBackend { window: &Window, error: impl std::error::Error + Send + Sync + 'static, ) -> Error { - if window.is_valid() { + if window.alive() { platform(error) } else { Error::WindowGone(id) @@ -126,7 +126,7 @@ impl MacosBackend { } fn info(window: &Window) -> Option { - if !window.is_valid() { + if !window.alive() { return None; } diff --git a/komorebi-for-mac/komorebi/src/reaper.rs b/komorebi-for-mac/komorebi/src/reaper.rs index 8f88b0c9..9f06b359 100644 --- a/komorebi-for-mac/komorebi/src/reaper.rs +++ b/komorebi-for-mac/komorebi/src/reaper.rs @@ -64,7 +64,7 @@ fn handle_notifications(wm: Arc>) -> color_eyre::Result<()> continue 'notification; } - handle_notification(&mut wm, notification, Window::is_valid)?; + handle_notification(&mut wm, notification, Window::alive)?; } Ok(()) diff --git a/komorebi-for-mac/komorebi/src/window.rs b/komorebi-for-mac/komorebi/src/window.rs index 49c0fe4d..de2ce50b 100644 --- a/komorebi-for-mac/komorebi/src/window.rs +++ b/komorebi-for-mac/komorebi/src/window.rs @@ -465,7 +465,7 @@ impl Drop for Window { fn drop(&mut self) { // this gets called when a cloned Window is dropped, so we need to make sure it only // invalidates the observer if the Window is no longer open - if !self.is_valid() { + if !self.alive() { tracing::info!( "invalidating window observer for {}", self.title() @@ -574,7 +574,7 @@ impl Window { MacosApi::window_rect(&self.element) } - pub fn is_valid(&self) -> bool { + pub fn alive(&self) -> bool { AccessibilityApi::copy_attribute_names(&self.element).is_some() } @@ -1290,7 +1290,7 @@ impl Window { event: Option, debug: &mut RuleDebug, ) -> eyre::Result { - if !self.is_valid() { + if !self.alive() { return Ok(false); } diff --git a/komorebi-for-mac/komorebi/src/workspace.rs b/komorebi-for-mac/komorebi/src/workspace.rs index d6d29ab7..a66674d1 100644 --- a/komorebi-for-mac/komorebi/src/workspace.rs +++ b/komorebi-for-mac/komorebi/src/workspace.rs @@ -566,7 +566,7 @@ impl Workspace { // if accessibility API calls fail on AXError::InvalidUIElement // let's try and nuke these early - if !focused_window.is_valid() { + if !focused_window.alive() { invalid_window_ids.push(focused_window.id); } } @@ -591,7 +591,7 @@ impl Workspace { // if accessibility API calls fail on AXError::InvalidUIElement // let's try and nuke these early - if !focused_window.is_valid() { + if !focused_window.alive() { invalid_window_ids.push(focused_window.id); } } @@ -612,7 +612,7 @@ impl Workspace { // if accessibility API calls fail on AXError::InvalidUIElement // let's try and nuke these early - if !window.is_valid() { + if !window.alive() { invalid_floating_window_ids.push(window.id); } }