From 43011bfb5b82e4518925e3befd66efa373ed24eb Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 27 Oct 2026 14:01:55 -0700 Subject: [PATCH] perf(workspace): only ask a window where it is when the layout needs to know Workspace::update asked every window where it was, which is a round trip to the app that owns it, before deciding what to do with it. The answer only matters for a window that the layout would put entirely out of view, so ask only then. --- komorebi/src/workspace.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index a5203a5e..80e3d883 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -1439,17 +1439,22 @@ impl Workspace { layout.add_padding(border_width); for window in container.windows_mut() { - 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); - let percentage_override = proposed_percentage == 0.0 - && current_percentage > 0.1 - && current_percentage < 100.0 - && resize_dimensions_is_empty; + // where the window is now only matters when the layout would put it + // entirely out of view, and finding out means asking the app + let percentage_override = + proposed_percentage == 0.0 && resize_dimensions_is_empty && { + let current_rect = MacosApi::window_rect(&window.element) + .unwrap_or_default(); + let current_percentage = work_area + .percentage_within_horizontal_bounds(&Rect::from( + current_rect, + )); + + current_percentage > 0.1 && current_percentage < 100.0 + }; if is_scrolling && proposed_percentage < 0.1 && !percentage_override {