Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: automatically deactivate non-current workspaces when all window… #801

Merged
merged 3 commits into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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