From bdf66cc362f8de4342d02e2edca431109c2055bf Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 19 May 2024 11:08:04 -0700 Subject: [PATCH] feat(wm): auto toggle-monocle on alt-tab This commit adds a change to automatically toggle monocle mode off on the focused workspace when a window on the same workspace is foregrounded by alt-tab. resolve #834 --- komorebi/src/process_event.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 94701736..a276baf2 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -334,8 +334,10 @@ impl WindowManager { if proceed { let behaviour = self.window_container_behaviour; let workspace = self.focused_workspace_mut()?; + let workspace_contains_window = workspace.contains_window(window.hwnd); + let workspace_has_monocle_container = workspace.monocle_container().is_some(); - if !workspace.contains_window(window.hwnd) && !needs_reconciliation { + if !workspace_contains_window && !needs_reconciliation { match behaviour { WindowContainerBehaviour::Create => { workspace.new_container_for_window(window); @@ -350,6 +352,11 @@ impl WindowManager { } } } + + if workspace_contains_window && workspace_has_monocle_container { + self.toggle_monocle()?; + window.focus(self.mouse_follows_focus)?; + } } } WindowManagerEvent::MoveResizeStart(_, window) => {