Simplify window removal

This commit is contained in:
Ottatop 2024-05-03 00:00:38 -05:00
parent feeb139b05
commit c55a4991c4

View file

@ -48,32 +48,19 @@ impl XdgShellHandler for State {
fn toplevel_destroyed(&mut self, surface: ToplevelSurface) { fn toplevel_destroyed(&mut self, surface: ToplevelSurface) {
tracing::debug!("toplevel destroyed"); tracing::debug!("toplevel destroyed");
self.pinnacle.windows.retain(|window| {
window
.wl_surface()
.is_some_and(|surf| &surf != surface.wl_surface())
});
self.pinnacle.z_index_stack.retain(|window| {
window
.wl_surface()
.is_some_and(|surf| &surf != surface.wl_surface())
});
for output in self.pinnacle.space.outputs() {
output.with_state_mut(|state| {
state.focus_stack.stack.retain(|window| {
window
.wl_surface()
.is_some_and(|surf| &surf != surface.wl_surface())
})
});
}
let Some(window) = self.pinnacle.window_for_surface(surface.wl_surface()) else { let Some(window) = self.pinnacle.window_for_surface(surface.wl_surface()) else {
return; return;
}; };
self.pinnacle.windows.retain(|win| win != &window);
self.pinnacle.z_index_stack.retain(|win| win != &window);
for output in self.pinnacle.space.outputs() {
output.with_state_mut(|state| state.focus_stack.stack.retain(|win| win != &window));
}
if let Some(output) = window.output(&self.pinnacle) { if let Some(output) = window.output(&self.pinnacle) {
self.pinnacle.request_layout(&output); self.pinnacle.request_layout(&output);