From 2f6dc23fbd69ef5228f4b69347563b99d530a382 Mon Sep 17 00:00:00 2001 From: Isaac Daly Date: Thu, 27 Jun 2024 21:26:02 +1000 Subject: [PATCH] Undo LayoutEngineCustomAction breaking name change (#917) In #909 I went a bit overzealous with a simplification which I wouldn't think would hit anyone. `LayoutEngineAction` has been renamed back to `LayoutEngineCustomAction`. --- src/Whim.Bar.Tests/BarLayoutEngineTests.cs | 4 ++-- src/Whim.Bar/BarLayoutEngine.cs | 2 +- .../FloatingLayoutEngineTests.cs | 6 ++--- .../FloatingLayoutEngine.cs | 2 +- src/Whim.Gaps.Tests/GapsLayoutEngineTests.cs | 4 ++-- src/Whim.Gaps/GapsLayoutEngine.cs | 2 +- .../PerformCustomActionTests.cs | 16 ++++++------- .../SliceLayoutPluginTests.cs | 16 ++++++------- src/Whim.SliceLayout/SliceLayoutEngine.cs | 11 +++++---- src/Whim.SliceLayout/SliceLayoutPlugin.cs | 4 ++-- .../ImmutableTestLayoutEngine.cs | 2 +- .../ProxyLayoutEngineBaseTests.cs | 2 +- src/Whim.TestUtils/TestLayoutEngine.cs | 3 ++- src/Whim.Tests/Commands/CoreCommandsTests.cs | 4 ++-- .../Layout/ColumnLayoutEngineTests.cs | 2 +- .../Layout/FocusLayoutEngineTests.cs | 4 ++-- ...LayoutEngineCustomActionTransformTests.cs} | 24 ++++++++++--------- .../Workspace/LegacyWorkspaceTests.cs | 8 +++---- .../LayoutEngine/PerformCustomActionTests.cs | 2 +- src/Whim.TreeLayout/TreeLayoutEngine.cs | 2 +- src/Whim/Commands/CoreCommands.cs | 6 ++++- src/Whim/Layout/BaseProxyLayoutEngine.cs | 2 +- src/Whim/Layout/ColumnLayoutEngine.cs | 2 +- src/Whim/Layout/FocusLayoutEngine.cs | 2 +- src/Whim/Layout/ILayoutEngine.cs | 2 +- ...eAction.cs => LayoutEngineCustomAction.cs} | 4 ++-- ...s => LayoutEngineCustomActionTransform.cs} | 12 ++++++---- src/Whim/Workspace/IWorkspace.cs | 4 ++-- src/Whim/Workspace/LegacyWorkspace.cs | 12 ++++++---- 29 files changed, 89 insertions(+), 77 deletions(-) rename src/Whim.Tests/Store/WorkspaceSector/Transforms/{LayoutEngineActionTransformTests.cs => LayoutEngineCustomActionTransformTests.cs} (78%) rename src/Whim/Layout/{LayoutEngineAction.cs => LayoutEngineCustomAction.cs} (90%) rename src/Whim/Store/WorkspaceSector/Transforms/{LayoutEngineActionTransform.cs => LayoutEngineCustomActionTransform.cs} (83%) diff --git a/src/Whim.Bar.Tests/BarLayoutEngineTests.cs b/src/Whim.Bar.Tests/BarLayoutEngineTests.cs index dd456785e..4df786b9a 100644 --- a/src/Whim.Bar.Tests/BarLayoutEngineTests.cs +++ b/src/Whim.Bar.Tests/BarLayoutEngineTests.cs @@ -344,7 +344,7 @@ public void PerformCustomAction_NotSame(ILayoutEngine innerLayoutEngine, ILayout { // Given BarLayoutEngine engine = CreateSut(innerLayoutEngine); - LayoutEngineAction action = + LayoutEngineCustomAction action = new() { Name = "Action", @@ -366,7 +366,7 @@ public void PerformCustomAction_Same(ILayoutEngine innerLayoutEngine) { // Given BarLayoutEngine engine = CreateSut(innerLayoutEngine); - LayoutEngineAction action = + LayoutEngineCustomAction action = new() { Name = "Action", diff --git a/src/Whim.Bar/BarLayoutEngine.cs b/src/Whim.Bar/BarLayoutEngine.cs index aa6affac0..14716993e 100644 --- a/src/Whim.Bar/BarLayoutEngine.cs +++ b/src/Whim.Bar/BarLayoutEngine.cs @@ -81,6 +81,6 @@ public override ILayoutEngine MinimizeWindowEnd(IWindow window) => UpdateInner(InnerLayoutEngine.MinimizeWindowEnd(window)); /// - public override ILayoutEngine PerformCustomAction(LayoutEngineAction action) => + public override ILayoutEngine PerformCustomAction(LayoutEngineCustomAction action) => UpdateInner(InnerLayoutEngine.PerformCustomAction(action)); } diff --git a/src/Whim.FloatingLayout.Tests/FloatingLayoutEngineTests.cs b/src/Whim.FloatingLayout.Tests/FloatingLayoutEngineTests.cs index 4f0c1b1e3..7e4d63a41 100644 --- a/src/Whim.FloatingLayout.Tests/FloatingLayoutEngineTests.cs +++ b/src/Whim.FloatingLayout.Tests/FloatingLayoutEngineTests.cs @@ -1113,7 +1113,7 @@ ILayoutEngine innerLayoutEngine { // Given FloatingLayoutEngine engine = new(context, plugin, innerLayoutEngine); - LayoutEngineAction action = + LayoutEngineCustomAction action = new() { Name = "Action", @@ -1138,7 +1138,7 @@ ILayoutEngine innerLayoutEngine { // Given FloatingLayoutEngine engine = new(context, plugin, innerLayoutEngine); - LayoutEngineAction action = + LayoutEngineCustomAction action = new() { Name = "Action", @@ -1166,7 +1166,7 @@ IWindow window { // Given FloatingLayoutEngine engine = new(context, plugin, innerLayoutEngine); - LayoutEngineAction action = + LayoutEngineCustomAction action = new() { Name = "Action", diff --git a/src/Whim.FloatingLayout/FloatingLayoutEngine.cs b/src/Whim.FloatingLayout/FloatingLayoutEngine.cs index 8fc2e9d8b..1c8fe0f30 100644 --- a/src/Whim.FloatingLayout/FloatingLayoutEngine.cs +++ b/src/Whim.FloatingLayout/FloatingLayoutEngine.cs @@ -256,7 +256,7 @@ public override ILayoutEngine MinimizeWindowEnd(IWindow window) => UpdateInner(InnerLayoutEngine.MinimizeWindowEnd(window), window); /// - public override ILayoutEngine PerformCustomAction(LayoutEngineAction action) + public override ILayoutEngine PerformCustomAction(LayoutEngineCustomAction action) { if (action.Window != null && IsWindowFloating(action.Window)) { diff --git a/src/Whim.Gaps.Tests/GapsLayoutEngineTests.cs b/src/Whim.Gaps.Tests/GapsLayoutEngineTests.cs index be1f0efc3..4dd778b1f 100644 --- a/src/Whim.Gaps.Tests/GapsLayoutEngineTests.cs +++ b/src/Whim.Gaps.Tests/GapsLayoutEngineTests.cs @@ -720,7 +720,7 @@ public void PerformCustomAction_NotSame(ILayoutEngine innerLayoutEngine, ILayout // Given GapsConfig gapsConfig = new() { OuterGap = 10, InnerGap = 5 }; - LayoutEngineAction action = + LayoutEngineCustomAction action = new() { Name = "Action", @@ -746,7 +746,7 @@ public void PerformCustomAction_Same(ILayoutEngine innerLayoutEngine) // Given GapsConfig gapsConfig = new() { OuterGap = 10, InnerGap = 5 }; - LayoutEngineAction action = + LayoutEngineCustomAction action = new() { Name = "Action", diff --git a/src/Whim.Gaps/GapsLayoutEngine.cs b/src/Whim.Gaps/GapsLayoutEngine.cs index 4ab7c6a2d..ec4c46f25 100644 --- a/src/Whim.Gaps/GapsLayoutEngine.cs +++ b/src/Whim.Gaps/GapsLayoutEngine.cs @@ -126,6 +126,6 @@ public override ILayoutEngine MinimizeWindowEnd(IWindow window) => UpdateInner(InnerLayoutEngine.MinimizeWindowEnd(window)); /// - public override ILayoutEngine PerformCustomAction(LayoutEngineAction action) => + public override ILayoutEngine PerformCustomAction(LayoutEngineCustomAction action) => UpdateInner(InnerLayoutEngine.PerformCustomAction(action)); } diff --git a/src/Whim.SliceLayout.Tests/SliceLayoutEngine/PerformCustomActionTests.cs b/src/Whim.SliceLayout.Tests/SliceLayoutEngine/PerformCustomActionTests.cs index 4619b59da..78c59ce46 100644 --- a/src/Whim.SliceLayout.Tests/SliceLayoutEngine/PerformCustomActionTests.cs +++ b/src/Whim.SliceLayout.Tests/SliceLayoutEngine/PerformCustomActionTests.cs @@ -27,7 +27,7 @@ public void PromoteWindowInStack_CannotFindWindow(IContext ctx, SliceLayoutPlugi IWindowState[] beforeStates = sut.DoLayout(primaryMonitorBounds, Substitute.For()).ToArray(); sut = sut.PerformCustomAction( - new LayoutEngineAction() + new LayoutEngineCustomAction() { Name = "whim.slice_layout.window.promote", Window = untrackedWindow, @@ -74,7 +74,7 @@ SliceLayoutPlugin plugin } sut = sut.PerformCustomAction( - new LayoutEngineAction() + new LayoutEngineCustomAction() { Name = "whim.slice_layout.window.promote", Window = windows[focusedWindowIdx], @@ -99,7 +99,7 @@ public void PromoteWindowInStack_EmptyLayoutEngine(IContext ctx, SliceLayoutPlug IWindowState[] beforeStates = sut.DoLayout(primaryMonitorBounds, Substitute.For()).ToArray(); sut = sut.PerformCustomAction( - new LayoutEngineAction() + new LayoutEngineCustomAction() { Name = "whim.slice_layout.window.promote", Window = window, @@ -131,7 +131,7 @@ public void DemoteWindowInStack_CannotFindWindow(IContext ctx, SliceLayoutPlugin IWindowState[] beforeStates = sut.DoLayout(primaryMonitorBounds, Substitute.For()).ToArray(); sut = sut.PerformCustomAction( - new LayoutEngineAction() + new LayoutEngineCustomAction() { Name = "whim.slice_layout.window.demote", Window = untrackedWindow, @@ -173,7 +173,7 @@ public void DemoteWindowInStack(int focusedWindowIdx, int expectedWindowIdx, ICo } sut = sut.PerformCustomAction( - new LayoutEngineAction() + new LayoutEngineCustomAction() { Name = "whim.slice_layout.window.demote", Window = windows[focusedWindowIdx], @@ -198,7 +198,7 @@ public void DemoteWindowInStack_EmptyLayoutEngine(IContext ctx, SliceLayoutPlugi IWindowState[] beforeStates = sut.DoLayout(primaryMonitorBounds, Substitute.For()).ToArray(); sut = sut.PerformCustomAction( - new LayoutEngineAction() + new LayoutEngineCustomAction() { Name = "whim.slice_layout.window.demote", Window = window, @@ -242,7 +242,7 @@ SliceLayoutPlugin plugin } ILayoutEngine resultSut = sut.PerformCustomAction( - new LayoutEngineAction() + new LayoutEngineCustomAction() { Name = promote ? plugin.PromoteFocusActionName : plugin.DemoteFocusActionName, Window = windows[focusedWindowIdx], @@ -273,7 +273,7 @@ public void PerformCustomAction_UnknownAction(IContext ctx, SliceLayoutPlugin pl IWindowState[] beforeStates = sut.DoLayout(primaryMonitorBounds, Substitute.For()).ToArray(); sut = sut.PerformCustomAction( - new LayoutEngineAction() + new LayoutEngineCustomAction() { Name = "whim.slice_layout.window.unknown", Window = windows[0], diff --git a/src/Whim.SliceLayout.Tests/SliceLayoutPluginTests.cs b/src/Whim.SliceLayout.Tests/SliceLayoutPluginTests.cs index b8f32b533..4e9ab9195 100644 --- a/src/Whim.SliceLayout.Tests/SliceLayoutPluginTests.cs +++ b/src/Whim.SliceLayout.Tests/SliceLayoutPluginTests.cs @@ -114,7 +114,7 @@ public void PromoteWindowInStack_NoWorkspace(IContext ctx, IWindow window) // Then nothing IWorkspace activeWorkspace = ctx.WorkspaceManager.ActiveWorkspace; - activeWorkspace.DidNotReceive().PerformCustomLayoutEngineAction(Arg.Any()); + activeWorkspace.DidNotReceive().PerformCustomLayoutEngineAction(Arg.Any()); activeWorkspace.DidNotReceive().DoLayout(); } @@ -133,7 +133,7 @@ public void PromoteWindowInStack(IContext ctx, IWindow window, IWorkspace worksp workspace .Received(1) .PerformCustomLayoutEngineAction( - Arg.Is(action => + Arg.Is(action => action.Name == plugin.PromoteWindowActionName && action.Window == window ) ); @@ -168,7 +168,7 @@ public void DemoteWindowInStack_NoWorkspace(IContext ctx, IWindow window) // Then nothing IWorkspace activeWorkspace = ctx.WorkspaceManager.ActiveWorkspace; - activeWorkspace.DidNotReceive().PerformCustomLayoutEngineAction(Arg.Any()); + activeWorkspace.DidNotReceive().PerformCustomLayoutEngineAction(Arg.Any()); activeWorkspace.DidNotReceive().DoLayout(); } @@ -187,7 +187,7 @@ public void DemoteWindowInStack(IContext ctx, IWindow window, IWorkspace workspa workspace .Received(1) .PerformCustomLayoutEngineAction( - Arg.Is(action => + Arg.Is(action => action.Name == plugin.DemoteWindowActionName && action.Window == window ) ); @@ -239,7 +239,7 @@ public void PromoteFocusInStack_NoWorkspace(IContext ctx, IWindow window) // Then nothing ctx.WorkspaceManager.ActiveWorkspace.DidNotReceive() - .PerformCustomLayoutEngineAction(Arg.Any()); + .PerformCustomLayoutEngineAction(Arg.Any()); } [Theory, AutoSubstituteData] @@ -257,7 +257,7 @@ public void PromoteFocusInStack(IContext ctx, IWindow window, IWorkspace workspa workspace .Received(1) .PerformCustomLayoutEngineAction( - Arg.Is(action => + Arg.Is(action => action.Name == plugin.PromoteFocusActionName && action.Window == window ) ); @@ -292,7 +292,7 @@ public void DemoteFocusInStack_NoWorkspace(IContext ctx, IWindow window) // Then nothing ctx.WorkspaceManager.ActiveWorkspace.DidNotReceive() - .PerformCustomLayoutEngineAction(Arg.Any()); + .PerformCustomLayoutEngineAction(Arg.Any()); } [Theory, AutoSubstituteData] @@ -310,7 +310,7 @@ public void DemoteFocusInStack(IContext ctx, IWindow window, IWorkspace workspac workspace .Received(1) .PerformCustomLayoutEngineAction( - Arg.Is(action => + Arg.Is(action => action.Name == plugin.DemoteFocusActionName && action.Window == window ) ); diff --git a/src/Whim.SliceLayout/SliceLayoutEngine.cs b/src/Whim.SliceLayout/SliceLayoutEngine.cs index 5d6d46e44..609ad5cf3 100644 --- a/src/Whim.SliceLayout/SliceLayoutEngine.cs +++ b/src/Whim.SliceLayout/SliceLayoutEngine.cs @@ -299,17 +299,18 @@ public ILayoutEngine MinimizeWindowEnd(IWindow window) } /// - public ILayoutEngine PerformCustomAction(LayoutEngineAction action) => + public ILayoutEngine PerformCustomAction(LayoutEngineCustomAction action) => action switch { - LayoutEngineAction promoteAction when promoteAction.Name == _plugin.PromoteWindowActionName + LayoutEngineCustomAction promoteAction when promoteAction.Name == _plugin.PromoteWindowActionName => PromoteWindowInStack(promoteAction.Payload, promote: true), - LayoutEngineAction demoteAction when demoteAction.Name == _plugin.DemoteWindowActionName + LayoutEngineCustomAction demoteAction when demoteAction.Name == _plugin.DemoteWindowActionName => PromoteWindowInStack(demoteAction.Payload, promote: false), - LayoutEngineAction promoteFocusAction + LayoutEngineCustomAction promoteFocusAction when promoteFocusAction.Name == _plugin.PromoteFocusActionName => PromoteFocusInStack(promoteFocusAction.Payload, promote: true), - LayoutEngineAction demoteFocusAction when demoteFocusAction.Name == _plugin.DemoteFocusActionName + LayoutEngineCustomAction demoteFocusAction + when demoteFocusAction.Name == _plugin.DemoteFocusActionName => PromoteFocusInStack(demoteFocusAction.Payload, promote: false), _ => this }; diff --git a/src/Whim.SliceLayout/SliceLayoutPlugin.cs b/src/Whim.SliceLayout/SliceLayoutPlugin.cs index 43015ccc6..0800cce29 100644 --- a/src/Whim.SliceLayout/SliceLayoutPlugin.cs +++ b/src/Whim.SliceLayout/SliceLayoutPlugin.cs @@ -65,7 +65,7 @@ private void ChangeWindowRank(IWindow? window, bool promote) } workspace.PerformCustomLayoutEngineAction( - new LayoutEngineAction() + new LayoutEngineCustomAction() { Name = promote ? PromoteWindowActionName : DemoteWindowActionName, Window = definedWindow @@ -107,7 +107,7 @@ private void FocusWindowRank(IWindow? window, bool promote) } workspace.PerformCustomLayoutEngineAction( - new LayoutEngineAction() + new LayoutEngineCustomAction() { Name = promote ? PromoteFocusActionName : DemoteFocusActionName, Window = definedWindow diff --git a/src/Whim.TestUtils/ImmutableTestLayoutEngine.cs b/src/Whim.TestUtils/ImmutableTestLayoutEngine.cs index 1adebb5dc..bac95ff00 100644 --- a/src/Whim.TestUtils/ImmutableTestLayoutEngine.cs +++ b/src/Whim.TestUtils/ImmutableTestLayoutEngine.cs @@ -33,7 +33,7 @@ public IEnumerable DoLayout(IRectangle rectangle, IMonitor mo public ILayoutEngine MoveWindowToPoint(IWindow window, IPoint point) => this; - public ILayoutEngine PerformCustomAction(LayoutEngineAction action) => this; + public ILayoutEngine PerformCustomAction(LayoutEngineCustomAction action) => this; public ILayoutEngine RemoveWindow(IWindow window) => this; diff --git a/src/Whim.TestUtils/ProxyLayoutEngineBaseTests.cs b/src/Whim.TestUtils/ProxyLayoutEngineBaseTests.cs index 08c191c37..8ef590ef2 100644 --- a/src/Whim.TestUtils/ProxyLayoutEngineBaseTests.cs +++ b/src/Whim.TestUtils/ProxyLayoutEngineBaseTests.cs @@ -186,7 +186,7 @@ public void PerformCustomAction_WindowIsPresent(ILayoutEngine inner, IWindow win { // Given ILayoutEngine layoutEngine = CreateLayoutEngine(inner).AddWindow(window1); - LayoutEngineAction action = + LayoutEngineCustomAction action = new() { Name = "Action", diff --git a/src/Whim.TestUtils/TestLayoutEngine.cs b/src/Whim.TestUtils/TestLayoutEngine.cs index 4873ce433..f15b9d763 100644 --- a/src/Whim.TestUtils/TestLayoutEngine.cs +++ b/src/Whim.TestUtils/TestLayoutEngine.cs @@ -49,7 +49,8 @@ public ILayoutEngine SwapWindowInDirection(Direction direction, IWindow window) throw new NotImplementedException(); /// - public ILayoutEngine PerformCustomAction(LayoutEngineAction action) => throw new NotImplementedException(); + public ILayoutEngine PerformCustomAction(LayoutEngineCustomAction action) => + throw new NotImplementedException(); /// public ILayoutEngine MinimizeWindowStart(IWindow window) => throw new NotImplementedException(); diff --git a/src/Whim.Tests/Commands/CoreCommandsTests.cs b/src/Whim.Tests/Commands/CoreCommandsTests.cs index 665872b5b..f9c6c2554 100644 --- a/src/Whim.Tests/Commands/CoreCommandsTests.cs +++ b/src/Whim.Tests/Commands/CoreCommandsTests.cs @@ -480,7 +480,7 @@ public void FocusLayoutToggleMaximized_NotFocusLayoutEngine(IContext ctx, ILayou // Then IWorkspace workspace = ctx.WorkspaceManager.ActiveWorkspace; - workspace.DidNotReceive().PerformCustomLayoutEngineAction(Arg.Any()); + workspace.DidNotReceive().PerformCustomLayoutEngineAction(Arg.Any()); workspace.DidNotReceive().DoLayout(); } @@ -501,6 +501,6 @@ public void FocusLayoutToggleMaximized_FocusLayoutEngine(IContext ctx) // Then IWorkspace workspace = ctx.WorkspaceManager.ActiveWorkspace; - workspace.Received(1).PerformCustomLayoutEngineAction(Arg.Any()); + workspace.Received(1).PerformCustomLayoutEngineAction(Arg.Any()); } } diff --git a/src/Whim.Tests/Layout/ColumnLayoutEngineTests.cs b/src/Whim.Tests/Layout/ColumnLayoutEngineTests.cs index 7f68deb20..fbdba2015 100644 --- a/src/Whim.Tests/Layout/ColumnLayoutEngineTests.cs +++ b/src/Whim.Tests/Layout/ColumnLayoutEngineTests.cs @@ -961,7 +961,7 @@ public void PerformCustomAction(IWindow window) { // Given ILayoutEngine engine = new ColumnLayoutEngine(identity).AddWindow(window); - LayoutEngineAction action = + LayoutEngineCustomAction action = new() { Name = "Action", diff --git a/src/Whim.Tests/Layout/FocusLayoutEngineTests.cs b/src/Whim.Tests/Layout/FocusLayoutEngineTests.cs index 25611971b..254b562b8 100644 --- a/src/Whim.Tests/Layout/FocusLayoutEngineTests.cs +++ b/src/Whim.Tests/Layout/FocusLayoutEngineTests.cs @@ -297,7 +297,7 @@ IWindow window2 // When ILayoutEngine result = sut.PerformCustomAction( - new LayoutEngineAction() + new LayoutEngineCustomAction() { Name = actionName, Window = null, @@ -339,7 +339,7 @@ public void PerformCustomAction_UnknownAction(IWindow window1, IWindow window2) // When ILayoutEngine result = sut.PerformCustomAction( - new LayoutEngineAction() + new LayoutEngineCustomAction() { Name = "Focus.unknown", Window = null, diff --git a/src/Whim.Tests/Store/WorkspaceSector/Transforms/LayoutEngineActionTransformTests.cs b/src/Whim.Tests/Store/WorkspaceSector/Transforms/LayoutEngineCustomActionTransformTests.cs similarity index 78% rename from src/Whim.Tests/Store/WorkspaceSector/Transforms/LayoutEngineActionTransformTests.cs rename to src/Whim.Tests/Store/WorkspaceSector/Transforms/LayoutEngineCustomActionTransformTests.cs index 0b6fbdef0..3f16dcf0c 100644 --- a/src/Whim.Tests/Store/WorkspaceSector/Transforms/LayoutEngineActionTransformTests.cs +++ b/src/Whim.Tests/Store/WorkspaceSector/Transforms/LayoutEngineCustomActionTransformTests.cs @@ -3,26 +3,26 @@ namespace Whim.TestUtils; [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] -public class LayoutEngineActionTransformTests +public class LayoutEngineCustomActionTransformTests { private static readonly Guid WorkspaceId = Guid.NewGuid(); private static ILayoutEngine CreateLayoutEngineNotSupportingAction() { ILayoutEngine engine = Substitute.For(); - engine.PerformCustomAction(Arg.Any>()).Returns(engine); + engine.PerformCustomAction(Arg.Any>()).Returns(engine); return engine; } private static ILayoutEngine CreateLayoutEngineSupportingAction() { ILayoutEngine engine = Substitute.For(); - engine.PerformCustomAction(Arg.Any>()).Returns(Substitute.For()); + engine.PerformCustomAction(Arg.Any>()).Returns(Substitute.For()); return engine; } private static void NoChanges( - LayoutEngineActionWithPayloadTransform sut, + LayoutEngineCustomActionWithPayloadTransform sut, IContext ctx, MutableRootSector rootSector, IWindow window @@ -47,7 +47,7 @@ IWindow window } private static void Changes( - LayoutEngineActionWithPayloadTransform sut, + LayoutEngineCustomActionWithPayloadTransform sut, IContext ctx, MutableRootSector root, IWindow window @@ -81,10 +81,10 @@ IWindow window [Theory, AutoSubstituteData] internal void PayloadAction_NoChanges(IContext ctx, MutableRootSector root, IWindow window) { - LayoutEngineActionWithPayloadTransform sut = + LayoutEngineCustomActionWithPayloadTransform sut = new( WorkspaceId, - new LayoutEngineAction + new LayoutEngineCustomAction { Name = "Action", Payload = window, @@ -98,7 +98,8 @@ internal void PayloadAction_NoChanges(IContext ctx, MutableRootSector root, IWin [Theory, AutoSubstituteData] internal void NoPayload_NoChanges(IContext ctx, MutableRootSector root, IWindow window) { - LayoutEngineActionTransform sut = new(WorkspaceId, new LayoutEngineAction { Name = "Action", Window = window }); + LayoutEngineCustomActionTransform sut = + new(WorkspaceId, new LayoutEngineCustomAction { Name = "Action", Window = window }); NoChanges(sut, ctx, root, window); } @@ -106,10 +107,10 @@ internal void NoPayload_NoChanges(IContext ctx, MutableRootSector root, IWindow [Theory, AutoSubstituteData] internal void PayloadAction_Changes(IContext ctx, MutableRootSector root, IWindow window) { - LayoutEngineActionWithPayloadTransform sut = + LayoutEngineCustomActionWithPayloadTransform sut = new( WorkspaceId, - new LayoutEngineAction + new LayoutEngineCustomAction { Name = "Action", Payload = window, @@ -123,7 +124,8 @@ internal void PayloadAction_Changes(IContext ctx, MutableRootSector root, IWindo [Theory, AutoSubstituteData] internal void NoPayload_Changes(IContext ctx, MutableRootSector root, IWindow window) { - LayoutEngineActionTransform sut = new(WorkspaceId, new LayoutEngineAction { Name = "Action", Window = window }); + LayoutEngineCustomActionTransform sut = + new(WorkspaceId, new LayoutEngineCustomAction { Name = "Action", Window = window }); Changes(sut, ctx, root, window); } diff --git a/src/Whim.Tests/Workspace/LegacyWorkspaceTests.cs b/src/Whim.Tests/Workspace/LegacyWorkspaceTests.cs index ce8f3e13b..f555d4571 100644 --- a/src/Whim.Tests/Workspace/LegacyWorkspaceTests.cs +++ b/src/Whim.Tests/Workspace/LegacyWorkspaceTests.cs @@ -390,9 +390,9 @@ internal void PerformCustomLayoutEngineAction(bool isChanged, IContext ctx, IWin { // Given Workspace workspace = CreateWorkspace(ctx); - LayoutEngineAction action = new() { Name = "Test", Window = window }; + LayoutEngineCustomAction action = new() { Name = "Test", Window = window }; - ctx.Store.Dispatch(new LayoutEngineActionTransform(workspace.Id, action)).Returns(isChanged); + ctx.Store.Dispatch(new LayoutEngineCustomActionTransform(workspace.Id, action)).Returns(isChanged); // When bool result = workspace.PerformCustomLayoutEngineAction(action); @@ -408,7 +408,7 @@ internal void PerformCustomLayoutEngineAction_Payload(bool isChanged, IContext c { // Given Workspace workspace = CreateWorkspace(ctx); - LayoutEngineAction action = + LayoutEngineCustomAction action = new() { Name = "Test", @@ -416,7 +416,7 @@ internal void PerformCustomLayoutEngineAction_Payload(bool isChanged, IContext c Payload = window }; - ctx.Store.Dispatch(new LayoutEngineActionWithPayloadTransform(workspace.Id, action)) + ctx.Store.Dispatch(new LayoutEngineCustomActionWithPayloadTransform(workspace.Id, action)) .Returns(isChanged); // When diff --git a/src/Whim.TreeLayout.Tests/LayoutEngine/PerformCustomActionTests.cs b/src/Whim.TreeLayout.Tests/LayoutEngine/PerformCustomActionTests.cs index 0f9974638..8d998b14f 100644 --- a/src/Whim.TreeLayout.Tests/LayoutEngine/PerformCustomActionTests.cs +++ b/src/Whim.TreeLayout.Tests/LayoutEngine/PerformCustomActionTests.cs @@ -10,7 +10,7 @@ public void PerformCustomAction(IWindow window) { // Given LayoutEngineWrapper wrapper = new LayoutEngineWrapper().SetAsLastFocusedWindow(null); - LayoutEngineAction action = + LayoutEngineCustomAction action = new() { Name = "Action", diff --git a/src/Whim.TreeLayout/TreeLayoutEngine.cs b/src/Whim.TreeLayout/TreeLayoutEngine.cs index 3fdd97d5f..424ec41f7 100644 --- a/src/Whim.TreeLayout/TreeLayoutEngine.cs +++ b/src/Whim.TreeLayout/TreeLayoutEngine.cs @@ -774,5 +774,5 @@ public ILayoutEngine MinimizeWindowEnd(IWindow window) } /// - public ILayoutEngine PerformCustomAction(LayoutEngineAction action) => this; + public ILayoutEngine PerformCustomAction(LayoutEngineCustomAction action) => this; } diff --git a/src/Whim/Commands/CoreCommands.cs b/src/Whim/Commands/CoreCommands.cs index 6883b4734..5356e88c3 100644 --- a/src/Whim/Commands/CoreCommands.cs +++ b/src/Whim/Commands/CoreCommands.cs @@ -230,7 +230,11 @@ is not FocusLayoutEngine focusLayoutEngine } workspace.PerformCustomLayoutEngineAction( - new LayoutEngineAction() { Name = $"{focusLayoutEngine.Name}.toggle_maximized", Window = null } + new LayoutEngineCustomAction() + { + Name = $"{focusLayoutEngine.Name}.toggle_maximized", + Window = null + } ); }, condition: () => diff --git a/src/Whim/Layout/BaseProxyLayoutEngine.cs b/src/Whim/Layout/BaseProxyLayoutEngine.cs index 127449bba..a024430f1 100644 --- a/src/Whim/Layout/BaseProxyLayoutEngine.cs +++ b/src/Whim/Layout/BaseProxyLayoutEngine.cs @@ -75,7 +75,7 @@ protected BaseProxyLayoutEngine(ILayoutEngine innerLayoutEngine) public abstract IEnumerable DoLayout(IRectangle rectangle, IMonitor monitor); /// - public abstract ILayoutEngine PerformCustomAction(LayoutEngineAction action); + public abstract ILayoutEngine PerformCustomAction(LayoutEngineCustomAction action); /// public abstract ILayoutEngine MinimizeWindowStart(IWindow window); diff --git a/src/Whim/Layout/ColumnLayoutEngine.cs b/src/Whim/Layout/ColumnLayoutEngine.cs index b5097fa64..f5e433646 100644 --- a/src/Whim/Layout/ColumnLayoutEngine.cs +++ b/src/Whim/Layout/ColumnLayoutEngine.cs @@ -315,5 +315,5 @@ public ILayoutEngine MinimizeWindowEnd(IWindow window) } /// - public ILayoutEngine PerformCustomAction(LayoutEngineAction action) => this; + public ILayoutEngine PerformCustomAction(LayoutEngineCustomAction action) => this; } diff --git a/src/Whim/Layout/FocusLayoutEngine.cs b/src/Whim/Layout/FocusLayoutEngine.cs index 9683ef607..f00965546 100644 --- a/src/Whim/Layout/FocusLayoutEngine.cs +++ b/src/Whim/Layout/FocusLayoutEngine.cs @@ -285,7 +285,7 @@ public ILayoutEngine MinimizeWindowEnd(IWindow window) } /// - public ILayoutEngine PerformCustomAction(LayoutEngineAction action) + public ILayoutEngine PerformCustomAction(LayoutEngineCustomAction action) { if (action.Name == $"{Name}.toggle_maximized") { diff --git a/src/Whim/Layout/ILayoutEngine.cs b/src/Whim/Layout/ILayoutEngine.cs index 5116d5a38..0f1a5dbe9 100644 --- a/src/Whim/Layout/ILayoutEngine.cs +++ b/src/Whim/Layout/ILayoutEngine.cs @@ -156,7 +156,7 @@ public interface ILayoutEngine /// /// A new layout engine if the action is handled, otherwise it returns the current layout engine. /// - ILayoutEngine PerformCustomAction(LayoutEngineAction action); + ILayoutEngine PerformCustomAction(LayoutEngineCustomAction action); /// /// Checks to see if this or a child layout engine is type diff --git a/src/Whim/Layout/LayoutEngineAction.cs b/src/Whim/Layout/LayoutEngineCustomAction.cs similarity index 90% rename from src/Whim/Layout/LayoutEngineAction.cs rename to src/Whim/Layout/LayoutEngineCustomAction.cs index 41c621d4c..e0d915617 100644 --- a/src/Whim/Layout/LayoutEngineAction.cs +++ b/src/Whim/Layout/LayoutEngineCustomAction.cs @@ -3,7 +3,7 @@ namespace Whim; /// /// The payload for a custom action for a layout engine to perform, via . /// -public record LayoutEngineAction +public record LayoutEngineCustomAction { /// /// The name of the action. This should be unique to the layout engine type. @@ -25,7 +25,7 @@ public record LayoutEngineAction /// /// The type of . /// -public record LayoutEngineAction : LayoutEngineAction +public record LayoutEngineCustomAction : LayoutEngineCustomAction { /// /// The payload of the action, which the handler can use to perform the action. diff --git a/src/Whim/Store/WorkspaceSector/Transforms/LayoutEngineActionTransform.cs b/src/Whim/Store/WorkspaceSector/Transforms/LayoutEngineCustomActionTransform.cs similarity index 83% rename from src/Whim/Store/WorkspaceSector/Transforms/LayoutEngineActionTransform.cs rename to src/Whim/Store/WorkspaceSector/Transforms/LayoutEngineCustomActionTransform.cs index c2cb998a2..fcce1c182 100644 --- a/src/Whim/Store/WorkspaceSector/Transforms/LayoutEngineActionTransform.cs +++ b/src/Whim/Store/WorkspaceSector/Transforms/LayoutEngineCustomActionTransform.cs @@ -14,8 +14,10 @@ namespace Whim; /// /// Metadata about the action to perform, and the payload to perform it with. /// -public record LayoutEngineActionWithPayloadTransform(WorkspaceId WorkspaceId, LayoutEngineAction PayloadAction) - : BaseWorkspaceTransform(WorkspaceId) +public record LayoutEngineCustomActionWithPayloadTransform( + WorkspaceId WorkspaceId, + LayoutEngineCustomAction PayloadAction +) : BaseWorkspaceTransform(WorkspaceId) { private protected override Result WorkspaceOperation( IContext ctx, @@ -58,10 +60,10 @@ Workspace workspace /// /// Metadata about the action to perform, and the payload to perform it with. /// -public record LayoutEngineActionTransform(WorkspaceId WorkspaceId, LayoutEngineAction Action) - : LayoutEngineActionWithPayloadTransform( +public record LayoutEngineCustomActionTransform(WorkspaceId WorkspaceId, LayoutEngineCustomAction Action) + : LayoutEngineCustomActionWithPayloadTransform( WorkspaceId, - new LayoutEngineAction() + new LayoutEngineCustomAction() { Name = Action.Name, Payload = Action.Window, diff --git a/src/Whim/Workspace/IWorkspace.cs b/src/Whim/Workspace/IWorkspace.cs index 67152535d..72d951f78 100644 --- a/src/Whim/Workspace/IWorkspace.cs +++ b/src/Whim/Workspace/IWorkspace.cs @@ -283,7 +283,7 @@ bool MoveWindowEdgesInDirection( /// /// Whether the changed. /// - bool PerformCustomLayoutEngineAction(LayoutEngineAction action); + bool PerformCustomLayoutEngineAction(LayoutEngineCustomAction action); /// /// Performs a custom action in a layout engine. @@ -301,6 +301,6 @@ bool MoveWindowEdgesInDirection( /// /// Whether the changed. /// - bool PerformCustomLayoutEngineAction(LayoutEngineAction action); + bool PerformCustomLayoutEngineAction(LayoutEngineCustomAction action); #endregion } diff --git a/src/Whim/Workspace/LegacyWorkspace.cs b/src/Whim/Workspace/LegacyWorkspace.cs index eea9c4d9a..b6012c6f2 100644 --- a/src/Whim/Workspace/LegacyWorkspace.cs +++ b/src/Whim/Workspace/LegacyWorkspace.cs @@ -142,13 +142,15 @@ public bool MoveWindowToPoint(IWindow window, IPoint point, bool deferLa public bool ContainsWindow(IWindow window) => LatestWorkspace.WindowPositions.ContainsKey(window.Handle); /// - public bool PerformCustomLayoutEngineAction(LayoutEngineAction action) => - _context.Store.Dispatch(new LayoutEngineActionTransform(Id, action)).TryGet(out bool isChanged) && isChanged; + public bool PerformCustomLayoutEngineAction(LayoutEngineCustomAction action) => + _context.Store.Dispatch(new LayoutEngineCustomActionTransform(Id, action)).TryGet(out bool isChanged) + && isChanged; /// - public bool PerformCustomLayoutEngineAction(LayoutEngineAction action) => - _context.Store.Dispatch(new LayoutEngineActionWithPayloadTransform(Id, action)).TryGet(out bool isChanged) - && isChanged; + public bool PerformCustomLayoutEngineAction(LayoutEngineCustomAction action) => + _context + .Store.Dispatch(new LayoutEngineCustomActionWithPayloadTransform(Id, action)) + .TryGet(out bool isChanged) && isChanged; /// public void Dispose()