QWindow: avoid extra window resize on changing min/max sizes

Amends e7477e8934.
Do not call QWindow::resize() on changing min/max sizes if
bounded window size has not changed. Otherwise it may unexpectedly
reset window's state on some platforms, like Windows and Linux.

Fixes: QTBUG-115699
Pick-to: 6.5 6.6
Change-Id: I217ca3fd854a1f41d6df312e3258734d1d3bce45
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
bb10
Vladimir Belyavsky 2023-09-09 11:20:56 +03:00
parent 63eaa3a989
commit 7efc0f6f19
1 changed files with 4 additions and 1 deletions

View File

@ -612,7 +612,10 @@ void QWindowPrivate::setMinOrMaxSize(QSize *oldSizeMember, const QSize &size,
// resize window if current size is outside of min and max limits
if (minimumSize.width() <= maximumSize.width()
|| minimumSize.height() <= maximumSize.height()) {
q->resize(q->geometry().size().expandedTo(minimumSize).boundedTo(maximumSize));
const QSize currentSize = q->size();
const QSize boundedSize = currentSize.expandedTo(minimumSize).boundedTo(maximumSize);
if (currentSize != boundedSize)
q->resize(boundedSize);
}
}