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.
This commit is contained in:
LGUG2Z committed 2026-10-29 16:38:24 -07:00
1 parent 2cd5884f21
commit 43011bfb5b
1 file changed
+13 -8
+13 -8
View File
@@ -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
{