Skip to content

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

feat(domain): change the focused container to be computed off the last focused descendant of root node

Lars Bergerfeb6c8e7a764
diff --git a/LarsWM.Domain/Containers/ContainerService.cs b/LarsWM.Domain/Containers/ContainerService.cs
index e8183e81..bc3999f5 100644
--- a/LarsWM.Domain/Containers/ContainerService.cs
+++ b/LarsWM.Domain/Containers/ContainerService.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using LarsWM.Domain.Common.Enums;
using LarsWM.Domain.UserConfigs;
@@ -22,7 +22,7 @@ namespace LarsWM.Domain.Containers
/// The currently focused container. This can either be a `Window` or a
/// `Workspace` without any descendant windows.
/// </summary>
- public Container FocusedContainer { get; set; } = null;
+ public Container FocusedContainer => ContainerTree.LastFocusedDescendant;
private UserConfigService _userConfigService;
diff --git a/LarsWM.Domain/Windows/CommandHandlers/FocusWindowHandler.cs b/LarsWM.Domain/Windows/CommandHandlers/FocusWindowHandler.cs
index fadb1e43..22aad9e1 100644
--- a/LarsWM.Domain/Windows/CommandHandlers/FocusWindowHandler.cs
+++ b/LarsWM.Domain/Windows/CommandHandlers/FocusWindowHandler.cs
@@ -25,8 +25,6 @@ namespace LarsWM.Domain.Windows.CommandHandlers
if (window == _containerService.FocusedContainer)
return CommandResponse.Ok;
- _containerService.FocusedContainer = window;
-
// Adjust focus order of ancestors.
_bus.Invoke(new SetFocusedDescendantCommand(window));
diff --git a/LarsWM.Domain/Workspaces/CommandHandlers/FocusWorkspaceHandler.cs b/LarsWM.Domain/Workspaces/CommandHandlers/FocusWorkspaceHandler.cs
index 574d8795..4eb9f3cd 100644
--- a/LarsWM.Domain/Workspaces/CommandHandlers/FocusWorkspaceHandler.cs
+++ b/LarsWM.Domain/Workspaces/CommandHandlers/FocusWorkspaceHandler.cs
@@ -56,7 +56,6 @@ namespace LarsWM.Domain.Workspaces.CommandHandlers
// If workspace has no descendant windows, set focus to the workspace itself.
if (!workspaceToFocus.HasChildren())
{
- _containerService.FocusedContainer = workspaceToFocus;
_bus.RaiseEvent(new FocusChangedEvent(workspaceToFocus));
// Remove focus from whichever window currently has focus.