shell: Refresh focus-stacks after swap

This commit is contained in:
Victoria Brekenfeld 2023-09-11 21:11:34 +02:00
parent 6b4eb83af5
commit 7ba52d7162
2 changed files with 15 additions and 5 deletions

View file

@ -289,25 +289,28 @@ impl State {
let mut spaces = data.common.shell.workspaces.spaces_mut();
if old_descriptor.handle != new_descriptor.handle {
let (mut old_w, mut other_w) = spaces.partition::<Vec<_>, _>(|w| w.handle == old_descriptor.handle);
if let Some(old_tiling_layer) = old_w.get_mut(0).map(|w| &mut w.tiling_layer) {
if let Some(new_tiling_layer) = other_w.iter_mut().find(|w| w.handle == new_descriptor.handle).map(|w| &mut w.tiling_layer) {
if let Some(focus) = TilingLayout::swap_trees(old_tiling_layer, Some(new_tiling_layer), &old_descriptor, &new_descriptor) {
if let Some(old_workspace) = old_w.get_mut(0) {
if let Some(new_workspace) = other_w.iter_mut().find(|w| w.handle == new_descriptor.handle) {
if let Some(focus) = TilingLayout::swap_trees(&mut old_workspace.tiling_layer, Some(&mut new_workspace.tiling_layer), &old_descriptor, &new_descriptor, &mut data.common.shell.toplevel_info_state) {
let seat = seat.clone();
data.common.event_loop_handle.insert_idle(move |data| {
Common::set_focus(&mut data.state, Some(&focus), &seat, None);
});
}
old_workspace.refresh_focus_stack();
new_workspace.refresh_focus_stack();
}
}
} else {
if let Some(tiling_layer) = spaces.find(|w| w.handle == new_descriptor.handle).map(|w| &mut w.tiling_layer) {
if let Some(focus) = TilingLayout::swap_trees(tiling_layer, None, &old_descriptor, &new_descriptor) {
if let Some(workspace) = spaces.find(|w| w.handle == new_descriptor.handle) {
if let Some(focus) = TilingLayout::swap_trees(&mut workspace.tiling_layer, None, &old_descriptor, &new_descriptor, &mut data.common.shell.toplevel_info_state) {
std::mem::drop(spaces);
let seat = seat.clone();
data.common.event_loop_handle.insert_idle(move |data| {
Common::set_focus(&mut data.state, Some(&focus), &seat, None);
});
}
workspace.refresh_focus_stack();
}
}
}

View file

@ -108,6 +108,13 @@ impl Workspace {
self.tiling_layer.refresh();
}
pub fn refresh_focus_stack(&mut self) {
let windows: Vec<CosmicMapped> = self.mapped().cloned().collect();
for stack in self.focus_stack.0.values_mut() {
stack.retain(|w| windows.contains(w));
}
}
pub fn animations_going(&self) -> bool {
self.tiling_layer.animations_going()
}