aboutsummaryrefslogtreecommitdiff
path: root/src/layout.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2023-09-24 09:42:49 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2023-09-24 09:42:49 +0400
commitb3b1e082ac16a93f19be01604cd4d764f004267e (patch)
tree45e250e014a86f5ae5f2e0f0eb261bd6fed78cad /src/layout.rs
parent34db4bcd48af7ed382eb62ab5810f476e28a73a4 (diff)
downloadniri-b3b1e082ac16a93f19be01604cd4d764f004267e.tar.gz
niri-b3b1e082ac16a93f19be01604cd4d764f004267e.tar.bz2
niri-b3b1e082ac16a93f19be01604cd4d764f004267e.zip
layout: Preserve active column when column to the left is removed
Diffstat (limited to 'src/layout.rs')
-rw-r--r--src/layout.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/layout.rs b/src/layout.rs
index 2c0ef30f..dbcc5083 100644
--- a/src/layout.rs
+++ b/src/layout.rs
@@ -1459,12 +1459,21 @@ impl<W: LayoutElement> Workspace<W> {
let window_idx = column.windows.iter().position(|win| win == window).unwrap();
column.windows.remove(window_idx);
if column.windows.is_empty() {
+ // FIXME: activate_column below computes current view position to compute the new view
+ // position, which can include the column we're removing here. This leads to unwanted
+ // view jumps.
self.columns.remove(column_idx);
if self.columns.is_empty() {
return;
}
- self.activate_column(min(self.active_column_idx, self.columns.len() - 1));
+ if self.active_column_idx > column_idx {
+ // A column to the left was removed; preserve the current position.
+ self.activate_column(self.active_column_idx - 1);
+ } else {
+ self.activate_column(min(self.active_column_idx, self.columns.len() - 1));
+ }
+
return;
}