From ec0531264e8e51f9110d8561abe49e8be72422b7 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Mon, 8 Apr 2024 19:08:35 +0400 Subject: Avoid move_left() in expel-left --- src/layout/workspace.rs | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'src/layout') diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index 1e4c09e6..dda8b7c9 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -622,8 +622,9 @@ impl Workspace { x } - pub fn add_window( + pub fn add_window_at( &mut self, + col_idx: usize, window: W, activate: bool, width: ColumnWidth, @@ -633,12 +634,6 @@ impl Workspace { let was_empty = self.columns.is_empty(); - let idx = if self.columns.is_empty() { - 0 - } else { - self.active_column_idx + 1 - }; - let column = Column::new( window, self.view_size, @@ -648,7 +643,7 @@ impl Workspace { is_full_width, ); let width = column.width(); - self.columns.insert(idx, column); + self.columns.insert(col_idx, column); if activate { // If this is the first window on an empty workspace, skip the animation from whatever @@ -667,11 +662,27 @@ impl Workspace { let prev_offset = (!was_empty).then(|| self.static_view_offset()); - self.activate_column(idx); + self.activate_column(col_idx); self.activate_prev_column_on_removal = prev_offset; } } + pub fn add_window( + &mut self, + window: W, + activate: bool, + width: ColumnWidth, + is_full_width: bool, + ) { + let col_idx = if self.columns.is_empty() { + 0 + } else { + self.active_column_idx + 1 + }; + + self.add_window_at(col_idx, window, activate, width, is_full_width); + } + pub fn add_window_right_of( &mut self, right_of: &W::Id, @@ -1037,9 +1048,9 @@ impl Workspace { let window = self.remove_window_by_idx(self.active_column_idx, source_column.active_tile_idx); - self.add_window(window, true, width, is_full_width); - // Window was added to the right of current column, so move the new column left. - self.move_left(); + self.add_window_at(self.active_column_idx, window, true, width, is_full_width); + // We added to the left, don't activate even further left on removal. + self.activate_prev_column_on_removal = None; } } -- cgit