aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2023-12-29 08:00:40 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2023-12-29 08:00:40 +0400
commit310aa2b464d22a9b43309f237d2b3732eee03d77 (patch)
treea57b8026d3bddf02ab5a9f2ea3b87af47b815550
parentd6c553091f037f482f63d8a8afce306b236c404b (diff)
downloadniri-310aa2b464d22a9b43309f237d2b3732eee03d77.tar.gz
niri-310aa2b464d22a9b43309f237d2b3732eee03d77.tar.bz2
niri-310aa2b464d22a9b43309f237d2b3732eee03d77.zip
layout: Extract move_column_to()
-rw-r--r--src/layout/workspace.rs21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs
index d496cd69..7fced686 100644
--- a/src/layout/workspace.rs
+++ b/src/layout/workspace.rs
@@ -645,8 +645,7 @@ impl<W: LayoutElement> Workspace<W> {
self.columns[self.active_column_idx].focus_up();
}
- pub fn move_left(&mut self) {
- let new_idx = self.active_column_idx.saturating_sub(1);
+ fn move_column_to(&mut self, new_idx: usize) {
if self.active_column_idx == new_idx {
return;
}
@@ -661,24 +660,18 @@ impl<W: LayoutElement> Workspace<W> {
self.activate_column(new_idx);
}
+ pub fn move_left(&mut self) {
+ let new_idx = self.active_column_idx.saturating_sub(1);
+ self.move_column_to(new_idx);
+ }
+
pub fn move_right(&mut self) {
if self.columns.is_empty() {
return;
}
let new_idx = min(self.active_column_idx + 1, self.columns.len() - 1);
- if self.active_column_idx == new_idx {
- return;
- }
-
- let current_x = self.view_pos();
-
- self.columns.swap(self.active_column_idx, new_idx);
-
- self.view_offset =
- self.compute_new_view_offset_for_column(current_x, self.active_column_idx);
-
- self.activate_column(new_idx);
+ self.move_column_to(new_idx);
}
pub fn move_down(&mut self) {