forge
Explore
Log in

Don't you dare go Hollow

layout/scrolling: Fix add_column() skipping activate_column() sometimes

Browse files at this commit

c4462d0c7fddfc11c9e98d43e3ef68a5b3c844caIvan MolodetskikhParent: f85cb5c
When the column was added immediately to the left of the current column
and activated, the new idx would be equal to active_column_idx, which
would skip activate_column() with its variable resets.
src/layout/scrolling.rsmodified+4 -2
@@ -986,6 +986,10 @@ impl<W: LayoutElement> ScrollingSpace<W> {
986 self.data.insert(idx, ColumnData::new(&column));986 self.data.insert(idx, ColumnData::new(&column));
987 self.columns.insert(idx, column);987 self.columns.insert(idx, column);
988 988
989+ if !was_empty && idx <= self.active_column_idx {
990+ self.active_column_idx += 1;
991+ }
992+
989 if activate {993 if activate {
990 // If this is the first window on an empty workspace, remove the effect of whatever994 // If this is the first window on an empty workspace, remove the effect of whatever
991 // view_offset was left over and skip the animation.995 // view_offset was left over and skip the animation.
@@ -1002,8 +1006,6 @@ impl<W: LayoutElement> ScrollingSpace<W> {
1002 anim_config.unwrap_or(self.options.animations.horizontal_view_movement.0);1006 anim_config.unwrap_or(self.options.animations.horizontal_view_movement.0);
1003 self.activate_column_with_anim_config(idx, anim_config);1007 self.activate_column_with_anim_config(idx, anim_config);
1004 self.activate_prev_column_on_removal = prev_offset;1008 self.activate_prev_column_on_removal = prev_offset;
1005- } else if !was_empty && idx <= self.active_column_idx {
1006- self.active_column_idx += 1;
1007 }1009 }
1008 1010
1009 // Animate movement of other columns.1011 // Animate movement of other columns.
src/layout/tests.rsmodified+28 -0
@@ -3674,6 +3674,34 @@ fn tabs_with_different_border() {
3674 check_ops_with_options(options, ops);3674 check_ops_with_options(options, ops);
3675 }3675 }
3676 3676
3677+#[test]
3678+fn expel_pending_left_from_fullscreen_tabbed_column() {
3679+ let ops = [
3680+ Op::AddOutput(1),
3681+ Op::AddWindow {
3682+ params: TestWindowParams::new(1),
3683+ },
3684+ Op::FullscreenWindow(1),
3685+ Op::Communicate(1),
3686+ // 1 is now fullscreen, view_offset_to_restore is set.
3687+ Op::ToggleColumnTabbedDisplay,
3688+ Op::AddWindow {
3689+ params: TestWindowParams::new(2),
3690+ },
3691+ Op::ConsumeOrExpelWindowLeft { id: Some(2) },
3692+ // 2 is consumed into a fullscreen column, fullscreen is requested but not applied.
3693+ //
3694+ // Now, get it back out while keeping it focused.
3695+ //
3696+ // Importantly, we expel it *left*, which results in adding a new column with the exact
3697+ // same active_column_idx.
3698+ Op::FocusWindow(2),
3699+ Op::ConsumeOrExpelWindowLeft { id: None },
3700+ ];
3701+
3702+ check_ops(ops);
3703+}
3704+
3677 fn parent_id_causes_loop(layout: &Layout<TestWindow>, id: usize, mut parent_id: usize) -> bool {3705 fn parent_id_causes_loop(layout: &Layout<TestWindow>, id: usize, mut parent_id: usize) -> bool {
3678 if parent_id == id {3706 if parent_id == id {
3679 return true;3707 return true;