Skip to content

Commit

Permalink
feat: deactivate empty non-current workspace on window close (#801)
Browse files Browse the repository at this point in the history
  • Loading branch information
DreamMaoMao authored Oct 22, 2024
1 parent 3e2f5f2 commit 04f9b0d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/wm/src/common/events/handle_window_destroyed.rs
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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(())
Expand Down

0 comments on commit 04f9b0d

Please sign in to comment.