Skip to content

Commit

Permalink
fix(wm): respect horizontal focus from monocle
Browse files Browse the repository at this point in the history
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
  • Loading branch information
LGUG2Z committed May 19, 2024
1 parent 2a45f98 commit 9244772
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
19 changes: 18 additions & 1 deletion komorebi/src/process_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) => {
Expand Down
6 changes: 5 additions & 1 deletion komorebi/src/window_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 9244772

Please sign in to comment.