fixed bug with initial size and position calculation for X11Window (in some cases scaling is not applied until first position change event, and all calculations before it provided wrong values) (#12833)
Co-authored-by: Herman Kirshin <herman.kirshin@jetbrains.com>
// We need to set position first because it is required for getting correct display scale. If position is not manual then it can be
// 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
// Second call will calculate correct position because both current and owner windows have correct scaling.
SetWindowStartupLocation(owner);
StartRendering();
@ -787,6 +793,11 @@ namespace Avalonia.Controls
_showingAsDialog=true;
IsVisible=true;
// We need to set position first because it is required for getting correct display scale. If position is not manual then it can be
// 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);
varinitialSize=newSize(
double.IsNaN(Width)?ClientSize.Width:Width,
double.IsNaN(Height)?ClientSize.Height:Height);
@ -802,6 +813,7 @@ namespace Avalonia.Controls
Owner=owner;
// Second call will calculate correct position because both current and owner windows have correct scaling.