mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-22 02:01:55 +07:00
layout: Preserve focused window in column when window above is closed
Might be the longest standing bug in niri?
This commit is contained in:
@@ -984,7 +984,13 @@ impl<W: LayoutElement> ScrollingSpace<W> {
|
||||
is_floating: false,
|
||||
};
|
||||
|
||||
column.active_tile_idx = min(column.active_tile_idx, column.tiles.len() - 1);
|
||||
if tile_idx < column.active_tile_idx {
|
||||
// A tile above was removed; preserve the current position.
|
||||
column.active_tile_idx -= 1;
|
||||
} else {
|
||||
column.active_tile_idx = min(column.active_tile_idx, column.tiles.len() - 1);
|
||||
}
|
||||
|
||||
column.update_tile_sizes_with_transaction(true, transaction);
|
||||
self.data[column_idx].update(column);
|
||||
let offset = prev_width - column.width();
|
||||
|
||||
@@ -3012,6 +3012,31 @@ fn move_workspace_to_same_monitor_doesnt_reorder() {
|
||||
assert_eq!(counts, &[1, 2, 0]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn removing_window_above_preserves_focused_window() {
|
||||
let ops = [
|
||||
Op::AddOutput(0),
|
||||
Op::AddWindow {
|
||||
params: TestWindowParams::new(0),
|
||||
},
|
||||
Op::AddWindow {
|
||||
params: TestWindowParams::new(1),
|
||||
},
|
||||
Op::AddWindow {
|
||||
params: TestWindowParams::new(2),
|
||||
},
|
||||
Op::FocusColumnFirst,
|
||||
Op::ConsumeWindowIntoColumn,
|
||||
Op::ConsumeWindowIntoColumn,
|
||||
Op::FocusWindowDown,
|
||||
Op::CloseWindow(0),
|
||||
];
|
||||
|
||||
let layout = check_ops(&ops);
|
||||
let win = layout.focus().unwrap();
|
||||
assert_eq!(win.0.id, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn preset_column_width_fixed_correct_with_border() {
|
||||
let ops = [
|
||||
|
||||
Reference in New Issue
Block a user