diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-04-08 19:08:35 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-04-08 19:11:25 +0400 |
| commit | ec0531264e8e51f9110d8561abe49e8be72422b7 (patch) | |
| tree | 5b2e478e28805570ab9b0865980f320d79ceace4 /src/layout/workspace.rs | |
| parent | 03fc439150c5a0006a4e86d1e2ad33fede0ddaca (diff) | |
| download | niri-ec0531264e8e51f9110d8561abe49e8be72422b7.tar.gz niri-ec0531264e8e51f9110d8561abe49e8be72422b7.tar.bz2 niri-ec0531264e8e51f9110d8561abe49e8be72422b7.zip | |
Avoid move_left() in expel-left
Diffstat (limited to 'src/layout/workspace.rs')
| -rw-r--r-- | src/layout/workspace.rs | 35 |
1 files changed, 23 insertions, 12 deletions
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<W: LayoutElement> Workspace<W> { 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<W: LayoutElement> Workspace<W> { 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<W: LayoutElement> Workspace<W> { 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<W: LayoutElement> Workspace<W> { 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<W: LayoutElement> Workspace<W> { 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; } } |
