From 6f8ad18d9ad3e3a0a5973c14468e8c5ca2f4a952 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Sat, 30 Sep 2023 17:27:25 +0400 Subject: Compute view offset relative to anim target This enables quickly tapping focus right-left to keep typing in the current window while showing the next window. Resolves https://github.com/YaLTeR/niri/issues/26 --- src/layout.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/layout.rs b/src/layout.rs index f878ed9e..38c076b6 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -1539,6 +1539,12 @@ impl Workspace { let current_x = self.view_pos(); + let final_x = if let Some(anim) = &self.view_offset_anim { + current_x - self.view_offset + anim.to().round() as i32 + } else { + current_x + }; + self.active_column_idx = idx; // A different column was activated; reset the flag. @@ -1546,7 +1552,7 @@ impl Workspace { let new_x = self.column_x(idx) - PADDING; let new_view_offset = compute_new_view_offset( - current_x, + final_x, self.working_area.size.w, new_x, self.columns[idx].size().w, @@ -1661,10 +1667,17 @@ impl Workspace { if idx == self.active_column_idx { // We might need to move the view to ensure the resized window is still visible. let current_x = self.view_pos(); + + let final_x = if let Some(anim) = &self.view_offset_anim { + current_x - self.view_offset + anim.to().round() as i32 + } else { + current_x + }; + let new_x = self.column_x(idx) - PADDING; let new_view_offset = compute_new_view_offset( - current_x, + final_x, self.working_area.size.w, new_x, self.columns[idx].size().w, -- cgit