Preserve active workspace when workspaces are moved back to another output
Instead of preserving the active workspace index, which may not match if a workspace before it has been moved back to another output.
This commit is contained in:
parent
400a7752fd
commit
c8ebac354c
1 changed files with 6 additions and 1 deletions
|
|
@ -668,6 +668,7 @@ impl Workspaces {
|
||||||
self.sets.insert(output.clone(), set);
|
self.sets.insert(output.clone(), set);
|
||||||
let mut moved_workspaces = Vec::new();
|
let mut moved_workspaces = Vec::new();
|
||||||
for set in self.sets.values_mut() {
|
for set in self.sets.values_mut() {
|
||||||
|
let active_handle = set.workspaces[set.active].handle;
|
||||||
let (prefers, doesnt) = set
|
let (prefers, doesnt) = set
|
||||||
.workspaces
|
.workspaces
|
||||||
.drain(..)
|
.drain(..)
|
||||||
|
|
@ -677,7 +678,11 @@ impl Workspaces {
|
||||||
if set.workspaces.is_empty() {
|
if set.workspaces.is_empty() {
|
||||||
set.add_empty_workspace(workspace_state);
|
set.add_empty_workspace(workspace_state);
|
||||||
}
|
}
|
||||||
set.active = set.active.min(set.workspaces.len() - 1);
|
set.active = set
|
||||||
|
.workspaces
|
||||||
|
.iter()
|
||||||
|
.position(|w| w.handle == active_handle)
|
||||||
|
.unwrap_or(set.workspaces.len() - 1);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
let set = self.sets.get_mut(output).unwrap();
|
let set = self.sets.get_mut(output).unwrap();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue