From 92447723d28d9d8d14b0b308ba5aa811641658f1 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 19 May 2024 12:45:34 -0700 Subject: [PATCH] fix(wm): respect horizontal focus from monocle This commit ensures that horizontal focus moves onto other monitors from a monocle container are respected (ie. we don't try moving left/right within the workspace on the focused monitor). Additionally, if the user tries to alt-tab a window to the foreground on a workspace where a monocle container exists, the window will flash before being hidden behind the monocle container as a visual cue that monocle mode needs to be disabled to access that window. This is in contrast to the current behaviour where that window floats on top of the monocle container in a somewhat broken state. re #834 --- komorebi/src/process_event.rs | 19 ++++++++++++++++++- komorebi/src/window_manager.rs | 6 +++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 94701736f..0cd9dd123 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 monocle_container = workspace.monocle_container().clone(); - 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,21 @@ impl WindowManager { } } } + + if workspace_contains_window { + let mut monocle_window_event = false; + if let Some(ref monocle) = monocle_container { + if let Some(monocle_window) = monocle.focused_window() { + if monocle_window.hwnd == window.hwnd { + monocle_window_event = true; + } + } + } + + if !monocle_window_event && monocle_container.is_some() { + window.hide(); + } + } } } WindowManagerEvent::MoveResizeStart(_, window) => { diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 1b6b8caf4..4dbd92c39 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -1129,7 +1129,11 @@ impl WindowManager { tracing::info!("focusing container"); - let new_idx = workspace.new_idx_for_direction(direction); + let new_idx = if workspace.monocle_container().is_some() { + None + } else { + workspace.new_idx_for_direction(direction) + }; let mut cross_monitor_monocle = false;