summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInho Lee <inho.lee@qt.io>2023-05-09 10:58:13 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-05-10 04:31:54 +0000
commitbe82e8bbc5d36a58f3cb961419d3a3a1d09f9750 (patch)
tree540a6ed33e3fc15a8a5cf9ba1290fe6d149fabf0
parent5570df776081c39995133c84525be5a5af39b7c0 (diff)
downloadqtwayland-be82e8bbc5d36a58f3cb961419d3a3a1d09f9750.tar.gz
Apply only valid min/max sizes
When setting min/max sizes, the minimum size can be larger than the maximum size. In that case, the size hint won't be applied to the geometry. Setting size hint will be pending until the min/max pair is valid and the actual geometry will not be changed with the invalid size hint. Fixes: QTBUG-113233 Change-Id: Ia05944e8342e7f8d794aee7883e0637a4c711c9d Reviewed-by: David Edmundson <davidedmundson@kde.org> (cherry picked from commit 42128ec10e2365b5235a80ebc0bb429402b8f95f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/client/qwaylandwindow.cpp12
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp12
2 files changed, 17 insertions, 7 deletions
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index bb1d944c..abab795c 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -369,9 +369,15 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
{
QSize minimum = windowMinimumSize();
QSize maximum = windowMaximumSize();
- QPlatformWindow::setGeometry(QRect(rect.x(), rect.y(),
- qBound(minimum.width(), rect.width(), maximum.width()),
- qBound(minimum.height(), rect.height(), maximum.height())));
+ int width = windowGeometry().width();
+ int height = windowGeometry().height();
+ if (minimum.width() <= maximum.width()
+ && minimum.height() <= maximum.height()) {
+ width = qBound(minimum.width(), rect.width(), maximum.width());
+ height = qBound(minimum.height(), rect.height(), maximum.height());
+ }
+
+ QPlatformWindow::setGeometry(QRect(rect.x(), rect.y(), width, height));
if (mViewport)
updateViewport();
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
index eebfb9e0..8e41e5a7 100644
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
@@ -416,14 +416,18 @@ void QWaylandXdgSurface::setSizeHints()
if (m_toplevel && m_window) {
const int minWidth = qMax(0, m_window->windowMinimumSize().width());
const int minHeight = qMax(0, m_window->windowMinimumSize().height());
- m_toplevel->set_min_size(minWidth, minHeight);
-
- int maxWidth = qMax(minWidth, m_window->windowMaximumSize().width());
+ int maxWidth = qMax(0, m_window->windowMaximumSize().width());
+ int maxHeight = qMax(0, m_window->windowMaximumSize().height());
if (maxWidth == QWINDOWSIZE_MAX)
maxWidth = 0;
- int maxHeight = qMax(minHeight, m_window->windowMaximumSize().height());
if (maxHeight == QWINDOWSIZE_MAX)
maxHeight = 0;
+
+ // It will not change min/max sizes if invalid.
+ if (minWidth > maxHeight || minHeight > maxHeight)
+ return;
+
+ m_toplevel->set_min_size(minWidth, minHeight);
m_toplevel->set_max_size(maxWidth, maxHeight);
}
}