diff --git a/packages/wm/src/common/events/handle_window_destroyed.rs b/packages/wm/src/common/events/handle_window_destroyed.rs index 0dfb919bc..da211622e 100644 --- a/packages/wm/src/common/events/handle_window_destroyed.rs +++ b/packages/wm/src/common/events/handle_window_destroyed.rs @@ -1,8 +1,11 @@ +use anyhow::Context; use tracing::info; use crate::{ common::platform::NativeWindow, windows::commands::unmanage_window, wm_state::WmState, + containers::traits::CommonGetters, + workspaces::commands::deactivate_workspace }; pub fn handle_window_destroyed( @@ -14,8 +17,15 @@ pub fn handle_window_destroyed( // Unmanage the window if it's currently managed. if let Some(window) = found_window { // TODO: Log window details. + let workspace = window.workspace().context("No workspace.")?; + info!("Window closed"); unmanage_window(window, state)?; + + // Destroy parent workspace if window was killed while its workspace was not displayed (e.g. via task manager). + if !workspace.config().keep_alive && !workspace.has_children() && !workspace.is_displayed() { + deactivate_workspace(workspace, state)?; + } } Ok(())