From b0ba5c78eee0a476f5ab3e55e3bf3b5476e481c4 Mon Sep 17 00:00:00 2001 From: Vladimir Belyavsky Date: Sat, 9 Sep 2023 11:37:25 +0300 Subject: QWindow: bail out early on resize() if size has not changed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On some platforms, like Windows and Linux, calling resize() may unexpectedly reset window state even when the actual size has not changed. So, bail out early on QWindow::resize() if new size is the same. Task-number: QTBUG-115699 Change-Id: I64ad611044008964b5201951a50f3866e2108b49 Reviewed-by: Tor Arne Vestbø Reviewed-by: Jan Arve Sæther --- src/gui/kernel/qwindow.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/gui/kernel/qwindow.cpp') diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 3c9194cb6e..00d66913e1 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -614,8 +614,7 @@ void QWindowPrivate::setMinOrMaxSize(QSize *oldSizeMember, const QSize &size, || minimumSize.height() <= maximumSize.height()) { const QSize currentSize = q->size(); const QSize boundedSize = currentSize.expandedTo(minimumSize).boundedTo(maximumSize); - if (currentSize != boundedSize) - q->resize(boundedSize); + q->resize(boundedSize); } } @@ -1646,20 +1645,18 @@ void QWindow::setY(int arg) \property QWindow::width \brief the width of the window's geometry */ -void QWindow::setWidth(int arg) +void QWindow::setWidth(int w) { - if (width() != arg) - resize(arg, height()); + resize(w, height()); } /*! \property QWindow::height \brief the height of the window's geometry */ -void QWindow::setHeight(int arg) +void QWindow::setHeight(int h) { - if (height() != arg) - resize(width(), arg); + resize(width(), h); } /*! @@ -1981,12 +1978,16 @@ void QWindow::resize(int w, int h) void QWindow::resize(const QSize &newSize) { Q_D(QWindow); + + const QSize oldSize = size(); + if (newSize == oldSize) + return; + d->positionPolicy = QWindowPrivate::WindowFrameExclusive; if (d->platformWindow) { d->platformWindow->setGeometry( QHighDpi::toNativeWindowGeometry(QRect(position(), newSize), this)); } else { - const QSize oldSize = d->geometry.size(); d->geometry.setSize(newSize); if (newSize.width() != oldSize.width()) emit widthChanged(newSize.width()); -- cgit v1.2.3