Browse Source

Multi-Monitor DPI scaling breaks dialog sizes (#15304)

* Multi-Monitor DPI scaling breaks dialog sizes

* move the flag up

* second location
pull/15450/head
Lubomir Tetak 2 years ago
committed by GitHub
parent
commit
2ae162838c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 7
      src/Avalonia.Controls/Window.cs

7
src/Avalonia.Controls/Window.cs

@ -93,6 +93,7 @@ namespace Avalonia.Controls
private bool _isExtendedIntoWindowDecorations;
private Thickness _windowDecorationMargin;
private Thickness _offScreenMargin;
private bool _canHandleResized = false;
/// <summary>
/// Defines the <see cref="SizeToContent"/> property.
@ -722,6 +723,8 @@ namespace Avalonia.Controls
// thus we ought to call it again later to center window correctly if needed, when scaling will be already applied
SetWindowStartupLocation(owner);
_canHandleResized = true;
var initialSize = new Size(
double.IsNaN(Width) ? Math.Max(MinWidth, ClientSize.Width) : Width,
double.IsNaN(Height) ? Math.Max(MinHeight, ClientSize.Height) : Height);
@ -800,6 +803,8 @@ namespace Avalonia.Controls
// determined only by calling this method. But here it will calculate not precise location because scaling may not yet be applied (see i.e. X11Window),
// thus we ought to call it again later to center window correctly if needed, when scaling will be already applied
SetWindowStartupLocation(owner);
_canHandleResized = true;
var initialSize = new Size(
double.IsNaN(Width) ? ClientSize.Width : Width,
@ -1036,7 +1041,7 @@ namespace Avalonia.Controls
/// <inheritdoc/>
internal override void HandleResized(Size clientSize, WindowResizeReason reason)
{
if (ClientSize != clientSize || double.IsNaN(Width) || double.IsNaN(Height))
if (_canHandleResized && (ClientSize != clientSize || double.IsNaN(Width) || double.IsNaN(Height)))
{
var sizeToContent = SizeToContent;

Loading…
Cancel
Save