diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2025-09-25 18:15:46 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-10-02 09:33:08 +0300 |
| commit | 3b4cf1ec8f0eea992740a33e143917edb761eb7d (patch) | |
| tree | aad7f71cc659a5bc4f5177d4e87463762769b4ee /src/layout/mod.rs | |
| parent | 1484175408b72fe6d267bc08036319969fc39ea1 (diff) | |
| download | niri-3b4cf1ec8f0eea992740a33e143917edb761eb7d.tar.gz niri-3b4cf1ec8f0eea992740a33e143917edb761eb7d.tar.bz2 niri-3b4cf1ec8f0eea992740a33e143917edb761eb7d.zip | |
layout: Extract Monitor::remove_workspace_by_idx()
Diffstat (limited to 'src/layout/mod.rs')
| -rw-r--r-- | src/layout/mod.rs | 32 |
1 files changed, 2 insertions, 30 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 60c0f1fe..084c0236 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -3414,19 +3414,7 @@ impl<W: LayoutElement> Layout<W> { return false; } - if current.active_workspace_idx == current.workspaces.len() - 1 { - // Insert a new empty workspace. - current.add_workspace_bottom(); - } - if current.options.layout.empty_workspace_above_first && current.active_workspace_idx == 0 { - current.add_workspace_top(); - } - - let mut ws = current.workspaces.remove(current.active_workspace_idx); - current.active_workspace_idx = current.active_workspace_idx.saturating_sub(1); - current.workspace_switch = None; - current.clean_up_workspaces(); - + let mut ws = current.remove_workspace_by_idx(current.active_workspace_idx); ws.set_output(Some(output.clone())); ws.original_output = OutputId::new(output); @@ -3500,23 +3488,7 @@ impl<W: LayoutElement> Layout<W> { let current_active_ws_idx = current.active_workspace_idx; - if old_idx == current.workspaces.len() - 1 { - // Insert a new empty workspace. - current.add_workspace_bottom(); - } - - let mut ws = current.workspaces.remove(old_idx); - - if current.options.layout.empty_workspace_above_first && old_idx == 0 { - current.add_workspace_top(); - } - - if old_idx < current.active_workspace_idx { - current.active_workspace_idx -= 1; - } - current.workspace_switch = None; - current.clean_up_workspaces(); - + let mut ws = current.remove_workspace_by_idx(old_idx); ws.set_output(Some(new_output.clone())); ws.original_output = OutputId::new(&new_output); |
