diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-02-29 08:30:46 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-02-29 08:30:46 +0400 |
| commit | 55038b7c07e9a7c08fca39793c5c4602e7099a0c (patch) | |
| tree | 7297964b884a175afc66065a8c5a37d1c9ec844d /src/layout | |
| parent | 8018839f5d970b0960936a4d7d984a8599785988 (diff) | |
| download | niri-55038b7c07e9a7c08fca39793c5c4602e7099a0c.tar.gz niri-55038b7c07e9a7c08fca39793c5c4602e7099a0c.tar.bz2 niri-55038b7c07e9a7c08fca39793c5c4602e7099a0c.zip | |
Pass prev_idx explicitly to animate_view_offset_to_column()
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/workspace.rs | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index fce5719d..2b0b0823 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -459,14 +459,24 @@ impl<W: LayoutElement> Workspace<W> { self.animate_view_offset(current_x, idx, new_view_offset); } - fn animate_view_offset_to_column(&mut self, current_x: i32, idx: usize) { + fn animate_view_offset_to_column( + &mut self, + current_x: i32, + idx: usize, + prev_idx: Option<usize>, + ) { match self.options.center_focused_column { CenterFocusedColumn::Always => { self.animate_view_offset_to_column_centered(current_x, idx) } CenterFocusedColumn::OnOverflow => { + let Some(prev_idx) = prev_idx else { + self.animate_view_offset_to_column_fit(current_x, idx); + return; + }; + // Always take the left or right neighbor of the target as the source. - let source_idx = if self.active_column_idx > idx { + let source_idx = if prev_idx > idx { min(idx + 1, self.columns.len() - 1) } else { idx.saturating_sub(1) @@ -503,7 +513,7 @@ impl<W: LayoutElement> Workspace<W> { } let current_x = self.view_pos(); - self.animate_view_offset_to_column(current_x, idx); + self.animate_view_offset_to_column(current_x, idx, Some(self.active_column_idx)); self.active_column_idx = idx; @@ -770,13 +780,9 @@ impl<W: LayoutElement> Workspace<W> { // We might need to move the view to ensure the resized window is still visible. let current_x = self.view_pos(); - if self.options.center_focused_column == CenterFocusedColumn::Always { - // FIXME: we will want to skip the animation in some cases here to make - // continuously resizing windows not look janky. - self.animate_view_offset_to_column_centered(current_x, idx); - } else { - self.animate_view_offset_to_column_fit(current_x, idx); - } + // FIXME: we will want to skip the animation in some cases here to make continuously + // resizing windows not look janky. + self.animate_view_offset_to_column(current_x, idx, None); } } |
