-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix window jump and size change while moving a floating window in bet…
…ween monitors (#1001) Avoid the "window jump + size change" when you move a window in between monitors. `NormalizeRectangle` now clamps to the monitor's bounds. --------- Co-authored-by: Isaac Daly <[email protected]>
- Loading branch information
Showing
11 changed files
with
238 additions
and
121 deletions.
There are no files selected for viewing
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
46 changes: 46 additions & 0 deletions
46
src/Whim.FloatingWindow.Tests/FloatingWindowCustomization.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,46 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using AutoFixture; | ||
using NSubstitute; | ||
using Whim.TestUtils; | ||
using Windows.Win32.Foundation; | ||
using Windows.Win32.Graphics.Gdi; | ||
|
||
namespace Whim.FloatingWindow.Tests; | ||
|
||
public class FloatingWindowCustomization : ICustomization | ||
{ | ||
[SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] | ||
public void Customize(IFixture fixture) | ||
{ | ||
IContext ctx = fixture.Freeze<IContext>(); | ||
IInternalContext internalCtx = fixture.Freeze<IInternalContext>(); | ||
|
||
Store store = new(ctx, internalCtx); | ||
ctx.Store.Returns(store); | ||
|
||
IWindow window1 = StoreTestUtils.CreateWindow((HWND)1); | ||
IWindow window2 = StoreTestUtils.CreateWindow((HWND)2); | ||
IWindow window3 = StoreTestUtils.CreateWindow((HWND)3); | ||
Workspace workspace = StoreTestUtils.CreateWorkspace(ctx); | ||
|
||
IMonitor monitor = StoreTestUtils.CreateMonitor((HMONITOR)123); | ||
monitor.WorkingArea.Returns(new Rectangle<int>() { Width = 1000, Height = 1000 }); | ||
|
||
StoreTestUtils.SetupMonitorAtPoint(ctx, internalCtx, store._root.MutableRootSector, monitor); | ||
|
||
StoreTestUtils.PopulateThreeWayMap(ctx, store._root.MutableRootSector, monitor, workspace, window1); | ||
StoreTestUtils.PopulateThreeWayMap(ctx, store._root.MutableRootSector, monitor, workspace, window2); | ||
StoreTestUtils.PopulateThreeWayMap(ctx, store._root.MutableRootSector, monitor, workspace, window3); | ||
|
||
ctx.NativeManager.DwmGetWindowRectangle(Arg.Any<HWND>()) | ||
.Returns(new Rectangle<int>() { Width = 100, Height = 100 }); | ||
|
||
fixture.Inject(monitor); | ||
fixture.Inject(store._root); | ||
fixture.Inject(store._root.MutableRootSector); | ||
fixture.Inject(workspace); | ||
|
||
// Only inject the first window. Other windows can be retrieved from the WindowSector. | ||
fixture.Inject(window1); | ||
} | ||
} |
Oops, something went wrong.