AppWindow sizing on zoomed screen
Describe the bug
If a Windows screen is not at 100% zoom, MoveAndResize has unexpected behavior.
Steps to reproduce the bug
Place a WinUI-3 window (wrapped on new AppWindow) on a screen with resolution different from 100%, ie: 150%.
Read its size via AppWindow.Size property. For example the result is 800x600.
Set 800x600 as rect size in AppWindow.MoveAndResize()
The window is now bigger.
Re-read size: the result is 1200x900 (150% of expected).
Expected behavior
Scaling both get and set or never scale size.
Screenshots
No response
NuGet package version
1.1.1
Packaging type
Packaged (MSIX)
Windows version
Windows 11 version 21H2 (22000)
IDE
Visual Studio 2022
Additional context
High severity for Apps that must save last window position (also for extra app windows).
I also encountered this bug.
I think
myAppWindow.MoveAndResize({x, y, w, h});
should function the same as
myAppWindow.Move({x, y});
myAppWindow.Resize({w, h});
thus
myAppWindow.MoveAndResize({x, y, w, h});
// Retrieve the window position and size immediately after calling MoveAndResize.
const auto pos = myAppWindow.Position();
const auto size = myAppWindow.Size();
// You would expect the following assert to be true.
assert(pos.X == x && pos.Y == y && size.Width == w && size.Height == h);
However, AppWindow.MoveAndResize currently behaves more like ResizeAndMove. DPI differences between monitors can cause the window size to change while moving.