From 8f542b6c3bb48a1901c4f6e5a70f9a03b261c978 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 1 Jan 2026 10:43:13 -0800 Subject: [PATCH] fix(wm): ensure tabbed apps are known in monocle mode This commit ensures that we detect tabbed applications appropriately when they are in monocle mode when handling FocusChange so that switching tabs doesn't break monocle mode or the layout it has been toggled on from. --- komorebi/src/process_event.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index c9bda99c..a09e7f41 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -274,6 +274,40 @@ impl WindowManager { } } + // check monocle_container for tabbed applications + let mut update_monocle = false; + if let Some(monocle) = &workspace.monocle_container + && let Some(window) = monocle.focused_window() + && window.application.name().unwrap_or_default() == application_name + && window.application.process_id == process_id + { + let tab_rect = MacosApi::window_rect(&element)?; + let main_rect = match MacosApi::window_rect(&window.element) { + Ok(rect) => rect, + Err(AccessibilityError::Api( + AccessibilityApiError::InvalidUIElement, + )) => { + first_tab_destroyed = true; + tab_rect + } + Err(error) => return Err(error.into()), + }; + + if tab_rect == main_rect && window.id != window_id { + update_monocle = true; + tabbed_window = true; + } + } + + if update_monocle { + if let Some(monocle) = workspace.monocle_container.as_mut() + && let Some(window) = monocle.focused_window_mut() + { + window.id = window_id; + window.element = AccessibilityUiElement(element.clone()); + } + } + if first_tab_destroyed { self.reap_invalid_windows_for_application(process_id)?; }