forge
Explore
Log in

Don't you dare go Hollow

Avoid move_left() in expel-left

Browse files at this commit

ec0531264e8e51f9110d8561abe49e8be72422b7Ivan MolodetskikhParent: 03fc439
src/layout/workspace.rsmodified+23 -12
@@ -622,8 +622,9 @@ impl<W: LayoutElement> Workspace<W> {
622 x622 x
623 }623 }
624 624
625- pub fn add_window(625+ pub fn add_window_at(
626 &mut self,626 &mut self,
627+ col_idx: usize,
627 window: W,628 window: W,
628 activate: bool,629 activate: bool,
629 width: ColumnWidth,630 width: ColumnWidth,
@@ -633,12 +634,6 @@ impl<W: LayoutElement> Workspace<W> {
633 634
634 let was_empty = self.columns.is_empty();635 let was_empty = self.columns.is_empty();
635 636
636- let idx = if self.columns.is_empty() {
637- 0
638- } else {
639- self.active_column_idx + 1
640- };
641-
642 let column = Column::new(637 let column = Column::new(
643 window,638 window,
644 self.view_size,639 self.view_size,
@@ -648,7 +643,7 @@ impl<W: LayoutElement> Workspace<W> {
648 is_full_width,643 is_full_width,
649 );644 );
650 let width = column.width();645 let width = column.width();
651- self.columns.insert(idx, column);646+ self.columns.insert(col_idx, column);
652 647
653 if activate {648 if activate {
654 // If this is the first window on an empty workspace, skip the animation from whatever649 // If this is the first window on an empty workspace, skip the animation from whatever
@@ -667,11 +662,27 @@ impl<W: LayoutElement> Workspace<W> {
667 662
668 let prev_offset = (!was_empty).then(|| self.static_view_offset());663 let prev_offset = (!was_empty).then(|| self.static_view_offset());
669 664
670- self.activate_column(idx);665+ self.activate_column(col_idx);
671 self.activate_prev_column_on_removal = prev_offset;666 self.activate_prev_column_on_removal = prev_offset;
672 }667 }
673 }668 }
674 669
670+ pub fn add_window(
671+ &mut self,
672+ window: W,
673+ activate: bool,
674+ width: ColumnWidth,
675+ is_full_width: bool,
676+ ) {
677+ let col_idx = if self.columns.is_empty() {
678+ 0
679+ } else {
680+ self.active_column_idx + 1
681+ };
682+
683+ self.add_window_at(col_idx, window, activate, width, is_full_width);
684+ }
685+
675 pub fn add_window_right_of(686 pub fn add_window_right_of(
676 &mut self,687 &mut self,
677 right_of: &W::Id,688 right_of: &W::Id,
@@ -1037,9 +1048,9 @@ impl<W: LayoutElement> Workspace<W> {
1037 let window =1048 let window =
1038 self.remove_window_by_idx(self.active_column_idx, source_column.active_tile_idx);1049 self.remove_window_by_idx(self.active_column_idx, source_column.active_tile_idx);
1039 1050
1040- self.add_window(window, true, width, is_full_width);1051+ self.add_window_at(self.active_column_idx, window, true, width, is_full_width);
1041- // Window was added to the right of current column, so move the new column left.1052+ // We added to the left, don't activate even further left on removal.
1042- self.move_left();1053+ self.activate_prev_column_on_removal = None;
1043 }1054 }
1044 }1055 }
1045 1056