diff --git a/komorebi/src/application.rs b/komorebi/src/application.rs index d7b33071..f34b3b61 100644 --- a/komorebi/src/application.rs +++ b/komorebi/src/application.rs @@ -189,9 +189,9 @@ impl Application { if let Some(window_title) = window.title() && (window_title.eq(title) - // TODO: find a better way to deal with these hacks - || (self.name().unwrap_or_default() == "Activity Monitor" - && window_title.starts_with(title))) + // a hack for handling already-launched apps with inconsistent titles when + // komorebi launches, such as Activity Monitor, Google Chrome, and counting... + || window_title.contains(title)) { target = Some(window); } diff --git a/komorebi/src/macos_api.rs b/komorebi/src/macos_api.rs index c58221c3..dfe13e08 100644 --- a/komorebi/src/macos_api.rs +++ b/komorebi/src/macos_api.rs @@ -371,6 +371,7 @@ impl MacosApi { )?) } + // #[track_caller] // use this to with std::panic::Location::caller() to debug failures #[tracing::instrument(skip_all)] pub fn window_rect(element: &AXUIElement) -> Result { let mut position_receiver = std::ptr::null(); diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index c9b22f38..79449a82 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -1171,9 +1171,10 @@ impl Workspace { layout.add_padding(border_width); for window in container.windows_mut() { - let current_percentage = work_area.percentage_within_horizontal_bounds( - &Rect::from(MacosApi::window_rect(&window.element)?), - ); + let current_rect = + MacosApi::window_rect(&window.element).unwrap_or_default(); + let current_percentage = work_area + .percentage_within_horizontal_bounds(&Rect::from(current_rect)); let proposed_percentage = work_area.percentage_within_horizontal_bounds(layout);