GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
fix: windows not hiding correctly after switching workspace focus (#167)
lars-bergerbc5f844a9d0b
diff --git a/GlazeWM.Domain/Workspaces/CommandHandlers/FocusWorkspaceHandler.cs b/GlazeWM.Domain/Workspaces/CommandHandlers/FocusWorkspaceHandler.csindex a5ed6ed3..98eaf88c 100644--- a/GlazeWM.Domain/Workspaces/CommandHandlers/FocusWorkspaceHandler.cs+++ b/GlazeWM.Domain/Workspaces/CommandHandlers/FocusWorkspaceHandler.cs@@ -39,8 +39,9 @@ namespace GlazeWM.Domain.Workspaces.CommandHandlersvar workspaceToFocus = _workspaceService.GetActiveWorkspaceByName(workspaceName)?? ActivateWorkspace(workspaceName);- // Get the currently focused workspace.+ // Get the currently focused and displayed workspaces.var focusedWorkspace = _workspaceService.GetFocusedWorkspace();+ var displayedWorkspace = (workspaceToFocus.Parent as Monitor).DisplayedWorkspace;if (focusedWorkspace == workspaceToFocus)return CommandResponse.Ok;@@ -58,7 +59,7 @@ namespace GlazeWM.Domain.Workspaces.CommandHandlers_bus.Emit(new FocusChangedEvent(containerToFocus));// Display the workspace to switch focus to.- _containerService.ContainersToRedraw.Add(focusedWorkspace);+ _containerService.ContainersToRedraw.Add(displayedWorkspace);_containerService.ContainersToRedraw.Add(workspaceToFocus);_bus.Invoke(new RedrawContainersCommand());diff --git a/GlazeWM.Domain/Workspaces/CommandHandlers/MoveWindowToWorkspaceHandler.cs b/GlazeWM.Domain/Workspaces/CommandHandlers/MoveWindowToWorkspaceHandler.csindex 8f51d1e5..f92aff21 100644--- a/GlazeWM.Domain/Workspaces/CommandHandlers/MoveWindowToWorkspaceHandler.cs+++ b/GlazeWM.Domain/Workspaces/CommandHandlers/MoveWindowToWorkspaceHandler.cs@@ -54,11 +54,19 @@ namespace GlazeWM.Domain.Workspaces.CommandHandlersvar focusTarget = WindowService.GetFocusTargetAfterRemoval(windowToMove);+ // Since the workspace that gets displayed is the last focused child, focus needs to be+ // reassigned to the displayed workspace.+ var targetMonitor = targetWorkspace.Parent as Monitor;+ var focusResetTarget = targetWorkspace.IsDisplayed ? null : targetMonitor.LastFocusedDescendant;+if (windowToMove is TilingWindow)MoveTilingWindowToWorkspace(windowToMove as TilingWindow, targetWorkspace);else_bus.Invoke(new MoveContainerWithinTreeCommand(windowToMove, targetWorkspace, false));+ if (focusResetTarget is not null)+ _bus.Invoke(new SetFocusedDescendantCommand(focusResetTarget));+// Reassign focus to descendant within the current workspace. Need to call// `SetFocusedDescendantCommand` for when commands like `FocusWorkspaceCommand` are called// immediately afterwards and they should behave as if `focusTarget` is the focused