Skip to content

Commit

Permalink
Undo LayoutEngineCustomAction breaking name change (#917)
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
dalyIsaac authored Jun 27, 2024
1 parent 1ac3bab commit 2f6dc23
Show file tree
Hide file tree
Showing 29 changed files with 89 additions and 77 deletions.
4 changes: 2 additions & 2 deletions src/Whim.Bar.Tests/BarLayoutEngineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public void PerformCustomAction_NotSame(ILayoutEngine innerLayoutEngine, ILayout
{
// Given
BarLayoutEngine engine = CreateSut(innerLayoutEngine);
LayoutEngineAction<string> action =
LayoutEngineCustomAction<string> action =
new()
{
Name = "Action",
Expand All @@ -366,7 +366,7 @@ public void PerformCustomAction_Same(ILayoutEngine innerLayoutEngine)
{
// Given
BarLayoutEngine engine = CreateSut(innerLayoutEngine);
LayoutEngineAction<string> action =
LayoutEngineCustomAction<string> action =
new()
{
Name = "Action",
Expand Down
2 changes: 1 addition & 1 deletion src/Whim.Bar/BarLayoutEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ public override ILayoutEngine MinimizeWindowEnd(IWindow window) =>
UpdateInner(InnerLayoutEngine.MinimizeWindowEnd(window));

/// <inheritdoc />
public override ILayoutEngine PerformCustomAction<T>(LayoutEngineAction<T> action) =>
public override ILayoutEngine PerformCustomAction<T>(LayoutEngineCustomAction<T> action) =>
UpdateInner(InnerLayoutEngine.PerformCustomAction(action));
}
6 changes: 3 additions & 3 deletions src/Whim.FloatingLayout.Tests/FloatingLayoutEngineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ ILayoutEngine innerLayoutEngine
{
// Given
FloatingLayoutEngine engine = new(context, plugin, innerLayoutEngine);
LayoutEngineAction<string> action =
LayoutEngineCustomAction<string> action =
new()
{
Name = "Action",
Expand All @@ -1138,7 +1138,7 @@ ILayoutEngine innerLayoutEngine
{
// Given
FloatingLayoutEngine engine = new(context, plugin, innerLayoutEngine);
LayoutEngineAction<string> action =
LayoutEngineCustomAction<string> action =
new()
{
Name = "Action",
Expand Down Expand Up @@ -1166,7 +1166,7 @@ IWindow window
{
// Given
FloatingLayoutEngine engine = new(context, plugin, innerLayoutEngine);
LayoutEngineAction<string> action =
LayoutEngineCustomAction<string> action =
new()
{
Name = "Action",
Expand Down
2 changes: 1 addition & 1 deletion src/Whim.FloatingLayout/FloatingLayoutEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public override ILayoutEngine MinimizeWindowEnd(IWindow window) =>
UpdateInner(InnerLayoutEngine.MinimizeWindowEnd(window), window);

/// <inheritdoc />
public override ILayoutEngine PerformCustomAction<T>(LayoutEngineAction<T> action)
public override ILayoutEngine PerformCustomAction<T>(LayoutEngineCustomAction<T> action)
{
if (action.Window != null && IsWindowFloating(action.Window))
{
Expand Down
4 changes: 2 additions & 2 deletions src/Whim.Gaps.Tests/GapsLayoutEngineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ public void PerformCustomAction_NotSame(ILayoutEngine innerLayoutEngine, ILayout
// Given
GapsConfig gapsConfig = new() { OuterGap = 10, InnerGap = 5 };

LayoutEngineAction<string> action =
LayoutEngineCustomAction<string> action =
new()
{
Name = "Action",
Expand All @@ -746,7 +746,7 @@ public void PerformCustomAction_Same(ILayoutEngine innerLayoutEngine)
// Given
GapsConfig gapsConfig = new() { OuterGap = 10, InnerGap = 5 };

LayoutEngineAction<string> action =
LayoutEngineCustomAction<string> action =
new()
{
Name = "Action",
Expand Down
2 changes: 1 addition & 1 deletion src/Whim.Gaps/GapsLayoutEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,6 @@ public override ILayoutEngine MinimizeWindowEnd(IWindow window) =>
UpdateInner(InnerLayoutEngine.MinimizeWindowEnd(window));

/// <inheritdoc />
public override ILayoutEngine PerformCustomAction<T>(LayoutEngineAction<T> action) =>
public override ILayoutEngine PerformCustomAction<T>(LayoutEngineCustomAction<T> action) =>
UpdateInner(InnerLayoutEngine.PerformCustomAction(action));
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void PromoteWindowInStack_CannotFindWindow(IContext ctx, SliceLayoutPlugi
IWindowState[] beforeStates = sut.DoLayout(primaryMonitorBounds, Substitute.For<IMonitor>()).ToArray();

sut = sut.PerformCustomAction(
new LayoutEngineAction<IWindow>()
new LayoutEngineCustomAction<IWindow>()
{
Name = "whim.slice_layout.window.promote",
Window = untrackedWindow,
Expand Down Expand Up @@ -74,7 +74,7 @@ SliceLayoutPlugin plugin
}

sut = sut.PerformCustomAction(
new LayoutEngineAction<IWindow>()
new LayoutEngineCustomAction<IWindow>()
{
Name = "whim.slice_layout.window.promote",
Window = windows[focusedWindowIdx],
Expand All @@ -99,7 +99,7 @@ public void PromoteWindowInStack_EmptyLayoutEngine(IContext ctx, SliceLayoutPlug
IWindowState[] beforeStates = sut.DoLayout(primaryMonitorBounds, Substitute.For<IMonitor>()).ToArray();

sut = sut.PerformCustomAction(
new LayoutEngineAction<IWindow>()
new LayoutEngineCustomAction<IWindow>()
{
Name = "whim.slice_layout.window.promote",
Window = window,
Expand Down Expand Up @@ -131,7 +131,7 @@ public void DemoteWindowInStack_CannotFindWindow(IContext ctx, SliceLayoutPlugin
IWindowState[] beforeStates = sut.DoLayout(primaryMonitorBounds, Substitute.For<IMonitor>()).ToArray();

sut = sut.PerformCustomAction(
new LayoutEngineAction<IWindow>()
new LayoutEngineCustomAction<IWindow>()
{
Name = "whim.slice_layout.window.demote",
Window = untrackedWindow,
Expand Down Expand Up @@ -173,7 +173,7 @@ public void DemoteWindowInStack(int focusedWindowIdx, int expectedWindowIdx, ICo
}

sut = sut.PerformCustomAction(
new LayoutEngineAction<IWindow>()
new LayoutEngineCustomAction<IWindow>()
{
Name = "whim.slice_layout.window.demote",
Window = windows[focusedWindowIdx],
Expand All @@ -198,7 +198,7 @@ public void DemoteWindowInStack_EmptyLayoutEngine(IContext ctx, SliceLayoutPlugi
IWindowState[] beforeStates = sut.DoLayout(primaryMonitorBounds, Substitute.For<IMonitor>()).ToArray();

sut = sut.PerformCustomAction(
new LayoutEngineAction<IWindow>()
new LayoutEngineCustomAction<IWindow>()
{
Name = "whim.slice_layout.window.demote",
Window = window,
Expand Down Expand Up @@ -242,7 +242,7 @@ SliceLayoutPlugin plugin
}

ILayoutEngine resultSut = sut.PerformCustomAction(
new LayoutEngineAction<IWindow>()
new LayoutEngineCustomAction<IWindow>()
{
Name = promote ? plugin.PromoteFocusActionName : plugin.DemoteFocusActionName,
Window = windows[focusedWindowIdx],
Expand Down Expand Up @@ -273,7 +273,7 @@ public void PerformCustomAction_UnknownAction(IContext ctx, SliceLayoutPlugin pl
IWindowState[] beforeStates = sut.DoLayout(primaryMonitorBounds, Substitute.For<IMonitor>()).ToArray();

sut = sut.PerformCustomAction(
new LayoutEngineAction<IWindow>()
new LayoutEngineCustomAction<IWindow>()
{
Name = "whim.slice_layout.window.unknown",
Window = windows[0],
Expand Down
16 changes: 8 additions & 8 deletions src/Whim.SliceLayout.Tests/SliceLayoutPluginTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void PromoteWindowInStack_NoWorkspace(IContext ctx, IWindow window)

// Then nothing
IWorkspace activeWorkspace = ctx.WorkspaceManager.ActiveWorkspace;
activeWorkspace.DidNotReceive().PerformCustomLayoutEngineAction(Arg.Any<LayoutEngineAction>());
activeWorkspace.DidNotReceive().PerformCustomLayoutEngineAction(Arg.Any<LayoutEngineCustomAction>());
activeWorkspace.DidNotReceive().DoLayout();
}

Expand All @@ -133,7 +133,7 @@ public void PromoteWindowInStack(IContext ctx, IWindow window, IWorkspace worksp
workspace
.Received(1)
.PerformCustomLayoutEngineAction(
Arg.Is<LayoutEngineAction>(action =>
Arg.Is<LayoutEngineCustomAction>(action =>
action.Name == plugin.PromoteWindowActionName && action.Window == window
)
);
Expand Down Expand Up @@ -168,7 +168,7 @@ public void DemoteWindowInStack_NoWorkspace(IContext ctx, IWindow window)

// Then nothing
IWorkspace activeWorkspace = ctx.WorkspaceManager.ActiveWorkspace;
activeWorkspace.DidNotReceive().PerformCustomLayoutEngineAction(Arg.Any<LayoutEngineAction>());
activeWorkspace.DidNotReceive().PerformCustomLayoutEngineAction(Arg.Any<LayoutEngineCustomAction>());
activeWorkspace.DidNotReceive().DoLayout();
}

Expand All @@ -187,7 +187,7 @@ public void DemoteWindowInStack(IContext ctx, IWindow window, IWorkspace workspa
workspace
.Received(1)
.PerformCustomLayoutEngineAction(
Arg.Is<LayoutEngineAction>(action =>
Arg.Is<LayoutEngineCustomAction>(action =>
action.Name == plugin.DemoteWindowActionName && action.Window == window
)
);
Expand Down Expand Up @@ -239,7 +239,7 @@ public void PromoteFocusInStack_NoWorkspace(IContext ctx, IWindow window)

// Then nothing
ctx.WorkspaceManager.ActiveWorkspace.DidNotReceive()
.PerformCustomLayoutEngineAction(Arg.Any<LayoutEngineAction>());
.PerformCustomLayoutEngineAction(Arg.Any<LayoutEngineCustomAction>());
}

[Theory, AutoSubstituteData]
Expand All @@ -257,7 +257,7 @@ public void PromoteFocusInStack(IContext ctx, IWindow window, IWorkspace workspa
workspace
.Received(1)
.PerformCustomLayoutEngineAction(
Arg.Is<LayoutEngineAction>(action =>
Arg.Is<LayoutEngineCustomAction>(action =>
action.Name == plugin.PromoteFocusActionName && action.Window == window
)
);
Expand Down Expand Up @@ -292,7 +292,7 @@ public void DemoteFocusInStack_NoWorkspace(IContext ctx, IWindow window)

// Then nothing
ctx.WorkspaceManager.ActiveWorkspace.DidNotReceive()
.PerformCustomLayoutEngineAction(Arg.Any<LayoutEngineAction>());
.PerformCustomLayoutEngineAction(Arg.Any<LayoutEngineCustomAction>());
}

[Theory, AutoSubstituteData]
Expand All @@ -310,7 +310,7 @@ public void DemoteFocusInStack(IContext ctx, IWindow window, IWorkspace workspac
workspace
.Received(1)
.PerformCustomLayoutEngineAction(
Arg.Is<LayoutEngineAction>(action =>
Arg.Is<LayoutEngineCustomAction>(action =>
action.Name == plugin.DemoteFocusActionName && action.Window == window
)
);
Expand Down
11 changes: 6 additions & 5 deletions src/Whim.SliceLayout/SliceLayoutEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,17 +299,18 @@ public ILayoutEngine MinimizeWindowEnd(IWindow window)
}

/// <inheritdoc />
public ILayoutEngine PerformCustomAction<T>(LayoutEngineAction<T> action) =>
public ILayoutEngine PerformCustomAction<T>(LayoutEngineCustomAction<T> action) =>
action switch
{
LayoutEngineAction<IWindow> promoteAction when promoteAction.Name == _plugin.PromoteWindowActionName
LayoutEngineCustomAction<IWindow> promoteAction when promoteAction.Name == _plugin.PromoteWindowActionName
=> PromoteWindowInStack(promoteAction.Payload, promote: true),
LayoutEngineAction<IWindow> demoteAction when demoteAction.Name == _plugin.DemoteWindowActionName
LayoutEngineCustomAction<IWindow> demoteAction when demoteAction.Name == _plugin.DemoteWindowActionName
=> PromoteWindowInStack(demoteAction.Payload, promote: false),
LayoutEngineAction<IWindow> promoteFocusAction
LayoutEngineCustomAction<IWindow> promoteFocusAction
when promoteFocusAction.Name == _plugin.PromoteFocusActionName
=> PromoteFocusInStack(promoteFocusAction.Payload, promote: true),
LayoutEngineAction<IWindow> demoteFocusAction when demoteFocusAction.Name == _plugin.DemoteFocusActionName
LayoutEngineCustomAction<IWindow> demoteFocusAction
when demoteFocusAction.Name == _plugin.DemoteFocusActionName
=> PromoteFocusInStack(demoteFocusAction.Payload, promote: false),
_ => this
};
Expand Down
4 changes: 2 additions & 2 deletions src/Whim.SliceLayout/SliceLayoutPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private void ChangeWindowRank(IWindow? window, bool promote)
}

workspace.PerformCustomLayoutEngineAction(
new LayoutEngineAction()
new LayoutEngineCustomAction()
{
Name = promote ? PromoteWindowActionName : DemoteWindowActionName,
Window = definedWindow
Expand Down Expand Up @@ -107,7 +107,7 @@ private void FocusWindowRank(IWindow? window, bool promote)
}

workspace.PerformCustomLayoutEngineAction(
new LayoutEngineAction()
new LayoutEngineCustomAction()
{
Name = promote ? PromoteFocusActionName : DemoteFocusActionName,
Window = definedWindow
Expand Down
2 changes: 1 addition & 1 deletion src/Whim.TestUtils/ImmutableTestLayoutEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public IEnumerable<IWindowState> DoLayout(IRectangle<int> rectangle, IMonitor mo

public ILayoutEngine MoveWindowToPoint(IWindow window, IPoint<double> point) => this;

public ILayoutEngine PerformCustomAction<T>(LayoutEngineAction<T> action) => this;
public ILayoutEngine PerformCustomAction<T>(LayoutEngineCustomAction<T> action) => this;

public ILayoutEngine RemoveWindow(IWindow window) => this;

Expand Down
2 changes: 1 addition & 1 deletion src/Whim.TestUtils/ProxyLayoutEngineBaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public void PerformCustomAction_WindowIsPresent(ILayoutEngine inner, IWindow win
{
// Given
ILayoutEngine layoutEngine = CreateLayoutEngine(inner).AddWindow(window1);
LayoutEngineAction<string> action =
LayoutEngineCustomAction<string> action =
new()
{
Name = "Action",
Expand Down
3 changes: 2 additions & 1 deletion src/Whim.TestUtils/TestLayoutEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public ILayoutEngine SwapWindowInDirection(Direction direction, IWindow window)
throw new NotImplementedException();

/// <inheritdoc/>
public ILayoutEngine PerformCustomAction<T>(LayoutEngineAction<T> action) => throw new NotImplementedException();
public ILayoutEngine PerformCustomAction<T>(LayoutEngineCustomAction<T> action) =>
throw new NotImplementedException();

/// <inheritdoc/>
public ILayoutEngine MinimizeWindowStart(IWindow window) => throw new NotImplementedException();
Expand Down
4 changes: 2 additions & 2 deletions src/Whim.Tests/Commands/CoreCommandsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ public void FocusLayoutToggleMaximized_NotFocusLayoutEngine(IContext ctx, ILayou

// Then
IWorkspace workspace = ctx.WorkspaceManager.ActiveWorkspace;
workspace.DidNotReceive().PerformCustomLayoutEngineAction(Arg.Any<LayoutEngineAction>());
workspace.DidNotReceive().PerformCustomLayoutEngineAction(Arg.Any<LayoutEngineCustomAction>());
workspace.DidNotReceive().DoLayout();
}

Expand All @@ -501,6 +501,6 @@ public void FocusLayoutToggleMaximized_FocusLayoutEngine(IContext ctx)

// Then
IWorkspace workspace = ctx.WorkspaceManager.ActiveWorkspace;
workspace.Received(1).PerformCustomLayoutEngineAction(Arg.Any<LayoutEngineAction>());
workspace.Received(1).PerformCustomLayoutEngineAction(Arg.Any<LayoutEngineCustomAction>());
}
}
2 changes: 1 addition & 1 deletion src/Whim.Tests/Layout/ColumnLayoutEngineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ public void PerformCustomAction(IWindow window)
{
// Given
ILayoutEngine engine = new ColumnLayoutEngine(identity).AddWindow(window);
LayoutEngineAction<string> action =
LayoutEngineCustomAction<string> action =
new()
{
Name = "Action",
Expand Down
4 changes: 2 additions & 2 deletions src/Whim.Tests/Layout/FocusLayoutEngineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ IWindow window2

// When
ILayoutEngine result = sut.PerformCustomAction(
new LayoutEngineAction<IWindow?>()
new LayoutEngineCustomAction<IWindow?>()
{
Name = actionName,
Window = null,
Expand Down Expand Up @@ -339,7 +339,7 @@ public void PerformCustomAction_UnknownAction(IWindow window1, IWindow window2)

// When
ILayoutEngine result = sut.PerformCustomAction(
new LayoutEngineAction<IWindow?>()
new LayoutEngineCustomAction<IWindow?>()
{
Name = "Focus.unknown",
Window = null,
Expand Down
Loading

0 comments on commit 2f6dc23

Please sign in to comment.