Skip to content

Commit

Permalink
fix(wm): avoid focus loops on ws w/ floating hwnds
Browse files Browse the repository at this point in the history
This commit adds a check which will only allow the focused workspace to
have a full update if the number of managed containers is non-zero.

Previously, this would be triggered in a loop when focusing a workspace
with only focused windows.

Going back in time to the first versions of komorebi and yatta which
didn't have so many different container and window kinds, this was
intended to be called whenever the focus was changed to update the
state.

With the complexity komorebi handles in 2025, there are also many calls
to Win32 APIs when we call self.update_focused_workspace, so we need to
be a bit more careful about when and where we call it.

re #816
  • Loading branch information
LGUG2Z committed Feb 4, 2025
1 parent 83114ed commit 95d758e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion komorebi/src/process_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,12 @@ impl WindowManager {
already_moved_window_handles.remove(&window.hwnd);
}
WindowManagerEvent::FocusChange(_, window) => {
self.update_focused_workspace(self.mouse_follows_focus, false)?;
// don't want to trigger the full workspace updates when there are no managed
// containers - this makes floating windows on empty workspaces go into very
// annoying focus change loops which prevents users from interacting with them
if !self.focused_workspace()?.containers().is_empty() {
self.update_focused_workspace(self.mouse_follows_focus, false)?;
}

let workspace = self.focused_workspace_mut()?;
let floating_window_idx = workspace
Expand Down

0 comments on commit 95d758e

Please sign in to comment.