From 6c575126ad9d628e3bd25387b06e7b72011675d1 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 24 Dec 2025 08:53:20 -0800 Subject: [PATCH] perf(animation): hide scrolling windows to nearest edge This commit improves the scrolling layout animation by dynamically choosing the window hiding position based on which side of the viewport the window is scrolling out of. Previously, all hidden windows went to the same corner (based on the global window_hiding_position setting), causing jarring animations when windows scrolled back into view from the opposite side of the screen. Now windows scrolling off the left edge hide to the bottom-left, and windows scrolling off the right edge hide to the bottom-right. This ensures windows animate back in from the side they scrolled out to. --- komorebi/src/workspace.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index da1e7acd..2d0e8d21 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -1199,7 +1199,6 @@ impl Workspace { let is_scrolling = matches!(self.layout, Layout::Default(DefaultLayout::Scrolling)); - let window_hiding_position = self.globals.window_hiding_position; let resize_dimensions_is_empty = self.resize_dimensions.is_empty(); let containers = self.containers_mut(); @@ -1224,7 +1223,18 @@ impl Workspace { if is_scrolling && proposed_percentage < 0.1 && !percentage_override { - if let Err(error) = window.hide(window_hiding_position) { + // for the scrolling layout we pick the hiding position based + // on the closest edge to make the animations back in to the + // scrolling viewport nicer (i.e. not all the way across the + // screen in the worst case scenario) + let scrolling_hiding_position = if layout.left < work_area.left + { + WindowHidingPosition::BottomLeft + } else { + WindowHidingPosition::BottomRight + }; + + if let Err(error) = window.hide(scrolling_hiding_position) { tracing::warn!( "failed to set hide window for scrolling layout: {error}" )