Skip to content

Commit

Permalink
feat: automatically deactivate non-current workspaces when all window…
Browse files Browse the repository at this point in the history
…s in the workspace have been destroyed
  • Loading branch information
DreamMaoMao committed Oct 20, 2024
1 parent 8eb71b8 commit 0074716
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/wm/src/common/events/handle_window_destroyed.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use tracing::info;

use crate::{
common::platform::NativeWindow, windows::commands::unmanage_window,
common::platform::NativeWindow, windows::commands::unmanage_window,
wm_state::WmState,
containers::traits::CommonGetters,
workspaces::commands::deactivate_workspace
};

pub fn handle_window_destroyed(
Expand All @@ -14,8 +16,16 @@ pub fn handle_window_destroyed(
// Unmanage the window if it's currently managed.
if let Some(window) = found_window {
// TODO: Log window details.
let bind_workspace = window.workspace();

info!("Window closed");
unmanage_window(window, state)?;

if let Some(workspace) = bind_workspace {
if !workspace.config().keep_alive && !workspace.has_children() && !workspace.is_displayed() {
deactivate_workspace(workspace, state)?;
}
}
}

Ok(())
Expand Down

0 comments on commit 0074716

Please sign in to comment.