On adding output add set after processing other sets
Maybe there's some reason for this, but I don't think the first loop needs to handle the new set. I do not expect this to change behavior.
This commit is contained in:
parent
fb2631adce
commit
229c794aad
1 changed files with 30 additions and 25 deletions
|
|
@ -647,7 +647,7 @@ impl Workspaces {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let set = self
|
let mut set = self
|
||||||
.backup_set
|
.backup_set
|
||||||
.take()
|
.take()
|
||||||
.map(|mut set| {
|
.map(|mut set| {
|
||||||
|
|
@ -665,43 +665,48 @@ impl Workspaces {
|
||||||
});
|
});
|
||||||
workspace_state.add_group_output(&set.group, &output);
|
workspace_state.add_group_output(&set.group, &output);
|
||||||
|
|
||||||
self.sets.insert(output.clone(), set);
|
// Remove workspaces that prefer this output from other sets
|
||||||
let mut moved_workspaces = Vec::new();
|
let mut moved_workspaces = Vec::new();
|
||||||
for set in self.sets.values_mut() {
|
for other_set in self.sets.values_mut() {
|
||||||
let active_handle = set.workspaces[set.active].handle;
|
let active_handle = other_set.workspaces[set.active].handle;
|
||||||
let (prefers, doesnt) = set
|
let (prefers, doesnt) = other_set
|
||||||
.workspaces
|
.workspaces
|
||||||
.drain(..)
|
.drain(..)
|
||||||
.partition(|w| w.prefers_output(output));
|
.partition(|w| w.prefers_output(output));
|
||||||
moved_workspaces.extend(prefers);
|
moved_workspaces.extend(prefers);
|
||||||
set.workspaces = doesnt;
|
other_set.workspaces = doesnt;
|
||||||
if set.workspaces.is_empty() {
|
if other_set.workspaces.is_empty() {
|
||||||
set.add_empty_workspace(workspace_state);
|
other_set.add_empty_workspace(workspace_state);
|
||||||
}
|
}
|
||||||
for (i, workspace) in set.workspaces.iter_mut().enumerate() {
|
for (i, workspace) in other_set.workspaces.iter_mut().enumerate() {
|
||||||
workspace_set_idx(workspace_state, i as u8 + 1, set.idx, &workspace.handle);
|
workspace_set_idx(
|
||||||
|
workspace_state,
|
||||||
|
i as u8 + 1,
|
||||||
|
other_set.idx,
|
||||||
|
&workspace.handle,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
set.active = set
|
other_set.active = other_set
|
||||||
.workspaces
|
.workspaces
|
||||||
.iter()
|
.iter()
|
||||||
.position(|w| w.handle == active_handle)
|
.position(|w| w.handle == active_handle)
|
||||||
.unwrap_or(set.workspaces.len() - 1);
|
.unwrap_or(other_set.workspaces.len() - 1);
|
||||||
}
|
}
|
||||||
{
|
|
||||||
let set = self.sets.get_mut(output).unwrap();
|
// Add `moved_workspaces` to set, and update output and index of workspaces
|
||||||
for workspace in &mut moved_workspaces {
|
for workspace in &mut moved_workspaces {
|
||||||
move_workspace_to_group(workspace, &set.group, workspace_state);
|
move_workspace_to_group(workspace, &set.group, workspace_state);
|
||||||
}
|
}
|
||||||
set.workspaces.extend(moved_workspaces);
|
set.workspaces.extend(moved_workspaces);
|
||||||
for (i, workspace) in set.workspaces.iter_mut().enumerate() {
|
for (i, workspace) in set.workspaces.iter_mut().enumerate() {
|
||||||
workspace.set_output(output);
|
workspace.set_output(output);
|
||||||
workspace.refresh(xdg_activation_state);
|
workspace.refresh(xdg_activation_state);
|
||||||
workspace_set_idx(workspace_state, i as u8 + 1, set.idx, &workspace.handle);
|
workspace_set_idx(workspace_state, i as u8 + 1, set.idx, &workspace.handle);
|
||||||
if i == set.active {
|
if i == set.active {
|
||||||
workspace_state.add_workspace_state(&workspace.handle, WState::Active);
|
workspace_state.add_workspace_state(&workspace.handle, WState::Active);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
self.sets.insert(output.clone(), set);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_output<'a>(
|
pub fn remove_output<'a>(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue