-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent additional layouts when focusing a window (#922)
Setting the `LastFocusedWindowHandle` for a workspace would previously trigger a layout, which would trigger the `FocusIndicatorPlugin` to flicker. `SetLastFocusedWindowTransform` now no longer triggers a layout operation.
- Loading branch information
Showing
2 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
src/Whim.Tests/Store/WorkspaceSector/Transforms/SetLastFocusedWindowTransformTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace Whim.Tests; | ||
|
||
[SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] | ||
public class SetLastFocusedWindowTransformTests | ||
{ | ||
[Theory, AutoSubstituteData<StoreCustomization>] | ||
internal void NoChanges(IContext ctx, MutableRootSector root) | ||
{ | ||
// Given the last focused window is the same as the window we're setting. | ||
IWindow window = CreateWindow((HWND)123); | ||
Workspace workspace = CreateWorkspace(ctx) with { LastFocusedWindowHandle = window.Handle }; | ||
|
||
workspace = PopulateWindowWorkspaceMap(ctx, root, window, workspace); | ||
|
||
SetLastFocusedWindowTransform sut = new(workspace.Id, window.Handle); | ||
|
||
// When we execute the transform | ||
Result<bool> result = ctx.Store.Dispatch(sut); | ||
|
||
// Then there are no changes | ||
Assert.True(result.IsSuccessful); | ||
Assert.False(result.Value); | ||
|
||
Workspace resultWorkspace = root.WorkspaceSector.Workspaces[workspace.Id]; | ||
Assert.Equal(window.Handle, resultWorkspace.LastFocusedWindowHandle); | ||
} | ||
|
||
[Theory, AutoSubstituteData<StoreCustomization>] | ||
internal void Success(IContext ctx, MutableRootSector root) | ||
{ | ||
// Given the last focused window is not the same as the window we're setting. | ||
IWindow window = CreateWindow((HWND)123); | ||
Workspace workspace = CreateWorkspace(ctx) with { LastFocusedWindowHandle = (HWND)456 }; | ||
|
||
workspace = PopulateWindowWorkspaceMap(ctx, root, window, workspace); | ||
|
||
SetLastFocusedWindowTransform sut = new(workspace.Id, window.Handle); | ||
|
||
// When we execute the transform | ||
Result<bool> result = ctx.Store.Dispatch(sut); | ||
|
||
// Then there are changes | ||
Assert.True(result.IsSuccessful); | ||
Assert.True(result.Value); | ||
|
||
Workspace resultWorkspace = root.WorkspaceSector.Workspaces[workspace.Id]; | ||
Assert.Equal(window.Handle, resultWorkspace.LastFocusedWindowHandle); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters