Skip to content

Commit

Permalink
Bugfix: CanResize unused when Width/Height is set (#12445)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
uthidata and stepangovorko authored Sep 25, 2023

Verified

This commit was signed with the committer’s verified signature.
DomPeliniAerospike Dominic Pelini
1 parent db7cbaa commit 5113b70
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/Avalonia.X11/X11Window.cs
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 5113b70

Please sign in to comment.