Skip to content

Commit c4462d0

Browse files
committed
layout/scrolling: Fix add_column() skipping activate_column() sometimes
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.
1 parent f85cb5c commit c4462d0

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

src/layout/scrolling.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,10 @@ impl<W: LayoutElement> ScrollingSpace<W> {
986986
self.data.insert(idx, ColumnData::new(&column));
987987
self.columns.insert(idx, column);
988988

989+
if !was_empty && idx <= self.active_column_idx {
990+
self.active_column_idx += 1;
991+
}
992+
989993
if activate {
990994
// If this is the first window on an empty workspace, remove the effect of whatever
991995
// view_offset was left over and skip the animation.
@@ -1002,8 +1006,6 @@ impl<W: LayoutElement> ScrollingSpace<W> {
10021006
anim_config.unwrap_or(self.options.animations.horizontal_view_movement.0);
10031007
self.activate_column_with_anim_config(idx, anim_config);
10041008
self.activate_prev_column_on_removal = prev_offset;
1005-
} else if !was_empty && idx <= self.active_column_idx {
1006-
self.active_column_idx += 1;
10071009
}
10081010

10091011
// Animate movement of other columns.

src/layout/tests.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3674,6 +3674,34 @@ fn tabs_with_different_border() {
36743674
check_ops_with_options(options, ops);
36753675
}
36763676

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+
36773705
fn parent_id_causes_loop(layout: &Layout<TestWindow>, id: usize, mut parent_id: usize) -> bool {
36783706
if parent_id == id {
36793707
return true;

0 commit comments

Comments
 (0)