shell: Handle WorkspaceMode::Global in move_workspace()

If workspaces span across outputs, the `Workspace` at a particular
index should be moved on every `WorkspaceSet`.
This commit is contained in:
Ian Douglas Scott 2025-09-18 11:38:39 -07:00 committed by Victoria Brekenfeld
parent b8ffc89948
commit d8281ed51b

View file

@ -928,6 +928,8 @@ impl Workspaces {
return; return;
}; };
match self.mode {
WorkspaceMode::OutputBound => {
// Check which workspace is active on the new set; before removing from the // Check which workspace is active on the new set; before removing from the
// old set in cause we're moving an active workspace within the same set. // old set in cause we're moving an active workspace within the same set.
let new_set = &mut self.sets[&new_output]; let new_set = &mut self.sets[&new_output];
@ -974,6 +976,46 @@ impl Workspaces {
new_set.update_workspace_idxs(workspace_state); new_set.update_workspace_idxs(workspace_state);
} }
WorkspaceMode::Global => {
let old_set = &mut self.sets[&old_output];
let old_idx = old_set
.workspaces
.iter()
.position(|w| w.handle == *handle)
.unwrap();
let new_set = &mut self.sets[&new_output];
let other_idx = new_set
.workspaces
.iter()
.position(|w| w.handle == *other_handle)
.unwrap();
// Move workspace at given index on every output
for set in self.sets.values_mut() {
if old_idx < set.workspaces.len() && other_idx < set.workspaces.len() {
let previous_active_handle = set.workspaces[set.active].handle;
if other_idx > old_idx {
let insert_idx = if after { other_idx } else { other_idx - 1 };
set.workspaces[old_idx..=insert_idx].rotate_left(1);
} else {
let insert_idx = if after { other_idx + 1 } else { other_idx };
set.workspaces[insert_idx..=old_idx].rotate_right(1);
}
set.active = set
.workspaces
.iter()
.position(|w| w.handle == previous_active_handle)
.unwrap();
set.update_workspace_idxs(workspace_state);
}
}
}
}
}
pub fn update_config( pub fn update_config(
&mut self, &mut self,