Browse Source

Bugfix: CanResize unused when Width/Height is set (#12445)

* Trigger CI/CD

* Bugfix: CanResize unused when Width/Height is set

2 problems in X11Window.cs
- In UpdateSizeHints: max and min sizes were set
regardless of _canResize, if preResize is not null
- In Resize, many things are set without checking for _canResize

Added the check for _canResize, which stops the resizing if not forced
(e.g. when a dialog needs a startup size)
Make setting varying max and min exclusively when _canResize is false

---------

Co-authored-by: stepan_govorko <stepan.govorko@jetbrains.com>
pull/13012/head
Dat Ng 3 years ago
committed by GitHub
parent
commit
5113b70697
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 29
      src/Avalonia.X11/X11Window.cs

29
src/Avalonia.X11/X11Window.cs

@ -297,19 +297,30 @@ namespace Avalonia.X11
private void UpdateSizeHints(PixelSize? preResize)
{
if(_overrideRedirect)
if (_overrideRedirect)
return;
var min = _minMaxSize.minSize;
var max = _minMaxSize.maxSize;
if (!_canResize)
max = min = _realSize;
if (preResize.HasValue)
{
var desired = preResize.Value;
max = new PixelSize(Math.Max(desired.Width, max.Width), Math.Max(desired.Height, max.Height));
min = new PixelSize(Math.Min(desired.Width, min.Width), Math.Min(desired.Height, min.Height));
if (preResize.HasValue)
{
max = min = preResize.Value;
}
else
{
max = min = _realSize;
}
}
else
{
if (preResize.HasValue)
{
var desired = preResize.Value;
max = new PixelSize(Math.Max(desired.Width, max.Width), Math.Max(desired.Height, max.Height));
min = new PixelSize(Math.Min(desired.Width, min.Width), Math.Min(desired.Height, min.Height));
}
}
var hints = new XSizeHints
@ -1001,8 +1012,10 @@ namespace Avalonia.X11
private void Resize(Size clientSize, bool force, WindowResizeReason reason)
{
if (!force && clientSize == ClientSize)
if (!force && (clientSize == ClientSize))
{
return;
}
var needImmediatePopupResize = clientSize != ClientSize;

Loading…
Cancel
Save