From 3b4cf1ec8f0eea992740a33e143917edb761eb7d Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Thu, 25 Sep 2025 18:15:46 +0300 Subject: layout: Extract Monitor::remove_workspace_by_idx() --- src/layout/mod.rs | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) (limited to 'src/layout/mod.rs') 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 Layout { 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 Layout { 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); -- cgit