forge
Explore
Log in

Don't you dare go Hollow

Place new workspace after current when moving

Browse files at this commit

1f72089a46a965fa98c833de3c76da2fb8b6a5f7Ivan MolodetskikhParent: fbe9020
This feels more natural, also makes moving back and forth idempotent in
most cases.
src/layout/mod.rsmodified+7 -1
@@ -29,6 +29,7 @@
29 //! compromise we only keep the first workspace there, and move the rest to the primary output,29 //! compromise we only keep the first workspace there, and move the rest to the primary output,
30 //! making the primary output their original output.30 //! making the primary output their original output.
31 31
32+use std::cmp::min;
32 use std::mem;33 use std::mem;
33 use std::rc::Rc;34 use std::rc::Rc;
34 use std::time::Duration;35 use std::time::Duration;
@@ -1364,7 +1365,12 @@ impl<W: LayoutElement> Layout<W> {
1364 .position(|mon| &mon.output == output)1365 .position(|mon| &mon.output == output)
1365 .unwrap();1366 .unwrap();
1366 let target = &mut monitors[target_idx];1367 let target = &mut monitors[target_idx];
1367- target.workspaces.insert(target.active_workspace_idx, ws);1368+
1369+ // Insert the workspace after the currently active one. Unless the currently active one is
1370+ // the last empty workspace, then insert before.
1371+ let target_ws_idx = min(target.active_workspace_idx + 1, target.workspaces.len() - 1);
1372+ target.workspaces.insert(target_ws_idx, ws);
1373+ target.active_workspace_idx = target_ws_idx;
1368 target.workspace_switch = None;1374 target.workspace_switch = None;
1369 target.clean_up_workspaces();1375 target.clean_up_workspaces();
1370 1376