Skip to content

Commit

Permalink
fix(wm): focus single window on show event
Browse files Browse the repository at this point in the history
This commit makes sure we refocus the window on `Show` event when it is
the only window on the workspace.

This is needed because some windows send the `FocusChange` event before
the `Show` event and on the first event we will be focusing the desktop
window to unfocus any previous window from other workspace because the
workspace will still be empty. So after adding the window, we need to
focus it again.
  • Loading branch information
alex-ds13 authored and LGUG2Z committed Oct 28, 2024
1 parent 73d9287 commit 4acd408
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions komorebi/src/process_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,21 @@ impl WindowManager {
}
}
}

if (self.focused_workspace()?.containers().len() == 1
&& self.focused_workspace()?.floating_windows().is_empty())
|| (self.focused_workspace()?.containers().is_empty()
&& self.focused_workspace()?.floating_windows().len() == 1)
{
// If after adding this window the workspace only contains 1 window, it
// means it was previously empty and we focused the desktop to unfocus
// any previous window from other workspace, so now we need to focus
// this window again. This is needed because sometimes some windows
// first send the `FocusChange` event and only the `Show` event after
// and we will be focusing the desktop on the `FocusChange` event since
// it is still empty.
window.focus(self.mouse_follows_focus)?;
}
}

if workspace_contains_window {
Expand Down

0 comments on commit 4acd408

Please sign in to comment.