diff --git a/komorebi-for-mac/komorebi/src/process_event.rs b/komorebi-for-mac/komorebi/src/process_event.rs index 7c72b2f0..5467f52f 100644 --- a/komorebi-for-mac/komorebi/src/process_event.rs +++ b/komorebi-for-mac/komorebi/src/process_event.rs @@ -745,6 +745,7 @@ impl WindowManager { ) ) { enhanced_ui::forget(process_id); + crate::ax_registry::forget_pid(process_id); } // some apps like Discord in all of their relentless Electron slop stupidity diff --git a/komorebi-for-mac/komorebi/src/reaper.rs b/komorebi-for-mac/komorebi/src/reaper.rs index 9f06b359..362c95b1 100644 --- a/komorebi-for-mac/komorebi/src/reaper.rs +++ b/komorebi-for-mac/komorebi/src/reaper.rs @@ -111,6 +111,9 @@ fn invalid_window_ids( } fn reap_window(wm: &mut WindowManager, window_id: u32) -> color_eyre::Result<()> { + // whatever else happens to the window, the id no longer names anything + crate::ax_registry::forget(window_id); + let mut should_update = false; for monitor in wm.monitors_mut() { for workspace in monitor.workspaces_mut() { diff --git a/komorebi-for-mac/komorebi/src/window.rs b/komorebi-for-mac/komorebi/src/window.rs index 8dc9420e..247b887e 100644 --- a/komorebi-for-mac/komorebi/src/window.rs +++ b/komorebi-for-mac/komorebi/src/window.rs @@ -476,6 +476,9 @@ impl Drop for Window { // for now - hopefully it doesn't break anything else reaper::send_notification(ReaperNotification::InvalidWindow(self.id)); + // and the id no longer names anything + crate::ax_registry::forget(self.id); + // make sure the observer gets removed from any run loops AccessibilityApi::invalidate_observer(&self.observer); } @@ -560,13 +563,18 @@ impl Window { Some(window_observer_callback), )?; - Ok(Self { + let window = Self { id: AccessibilityApi::window_id(&element)?, element: AccessibilityUiElement(element), application, observer: AccessibilityObserver(Some(observer)), details: None, - }) + }; + + // so that the window can be found again from its id alone + crate::ax_registry::register(&window); + + Ok(window) } /// The handles that act on this window, as the registry keeps them