From 5113b706970558726a5b45b84abbf373d9db64a8 Mon Sep 17 00:00:00 2001 From: Dat Ng Date: Mon, 25 Sep 2023 03:52:14 +0200 Subject: [PATCH] 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 --- src/Avalonia.X11/X11Window.cs | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/Avalonia.X11/X11Window.cs b/src/Avalonia.X11/X11Window.cs index d078ceb9f8d..7edf1fd025b 100644 --- a/src/Avalonia.X11/X11Window.cs +++ b/src/Avalonia.X11/X11Window.cs @@ -297,19 +297,30 @@ private void UpdateMotifHints() 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 @@ private void MoveResize(PixelPoint position, Size size, double scaling) private void Resize(Size clientSize, bool force, WindowResizeReason reason) { - if (!force && clientSize == ClientSize) + if (!force && (clientSize == ClientSize)) + { return; + } var needImmediatePopupResize = clientSize != ClientSize;