fix(wm): disable monocle mode if window is closed

This commit ensures that monocle mode will be automatically disabled if
the last window in a monocle container is closed.
This commit is contained in:
LGUG2Z committed 2025-11-29 14:41:25 -08:00
1 parent 6b980a0360
commit 2ff76f0881
3 files changed
+40 -3

No files matched your search

+3
View File
@@ -27,6 +27,9 @@ build target:
run target:
cargo +stable run --bin {{ target }} --locked
error target $RUST_LOG="komorebi=error":
just run {{ target }}
warn target $RUST_LOG="komorebi=warn":
just run {{ target }}
+21 -3
View File
@@ -80,6 +80,22 @@ fn handle_notifications(wm: Arc<Mutex<WindowManager>>) -> color_eyre::Result<()>
});
}
if let Some(container) = &mut workspace.monocle_container {
container.windows_mut().retain(|w| {
if w.id == window_id {
should_update = true;
tracing::info!("reaping window: {window_id}");
}
w.id != window_id
});
if container.windows().is_empty() {
workspace.monocle_container = None;
workspace.monocle_container_restore_idx = None;
}
}
workspace.floating_windows_mut().retain(|w| {
if w.id == window_id {
should_update = true;
@@ -91,9 +107,11 @@ fn handle_notifications(wm: Arc<Mutex<WindowManager>>) -> color_eyre::Result<()>
}
}
// If an invalid window was cleaned up, we update the workspace
wm.update_focused_workspace(false, false)?;
border_manager::send_notification(None, Some(window_id));
if should_update {
// If an invalid window was cleaned up, we update the workspace
wm.update_focused_workspace(false, false)?;
border_manager::send_notification(None, Some(window_id));
}
}
ReaperNotification::MouseUpKeyUp => {
// this first one will do a "nothing" update to check if any windows failed
+16
View File
@@ -415,6 +415,22 @@ impl Workspace {
}
}
if let Some(container) = &self.monocle_container
&& let Some(focused_window) = container.focused_window()
{
if focused_window.application.process_id == process_id
&& !valid_window_ids.contains(&focused_window.id)
{
invalid_window_ids.push(focused_window.id);
}
// if accessibility API calls fail on AXError::InvalidUIElement
// let's try and nuke these early
if !focused_window.is_valid() {
invalid_window_ids.push(focused_window.id);
}
}
for window in self.floating_windows() {
if window.application.process_id == process_id {
if !valid_window_ids.contains(&window.id) {