Skip to content

GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.

feat(domain): set OS focus to new windows in `AddWindowHandler`

Lars Bergerbcf672bc9931
diff --git a/GlazeWM.Domain/Windows/CommandHandlers/AddWindowHandler.cs b/GlazeWM.Domain/Windows/CommandHandlers/AddWindowHandler.cs
index e6d49f6c..555a9a2b 100644
--- a/GlazeWM.Domain/Windows/CommandHandlers/AddWindowHandler.cs
+++ b/GlazeWM.Domain/Windows/CommandHandlers/AddWindowHandler.cs
@@ -98,6 +98,10 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
// isn't updated automatically.
_bus.Invoke(new SetFocusedDescendantCommand(window));
+ // Set OS focus to the newly added window in case it's not already focused. This is also
+ // necessary for window rule commands to run properly on startup with existing windows.
+ _bus.Invoke(new FocusWindowCommand(window));
+
var parsedCommands = commandStrings
.Select(commandString => _commandParsingService.ParseCommand(commandString))
.ToList();