Skip to content

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

refactor: rename layout-related variables (#359)

lars-bergerd2a225b56760
diff --git a/GlazeWM.Bar/Components/TilingDirectionComponentViewModel.cs b/GlazeWM.Bar/Components/TilingDirectionComponentViewModel.cs
index 3c9563c6..fc275a5b 100644
--- a/GlazeWM.Bar/Components/TilingDirectionComponentViewModel.cs
+++ b/GlazeWM.Bar/Components/TilingDirectionComponentViewModel.cs
@@ -23,22 +23,22 @@ namespace GlazeWM.Bar.Components
private string LabelHorizontal => _config.LabelHorizontal;
/// <summary>
- /// The layout of the currently focused container. Can be null on app startup when
- /// workspaces haven't been created yet.
+ /// The tiling direction of the currently focused container. Can be null on app
+ /// startup when workspaces haven't been created yet.
/// </summary>
- private Layout? _tilingDirection =>
- (_containerService.FocusedContainer as SplitContainer)?.Layout ??
- (_containerService.FocusedContainer.Parent as SplitContainer)?.Layout;
+ private TilingDirection? _tilingDirection =>
+ (_containerService.FocusedContainer as SplitContainer)?.TilingDirection ??
+ (_containerService.FocusedContainer.Parent as SplitContainer)?.TilingDirection;
public string TilingDirectionString =>
- _tilingDirection == Layout.Vertical ? LabelVertical : LabelHorizontal;
+ _tilingDirection == TilingDirection.Vertical ? LabelVertical : LabelHorizontal;
public TilingDirectionComponentViewModel(
BarViewModel parentViewModel,
TilingDirectionComponentConfig config) : base(parentViewModel, config)
{
_bus.Events.Where(
- (@event) => @event is LayoutChangedEvent or FocusChangedEvent
+ (@event) => @event is TilingDirectionChangedEvent or FocusChangedEvent
).Subscribe((_) =>
_dispatcher.Invoke(() => OnPropertyChanged(nameof(TilingDirectionString)))
);
diff --git a/GlazeWM.Domain/Common/Enums/Direction.cs b/GlazeWM.Domain/Common/Enums/Direction.cs
index 4faf023b..7a448ff6 100644
--- a/GlazeWM.Domain/Common/Enums/Direction.cs
+++ b/GlazeWM.Domain/Common/Enums/Direction.cs
@@ -29,14 +29,14 @@ namespace GlazeWM.Domain.Common.Enums
}
/// <summary>
- /// Get the layout that is needed for when moving or switching focus in given direction (eg. a
- /// horizontal layout when moving horizontally).
+ /// Get the tiling direction that is needed for when moving or switching focus in
+ /// given direction (eg. a horizontal tiling direction when moving horizontally).
/// </summary>
- public static Layout GetCorrespondingLayout(this Direction direction)
+ public static TilingDirection GetTilingDirection(this Direction direction)
{
return (direction is Direction.Left or Direction.Right)
- ? Layout.Horizontal
- : Layout.Vertical;
+ ? TilingDirection.Horizontal
+ : TilingDirection.Vertical;
}
}
}
diff --git a/GlazeWM.Domain/Common/Enums/Layout.cs b/GlazeWM.Domain/Common/Enums/TilingDirection.cs
similarity index 72%
rename from GlazeWM.Domain/Common/Enums/Layout.cs
rename to GlazeWM.Domain/Common/Enums/TilingDirection.cs
index d14aa90a..aa80428b 100644
--- a/GlazeWM.Domain/Common/Enums/Layout.cs
+++ b/GlazeWM.Domain/Common/Enums/TilingDirection.cs
@@ -1,6 +1,6 @@
namespace GlazeWM.Domain.Common.Enums
{
- public enum Layout
+ public enum TilingDirection
{
Vertical,
Horizontal,
diff --git a/GlazeWM.Domain/Containers/CommandHandlers/ChangeContainerLayoutHandler.cs b/GlazeWM.Domain/Containers/CommandHandlers/ChangeTilingDirectionHandler.cs
similarity index 56%
rename from GlazeWM.Domain/Containers/CommandHandlers/ChangeContainerLayoutHandler.cs
rename to GlazeWM.Domain/Containers/CommandHandlers/ChangeTilingDirectionHandler.cs
index 0e7526f1..641ad969 100644
--- a/GlazeWM.Domain/Containers/CommandHandlers/ChangeContainerLayoutHandler.cs
+++ b/GlazeWM.Domain/Containers/CommandHandlers/ChangeTilingDirectionHandler.cs
@@ -8,44 +8,47 @@ using GlazeWM.Infrastructure.Bussing;
namespace GlazeWM.Domain.Containers.CommandHandlers
{
- internal sealed class ChangeContainerLayoutHandler : ICommandHandler<ChangeContainerLayoutCommand>
+ internal sealed class ChangeTilingDirectionHandler : ICommandHandler<ChangeTilingDirectionCommand>
{
private readonly Bus _bus;
private readonly ContainerService _containerService;
- public ChangeContainerLayoutHandler(Bus bus, ContainerService containerService)
+ public ChangeTilingDirectionHandler(Bus bus, ContainerService containerService)
{
_bus = bus;
_containerService = containerService;
}
- public CommandResponse Handle(ChangeContainerLayoutCommand command)
+ public CommandResponse Handle(ChangeTilingDirectionCommand command)
{
var container = command.Container;
- var newLayout = command.NewLayout;
+ var newTilingDirection = command.TilingDirection;
if (container is TilingWindow)
- ChangeWindowLayout(container as Window, newLayout);
+ ChangeWindowTilingDirection(container as Window, newTilingDirection);
else if (container is Workspace)
- ChangeWorkspaceLayout(container as Workspace, newLayout);
+ ChangeWorkspaceTilingDirection(container as Workspace, newTilingDirection);
- _bus.Emit(new LayoutChangedEvent(newLayout));
+ _bus.Emit(new TilingDirectionChangedEvent(newTilingDirection));
return CommandResponse.Ok;
}
- private void ChangeWindowLayout(Window window, Layout newLayout)
+ private void ChangeWindowTilingDirection(
+ Window window,
+ TilingDirection newTilingDirection)
{
var parent = window.Parent as SplitContainer;
- var currentLayout = parent.Layout;
+ var currentTilingDirection = parent.TilingDirection;
- if (currentLayout == newLayout)
+ if (currentTilingDirection == newTilingDirection)
return;
- // If the window is an only child of a workspace, change layout of the workspace.
+ // If the window is an only child of a workspace, change tiling direction of the
+ // workspace.
if (!window.HasSiblings() && parent is Workspace)
{
- ChangeWorkspaceLayout(parent as Workspace, newLayout);
+ ChangeWorkspaceTilingDirection(parent as Workspace, newTilingDirection);
return;
}
@@ -60,7 +63,7 @@ namespace GlazeWM.Domain.Containers.CommandHandlers
// Create a new split container to wrap the window.
var splitContainer = new SplitContainer
{
- Layout = newLayout,
+ TilingDirection = newTilingDirection,
};
// Replace the window with the wrapping split container. The window has to be attached to
@@ -73,22 +76,25 @@ namespace GlazeWM.Domain.Containers.CommandHandlers
_bus.Invoke(new AttachContainerCommand(window, splitContainer));
}
- private void ChangeWorkspaceLayout(Workspace workspace, Layout newLayout)
+ private void ChangeWorkspaceTilingDirection(
+ Workspace workspace,
+ TilingDirection newTilingDirection)
{
- var currentLayout = workspace.Layout;
+ var currentTilingDirection = workspace.TilingDirection;
- if (currentLayout == newLayout)
+ if (currentTilingDirection == newTilingDirection)
return;
- workspace.Layout = newLayout;
+ workspace.TilingDirection = newTilingDirection;
- // Flatten any top-level split containers with the same layout as the workspace. Clone the
- // list since the number of workspace children changes when split containers are flattened.
+ // Flatten any top-level split containers with the same tiling direction as the
+ // workspace. Clone the list since the number of workspace children changes when
+ // split containers are flattened.
foreach (var child in workspace.Children.ToList())
{
var childSplitContainer = child as SplitContainer;
- if (childSplitContainer?.Layout != newLayout)
+ if (childSplitContainer?.TilingDirection != newTilingDirection)
continue;
_bus.Invoke(new FlattenSplitContainerCommand(childSplitContainer));
diff --git a/GlazeWM.Domain/Containers/CommandHandlers/FocusInDirectionHandler.cs b/GlazeWM.Domain/Containers/CommandHandlers/FocusInDirectionHandler.cs
index 48351c48..834d5570 100644
--- a/GlazeWM.Domain/Containers/CommandHandlers/FocusInDirectionHandler.cs
+++ b/GlazeWM.Domain/Containers/CommandHandlers/FocusInDirectionHandler.cs
@@ -85,7 +85,7 @@ namespace GlazeWM.Domain.Containers.CommandHandlers
Container focusedContainer,
Direction direction)
{
- var layoutForDirection = direction.GetCorrespondingLayout();
+ var tilingDirection = direction.GetTilingDirection();
var focusReference = focusedContainer;
// Traverse upwards from the focused container. Stop searching when a workspace is
@@ -94,7 +94,7 @@ namespace GlazeWM.Domain.Containers.CommandHandlers
{
var parent = focusReference.Parent as SplitContainer;
- if (!focusReference.HasSiblings() || parent.Layout != layoutForDirection)
+ if (!focusReference.HasSiblings() || parent.TilingDirection != tilingDirection)
{
focusReference = parent;
continue;
diff --git a/GlazeWM.Domain/Containers/CommandHandlers/ToggleContainerLayoutHandler.cs b/GlazeWM.Domain/Containers/CommandHandlers/ToggleContainerLayoutHandler.cs
deleted file mode 100644
index aa4eb702..00000000
--- a/GlazeWM.Domain/Containers/CommandHandlers/ToggleContainerLayoutHandler.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using GlazeWM.Domain.Common.Enums;
-using GlazeWM.Domain.Containers.Commands;
-using GlazeWM.Infrastructure.Bussing;
-
-namespace GlazeWM.Domain.Containers.CommandHandlers
-{
- internal sealed class ToggleContainerLayoutHandler : ICommandHandler<ToggleContainerLayoutCommand>
- {
- private readonly Bus _bus;
-
- public ToggleContainerLayoutHandler(Bus bus)
- {
- _bus = bus;
- }
- public CommandResponse Handle(ToggleContainerLayoutCommand command)
- {
- var container = command.Container;
- var currentLayout = (container as SplitContainer)?.Layout
- ?? (container.Parent as SplitContainer).Layout;
- var newLayout = currentLayout == Layout.Horizontal ? Layout.Vertical : Layout.Horizontal;
- _bus.Invoke(new ChangeContainerLayoutCommand(container, newLayout));
- return CommandResponse.Ok;
- }
- }
-}
diff --git a/GlazeWM.Domain/Containers/CommandHandlers/ToggleTilingDirectionHandler.cs b/GlazeWM.Domain/Containers/CommandHandlers/ToggleTilingDirectionHandler.cs
new file mode 100644
index 00000000..3a80d6c9
--- /dev/null
+++ b/GlazeWM.Domain/Containers/CommandHandlers/ToggleTilingDirectionHandler.cs
@@ -0,0 +1,35 @@
+using GlazeWM.Domain.Common.Enums;
+using GlazeWM.Domain.Containers.Commands;
+using GlazeWM.Infrastructure.Bussing;
+
+namespace GlazeWM.Domain.Containers.CommandHandlers
+{
+ internal sealed class ToggleTilingDirectionHandler
+ : ICommandHandler<ToggleTilingDirectionCommand>
+ {
+ private readonly Bus _bus;
+
+ public ToggleTilingDirectionHandler(Bus bus)
+ {
+ _bus = bus;
+ }
+
+ public CommandResponse Handle(ToggleTilingDirectionCommand command)
+ {
+ var container = command.Container;
+
+ var currentTilingDirection =
+ (container as SplitContainer)?.TilingDirection ??
+ (container.Parent as SplitContainer).TilingDirection;
+
+ var newTilingDirection =
+ currentTilingDirection == TilingDirection.Horizontal
+ ? TilingDirection.Vertical
+ : TilingDirection.Horizontal;
+
+ _bus.Invoke(new ChangeTilingDirectionCommand(container, newTilingDirection));
+
+ return CommandResponse.Ok;
+ }
+ }
+}
diff --git a/GlazeWM.Domain/Containers/Commands/ChangeContainerLayoutCommand.cs b/GlazeWM.Domain/Containers/Commands/ChangeContainerLayoutCommand.cs
deleted file mode 100644
index cdcfa450..00000000
--- a/GlazeWM.Domain/Containers/Commands/ChangeContainerLayoutCommand.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using GlazeWM.Domain.Common.Enums;
-using GlazeWM.Infrastructure.Bussing;
-
-namespace GlazeWM.Domain.Containers.Commands
-{
- public class ChangeContainerLayoutCommand : Command
- {
- public Container Container { get; }
- public Layout NewLayout { get; }
-
- public ChangeContainerLayoutCommand(Container container, Layout newLayout)
- {
- Container = container;
- NewLayout = newLayout;
- }
- }
-}
diff --git a/GlazeWM.Domain/Containers/Commands/ChangeTilingDirectionCommand.cs b/GlazeWM.Domain/Containers/Commands/ChangeTilingDirectionCommand.cs
new file mode 100644
index 00000000..98b22bdc
--- /dev/null
+++ b/GlazeWM.Domain/Containers/Commands/ChangeTilingDirectionCommand.cs
@@ -0,0 +1,19 @@
+using GlazeWM.Domain.Common.Enums;
+using GlazeWM.Infrastructure.Bussing;
+
+namespace GlazeWM.Domain.Containers.Commands
+{
+ public class ChangeTilingDirectionCommand : Command
+ {
+ public Container Container { get; }
+ public TilingDirection TilingDirection { get; }
+
+ public ChangeTilingDirectionCommand(
+ Container container,
+ TilingDirection tilingDirection)
+ {
+ Container = container;
+ TilingDirection = tilingDirection;
+ }
+ }
+}
diff --git a/GlazeWM.Domain/Containers/Commands/ToggleContainerLayoutCommand.cs b/GlazeWM.Domain/Containers/Commands/ToggleTilingDirectionCommand.cs
similarity index 60%
rename from GlazeWM.Domain/Containers/Commands/ToggleContainerLayoutCommand.cs
rename to GlazeWM.Domain/Containers/Commands/ToggleTilingDirectionCommand.cs
index c682fe4c..ed210064 100644
--- a/GlazeWM.Domain/Containers/Commands/ToggleContainerLayoutCommand.cs
+++ b/GlazeWM.Domain/Containers/Commands/ToggleTilingDirectionCommand.cs
@@ -2,11 +2,11 @@ using GlazeWM.Infrastructure.Bussing;
namespace GlazeWM.Domain.Containers.Commands
{
- public class ToggleContainerLayoutCommand : Command
+ public class ToggleTilingDirectionCommand : Command
{
public Container Container { get; }
- public ToggleContainerLayoutCommand(Container container)
+ public ToggleTilingDirectionCommand(Container container)
{
Container = container;
}
diff --git a/GlazeWM.Domain/Containers/ContainerService.cs b/GlazeWM.Domain/Containers/ContainerService.cs
index 0e338a22..20514823 100644
--- a/GlazeWM.Domain/Containers/ContainerService.cs
+++ b/GlazeWM.Domain/Containers/ContainerService.cs
@@ -64,7 +64,7 @@ namespace GlazeWM.Domain.Containers
{
var parent = container.Parent as SplitContainer;
- if (parent.Layout == Layout.Vertical)
+ if (parent.TilingDirection == TilingDirection.Vertical)
return parent.Width;
var innerGap = _userConfigService.GapsConfig.InnerGap;
@@ -82,7 +82,7 @@ namespace GlazeWM.Domain.Containers
{
var parent = container.Parent as SplitContainer;
- if (parent.Layout == Layout.Horizontal)
+ if (parent.TilingDirection == TilingDirection.Horizontal)
return parent.Height;
var innerGap = _userConfigService.GapsConfig.InnerGap;
@@ -102,7 +102,7 @@ namespace GlazeWM.Domain.Containers
var isFirstOfType = container.SelfAndSiblingsOfType<IResizable>().First() == container;
- if (parent.Layout == Layout.Vertical || isFirstOfType)
+ if (parent.TilingDirection == TilingDirection.Vertical || isFirstOfType)
return parent.X;
var innerGap = _userConfigService.GapsConfig.InnerGap;
@@ -122,7 +122,7 @@ namespace GlazeWM.Domain.Containers
var isFirstOfType = container.SelfAndSiblingsOfType<IResizable>().First() == container;
- if (parent.Layout == Layout.Horizontal || isFirstOfType)
+ if (parent.TilingDirection == TilingDirection.Horizontal || isFirstOfType)
return parent.Y;
var innerGap = _userConfigService.GapsConfig.InnerGap;
@@ -146,9 +146,9 @@ namespace GlazeWM.Domain.Containers
if (!isDescendable)
return originContainer;
- var layout = (originContainer as SplitContainer).Layout;
+ var tilingDirection = (originContainer as SplitContainer).TilingDirection;
- if (layout != direction.GetCorrespondingLayout())
+ if (tilingDirection != direction.GetTilingDirection())
return GetDescendantInDirection(
originContainer.LastFocusedChildOfType<IResizable>(),
direction
diff --git a/GlazeWM.Domain/Containers/Events/LayoutChangedEvent.cs b/GlazeWM.Domain/Containers/Events/LayoutChangedEvent.cs
index 4f9091e6..c5cac609 100644
--- a/GlazeWM.Domain/Containers/Events/LayoutChangedEvent.cs
+++ b/GlazeWM.Domain/Containers/Events/LayoutChangedEvent.cs
@@ -3,13 +3,13 @@ using GlazeWM.Infrastructure.Bussing;
namespace GlazeWM.Domain.Containers.Events
{
- public class LayoutChangedEvent : Event
+ public class TilingDirectionChangedEvent : Event
{
- public Layout NewLayout { get; }
+ public TilingDirection NewTilingDirection { get; }
- public LayoutChangedEvent(Layout newLayout)
+ public TilingDirectionChangedEvent(TilingDirection newTilingDirection)
{
- NewLayout = newLayout;
+ NewTilingDirection = newTilingDirection;
}
}
}
diff --git a/GlazeWM.Domain/Containers/JsonContainerConverter.cs b/GlazeWM.Domain/Containers/JsonContainerConverter.cs
index c7bd5939..f018fc47 100644
--- a/GlazeWM.Domain/Containers/JsonContainerConverter.cs
+++ b/GlazeWM.Domain/Containers/JsonContainerConverter.cs
@@ -112,8 +112,8 @@ namespace GlazeWM.Domain.Containers
SplitContainer splitContainer,
JsonSerializerOptions options)
{
- writer.WritePropertyName(JsonParser.ChangeCasing("Layout", options));
- JsonSerializer.Serialize(writer, splitContainer.Layout, options);
+ writer.WritePropertyName(JsonParser.ChangeCasing("TilingDirection", options));
+ JsonSerializer.Serialize(writer, splitContainer.TilingDirection, options);
writer.WriteNumber(
JsonParser.ChangeCasing("SizePercentage", options),
diff --git a/GlazeWM.Domain/Containers/SplitContainer.cs b/GlazeWM.Domain/Containers/SplitContainer.cs
index e3fab625..6392d90c 100644
--- a/GlazeWM.Domain/Containers/SplitContainer.cs
+++ b/GlazeWM.Domain/Containers/SplitContainer.cs
@@ -9,7 +9,7 @@ namespace GlazeWM.Domain.Containers
/// <inheritdoc />
public override ContainerType Type { get; } = ContainerType.Split;
- public Layout Layout { get; set; } = Layout.Horizontal;
+ public TilingDirection TilingDirection { get; set; } = TilingDirection.Horizontal;
public double SizePercentage { get; set; } = 1;
diff --git a/GlazeWM.Domain/DependencyInjection.cs b/GlazeWM.Domain/DependencyInjection.cs
index df0aec46..f4e2a77a 100644
--- a/GlazeWM.Domain/DependencyInjection.cs
+++ b/GlazeWM.Domain/DependencyInjection.cs
@@ -41,8 +41,8 @@ namespace GlazeWM.Domain
services.AddSingleton<ICommandHandler<AttachContainerCommand>, AttachContainerHandler>();
services.AddSingleton<ICommandHandler<CenterCursorOnContainerCommand>, CenterCursorOnContainerHandler>();
services.AddSingleton<ICommandHandler<SetActiveWindowBorderCommand>, SetActiveWindowBorderHandler>();
- services.AddSingleton<ICommandHandler<ChangeContainerLayoutCommand>, ChangeContainerLayoutHandler>();
- services.AddSingleton<ICommandHandler<ToggleContainerLayoutCommand>, ToggleContainerLayoutHandler>();
+ services.AddSingleton<ICommandHandler<ChangeTilingDirectionCommand>, ChangeTilingDirectionHandler>();
+ services.AddSingleton<ICommandHandler<ToggleTilingDirectionCommand>, ToggleTilingDirectionHandler>();
services.AddSingleton<ICommandHandler<DetachAndResizeContainerCommand>, DetachAndResizeContainerHandler>();
services.AddSingleton<ICommandHandler<DetachContainerCommand>, DetachContainerHandler>();
services.AddSingleton<ICommandHandler<FlattenSplitContainerCommand>, FlattenSplitContainerHandler>();
diff --git a/GlazeWM.Domain/UserConfigs/CommandParsingService.cs b/GlazeWM.Domain/UserConfigs/CommandParsingService.cs
index 9f287070..17c51094 100644
--- a/GlazeWM.Domain/UserConfigs/CommandParsingService.cs
+++ b/GlazeWM.Domain/UserConfigs/CommandParsingService.cs
@@ -109,9 +109,9 @@ namespace GlazeWM.Domain.UserConfigs
{
"direction" => commandParts[2] switch
{
- "vertical" => new ChangeContainerLayoutCommand(subjectContainer, Layout.Vertical),
- "horizontal" => new ChangeContainerLayoutCommand(subjectContainer, Layout.Horizontal),
- "toggle" => new ToggleContainerLayoutCommand(subjectContainer),
+ "vertical" => new ChangeTilingDirectionCommand(subjectContainer, TilingDirection.Vertical),
+ "horizontal" => new ChangeTilingDirectionCommand(subjectContainer, TilingDirection.Horizontal),
+ "toggle" => new ToggleTilingDirectionCommand(subjectContainer),
_ => throw new ArgumentException(null, nameof(commandParts)),
},
_ => throw new ArgumentException(null, nameof(commandParts)),
@@ -122,8 +122,8 @@ namespace GlazeWM.Domain.UserConfigs
{
return commandParts[1] switch
{
- "vertical" => new ChangeContainerLayoutCommand(subjectContainer, Layout.Vertical),
- "horizontal" => new ChangeContainerLayoutCommand(subjectContainer, Layout.Horizontal),
+ "vertical" => new ChangeTilingDirectionCommand(subjectContainer, TilingDirection.Vertical),
+ "horizontal" => new ChangeTilingDirectionCommand(subjectContainer, TilingDirection.Horizontal),
_ => throw new ArgumentException(null, nameof(commandParts)),
};
}
diff --git a/GlazeWM.Domain/Windows/CommandHandlers/MoveWindowHandler.cs b/GlazeWM.Domain/Windows/CommandHandlers/MoveWindowHandler.cs
index b43fb38c..bc6f19f9 100644
--- a/GlazeWM.Domain/Windows/CommandHandlers/MoveWindowHandler.cs
+++ b/GlazeWM.Domain/Windows/CommandHandlers/MoveWindowHandler.cs
@@ -96,9 +96,8 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
);
var targetParent = targetDescendant.Parent as SplitContainer;
- var layoutForDirection = direction.GetCorrespondingLayout();
var shouldInsertAfter =
- targetParent.Layout != layoutForDirection ||
+ targetParent.TilingDirection != direction.GetTilingDirection() ||
direction == Direction.Up ||
direction == Direction.Left;
var insertionIndex = shouldInsertAfter ? targetDescendant.Index + 1 : targetDescendant.Index;
@@ -139,12 +138,11 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
_bus.Emit(new FocusChangedEvent(windowToMove));
}
- private void ChangeWorkspaceLayout(Window windowToMove, Direction direction)
+ private void ChangeWorkspaceTilingDirection(Window windowToMove, Direction direction)
{
var workspace = WorkspaceService.GetWorkspaceFromChildContainer(windowToMove);
- var layoutForDirection = direction.GetCorrespondingLayout();
- _bus.Invoke(new ChangeContainerLayoutCommand(workspace, layoutForDirection));
+ _bus.Invoke(new ChangeTilingDirectionCommand(workspace, direction.GetTilingDirection()));
// TODO: Should probably descend into sibling if possible.
if (HasSiblingInDirection(windowToMove, direction))
@@ -156,12 +154,13 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
private void InsertIntoAncestor(
TilingWindow windowToMove,
Direction direction,
- Container ancestorWithLayout)
+ Container ancestorWithTilingDirection)
{
- // Traverse up from `windowToMove` to find container where the parent is `ancestorWithLayout`.
- // Then, depending on the direction, insert before or after that container.
+ // Traverse up from `windowToMove` to find container where the parent is
+ // `ancestorWithTilingDirection`. Then, depending on the direction, insert before
+ // or after that container.
var insertionReference = windowToMove.Ancestors
- .FirstOrDefault(container => container.Parent == ancestorWithLayout);
+ .FirstOrDefault(container => container.Parent == ancestorWithTilingDirection);
var insertionReferenceSibling = direction is Direction.Up or Direction.Left
? insertionReference.PreviousSiblingOfType<IResizable>()
@@ -176,9 +175,8 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
);
var targetParent = targetDescendant.Parent as SplitContainer;
- var layoutForDirection = direction.GetCorrespondingLayout();
var shouldInsertAfter =
- targetParent.Layout != layoutForDirection ||
+ targetParent.TilingDirection != direction.GetTilingDirection() ||
direction == Direction.Up ||
direction == Direction.Left;
@@ -194,7 +192,14 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
var insertionIndex = (direction is Direction.Up or Direction.Left) ?
insertionReference.Index : insertionReference.Index + 1;
- _bus.Invoke(new MoveContainerWithinTreeCommand(windowToMove, ancestorWithLayout, insertionIndex, true));
+ _bus.Invoke(
+ new MoveContainerWithinTreeCommand(
+ windowToMove,
+ ancestorWithTilingDirection,
+ insertionIndex,
+ true
+ )
+ );
}
_bus.Invoke(new RedrawContainersCommand());
@@ -202,18 +207,17 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
private void MoveTilingWindow(TilingWindow windowToMove, Direction direction)
{
- var layoutForDirection = direction.GetCorrespondingLayout();
- var parentMatchesLayout =
- (windowToMove.Parent as SplitContainer).Layout == direction.GetCorrespondingLayout();
+ var parentHasTilingDirection =
+ (windowToMove.Parent as SplitContainer).TilingDirection == direction.GetTilingDirection();
- if (parentMatchesLayout && HasSiblingInDirection(windowToMove, direction))
+ if (parentHasTilingDirection && HasSiblingInDirection(windowToMove, direction))
{
SwapSiblingContainers(windowToMove, direction);
return;
}
// Attempt to the move window to workspace in given direction.
- if (parentMatchesLayout && windowToMove.Parent is Workspace)
+ if (parentHasTilingDirection && windowToMove.Parent is Workspace)
{
MoveToWorkspaceInDirection(windowToMove, direction);
return;
@@ -221,18 +225,19 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
// The window cannot be moved within the parent container, so traverse upwards to find a
// suitable ancestor to move to.
- var ancestorWithLayout = windowToMove.Parent.Ancestors.FirstOrDefault(
- container => (container as SplitContainer)?.Layout == layoutForDirection
+ var ancestorWithTilingDirection = windowToMove.Parent.Ancestors.FirstOrDefault(
+ (container) =>
+ (container as SplitContainer)?.TilingDirection == direction.GetTilingDirection()
) as SplitContainer;
- // Change the layout of the workspace to layout for direction.
- if (ancestorWithLayout == null)
+ // Change the tiling direction of the workspace to tiling direction for direction.
+ if (ancestorWithTilingDirection == null)
{
- ChangeWorkspaceLayout(windowToMove, direction);
+ ChangeWorkspaceTilingDirection(windowToMove, direction);
return;
}
- InsertIntoAncestor(windowToMove, direction, ancestorWithLayout);
+ InsertIntoAncestor(windowToMove, direction, ancestorWithTilingDirection);
}
private void MoveFloatingWindow(Window windowToMove, Direction direction)
diff --git a/GlazeWM.Domain/Windows/CommandHandlers/ResizeWindowHandler.cs b/GlazeWM.Domain/Windows/CommandHandlers/ResizeWindowHandler.cs
index c5066d03..60c564c9 100644
--- a/GlazeWM.Domain/Windows/CommandHandlers/ResizeWindowHandler.cs
+++ b/GlazeWM.Domain/Windows/CommandHandlers/ResizeWindowHandler.cs
@@ -70,12 +70,14 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
{
var parent = windowToResize.Parent;
var grandparent = parent.Parent;
- var layout = (parent as SplitContainer).Layout;
+ var tilingDirection = (parent as SplitContainer).TilingDirection;
- // Whether the resize is in the inverse direction of its layout.
+ // Whether the resize is in the inverse direction of its tiling direction.
var isInverseResize =
- (layout == Layout.Horizontal && dimensionToResize == ResizeDimension.Height) ||
- (layout == Layout.Vertical && dimensionToResize == ResizeDimension.Width);
+ (tilingDirection == TilingDirection.Horizontal &&
+ dimensionToResize == ResizeDimension.Height) ||
+ (tilingDirection == TilingDirection.Vertical &&
+ dimensionToResize == ResizeDimension.Width);
var hasResizableSiblings = windowToResize.SiblingsOfType<IResizable>().Any();
diff --git a/GlazeWM.Domain/Workspaces/CommandHandlers/ActivateWorkspaceHandler.cs b/GlazeWM.Domain/Workspaces/CommandHandlers/ActivateWorkspaceHandler.cs
index e19f9c30..c90a4bdb 100644
--- a/GlazeWM.Domain/Workspaces/CommandHandlers/ActivateWorkspaceHandler.cs
+++ b/GlazeWM.Domain/Workspaces/CommandHandlers/ActivateWorkspaceHandler.cs
@@ -20,8 +20,11 @@ namespace GlazeWM.Domain.Workspaces.CommandHandlers
var workspaceName = command.WorkspaceName;
var targetMonitor = command.TargetMonitor;
- var layout = targetMonitor.Height > targetMonitor.Width ? Layout.Vertical : Layout.Horizontal;
- var newWorkspace = new Workspace(workspaceName, layout);
+ var tilingDirection = targetMonitor.Height > targetMonitor.Width
+ ? TilingDirection.Vertical
+ : TilingDirection.Horizontal;
+
+ var newWorkspace = new Workspace(workspaceName, tilingDirection);
// Attach the created workspace to the specified monitor.
_bus.Invoke(new AttachContainerCommand(newWorkspace, targetMonitor));
diff --git a/GlazeWM.Domain/Workspaces/Workspace.cs b/GlazeWM.Domain/Workspaces/Workspace.cs
index 63ac9986..9774702b 100644
--- a/GlazeWM.Domain/Workspaces/Workspace.cs
+++ b/GlazeWM.Domain/Workspaces/Workspace.cs
@@ -93,10 +93,10 @@ namespace GlazeWM.Domain.Workspaces
/// </summary>
public bool IsDisplayed => (Parent as Monitor)?.DisplayedWorkspace == this;
- public Workspace(string name, Layout layout)
+ public Workspace(string name, TilingDirection tilingDirection)
{
- Layout = layout;
Name = name;
+ TilingDirection = tilingDirection;
}
}
}