From 20817b094d5277f633f9a9fc2131803d4240b3ce Mon Sep 17 00:00:00 2001 From: alex-ds13 <145657253+alex-ds13@users.noreply.github.com> Date: Mon, 24 Feb 2025 02:05:07 +0000 Subject: [PATCH] fix(wm): prevent floating focus change event infinite loops This commit stops the `FocusChange` event from focusing a floating window when it is the one emitting said `FocusChange` event, since it's not needed and is the cause of some flicker bugs reported! If that floating window was the one emitting the `FocusChange` event then it means it is already the foreground window, and there is no reason for us to focus the window again (since that will create an infinite loop of events). When the window emitting this event is not floating we don't try to focus the window, we simply set the focus index for the container of that window and the focused index for the window of that container. Except in one case, which is if the workspace has a monocle container, then it does focus a window, it focuses the monocle window to make sure the monocle keeps showing in front of everything and doesn't let anything come in front of it. --- komorebi/src/process_event.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index b3248861..298d6d8d 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -285,8 +285,7 @@ impl WindowManager { workspace.set_layer(WorkspaceLayer::Tiling); } Some(idx) => { - if let Some(window) = workspace.floating_windows().get(idx) { - window.focus(false)?; + if let Some(_window) = workspace.floating_windows().get(idx) { workspace.set_layer(WorkspaceLayer::Floating); } }