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

Amends e7477e8934ab38722f5589914d08b3f15e870109.
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
Change-Id: I217ca3fd854a1f41d6df312e3258734d1d3bce45
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 7efc0f6f1994a06359deb859fd73126d576df226)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Vladimir Belyavsky 2023-09-09 11:20:56 +03:00 committed by Qt Cherry-pick Bot
parent a88f26f7e4
commit 8f07015af8

View File

@ -597,7 +597,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);
}
}