Browse Source

fix resize with high dpi on windows

pull/2221/head
ahopper 8 years ago
parent
commit
1d4b23f718
  1. 16
      src/Windows/Avalonia.Win32/WindowImpl.cs

16
src/Windows/Avalonia.Win32/WindowImpl.cs

@ -119,7 +119,7 @@ namespace Avalonia.Win32
} }
public Size ClientSize public Size ClientSize
{ {
get get
{ {
UnmanagedMethods.RECT rect; UnmanagedMethods.RECT rect;
@ -153,10 +153,14 @@ namespace Avalonia.Win32
public void Resize(Size value) public void Resize(Size value)
{ {
var clientRect = ClientSize; int requestedClientWidth = (int)(value.Width * Scaling);
if (value != clientRect) int requestedClientHeight = (int)(value.Height * Scaling);
UnmanagedMethods.RECT clientRect;
UnmanagedMethods.GetClientRect(_hwnd, out clientRect);
// do comparison after scaling to avoid rounding issues
if (requestedClientWidth != clientRect.Width || requestedClientHeight != clientRect.Height)
{ {
value *= Scaling;
UnmanagedMethods.RECT windowRect; UnmanagedMethods.RECT windowRect;
UnmanagedMethods.GetWindowRect(_hwnd, out windowRect); UnmanagedMethods.GetWindowRect(_hwnd, out windowRect);
@ -165,8 +169,8 @@ namespace Avalonia.Win32
IntPtr.Zero, IntPtr.Zero,
0, 0,
0, 0,
(int)(value.Width + (windowRect.Width - clientRect.Width)), requestedClientWidth + (windowRect.Width - clientRect.Width),
(int)(value.Height + (windowRect.Height - clientRect.Height)), requestedClientHeight + (windowRect.Height - clientRect.Height),
UnmanagedMethods.SetWindowPosFlags.SWP_RESIZE); UnmanagedMethods.SetWindowPosFlags.SWP_RESIZE);
} }
} }

Loading…
Cancel
Save