Skip to content

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

feat(domain): allow `SetFocusDescendantCommand` to set last focused descendant up until an end ancestor

Lars Berger773b991c8158
diff --git a/GlazeWM.Domain/Containers/CommandHandlers/SetFocusedDescendantHandler.cs b/GlazeWM.Domain/Containers/CommandHandlers/SetFocusedDescendantHandler.cs
index 356bc688..e1e476ec 100644
--- a/GlazeWM.Domain/Containers/CommandHandlers/SetFocusedDescendantHandler.cs
+++ b/GlazeWM.Domain/Containers/CommandHandlers/SetFocusedDescendantHandler.cs
@@ -6,22 +6,19 @@ namespace GlazeWM.Domain.Containers.CommandHandlers
{
class SetFocusedDescendantHandler : ICommandHandler<SetFocusedDescendantCommand>
{
- private Bus _bus;
- private ContainerService _containerService;
-
- public SetFocusedDescendantHandler(Bus bus, ContainerService containerService)
+ public SetFocusedDescendantHandler()
{
- _bus = bus;
- _containerService = containerService;
}
public CommandResponse Handle(SetFocusedDescendantCommand command)
{
- var focusDescendant = command.FocusedDescendant;
+ var focusedDescendant = command.FocusedDescendant;
+ var endAncestor = command.EndAncestor;
- // Traverse upwards, setting the container as the last focused.
- var target = focusDescendant;
- while (target.Parent != null)
+ // Traverse upwards, setting the container as the last focused until the root container
+ // or `endAncestor` (if provided) is reached.
+ var target = focusedDescendant;
+ while (target.Parent != null && target != endAncestor)
{
target.Parent.ChildFocusOrder.MoveToFront(target);
target = target.Parent;
diff --git a/GlazeWM.Domain/Containers/Commands/SetFocusedDescendantCommand.cs b/GlazeWM.Domain/Containers/Commands/SetFocusedDescendantCommand.cs
index 58f5b884..2a68f1b0 100644
--- a/GlazeWM.Domain/Containers/Commands/SetFocusedDescendantCommand.cs
+++ b/GlazeWM.Domain/Containers/Commands/SetFocusedDescendantCommand.cs
@@ -5,10 +5,12 @@ namespace GlazeWM.Domain.Containers.Commands
public class SetFocusedDescendantCommand : Command
{
public Container FocusedDescendant { get; }
+ public Container EndAncestor { get; }
- public SetFocusedDescendantCommand(Container focusedDescendant)
+ public SetFocusedDescendantCommand(Container focusedDescendant, Container endAncestor = null)
{
FocusedDescendant = focusedDescendant;
+ EndAncestor = endAncestor;
}
}
}