summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Edmundson <davidedmundson@kde.org>2023-12-13 12:43:27 +0000
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-02-20 18:25:08 +0000
commit2435e705d3b37e0ab27b2f78722d3e7f19e59658 (patch)
treeb5dddcc412de29a0dc2acd880e068df8e872bdc1
parenta41765e35a80e7ece1f22e0e3bf19e7fba7f1cbf (diff)
client: Fix xdg shell setting only a minimum size hint
An unbound maximum size is sent across the protocol as 0. We need to make this change before the check that the minimum size is less than the maximum size. This fixes having only a minimum size set. This bug is currently masked by the platform forcefully applying the minimum size. Change-Id: Ifca4fa01e4c2ac1c34aeb72db1584e4a868d50bc Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org> (cherry picked from commit fdb29f3f6fa83e030ba8be30f3e23ff21dea6b5a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 1b71f375c978a57cb796dd1c652f9cb35938b42d)
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp9
-rw-r--r--tests/auto/client/xdgshell/tst_xdgshell.cpp59
2 files changed, 55 insertions, 13 deletions
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
index 2ff84e636..d8abd059b 100644
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
@@ -416,15 +416,16 @@ void QWaylandXdgSurface::setSizeHints()
const int minHeight = qMax(0, minSize.height());
int maxWidth = qMax(0, maxSize.width());
int maxHeight = qMax(0, maxSize.height());
- if (maxWidth == QWINDOWSIZE_MAX)
- maxWidth = 0;
- if (maxHeight == QWINDOWSIZE_MAX)
- maxHeight = 0;
// It will not change min/max sizes if invalid.
if (minWidth > maxWidth || minHeight > maxHeight)
return;
+ if (maxWidth == QWINDOWSIZE_MAX)
+ maxWidth = 0;
+ if (maxHeight == QWINDOWSIZE_MAX)
+ maxHeight = 0;
+
m_toplevel->set_min_size(minWidth, minHeight);
m_toplevel->set_max_size(maxWidth, maxHeight);
}
diff --git a/tests/auto/client/xdgshell/tst_xdgshell.cpp b/tests/auto/client/xdgshell/tst_xdgshell.cpp
index 3268964fc..670898d77 100644
--- a/tests/auto/client/xdgshell/tst_xdgshell.cpp
+++ b/tests/auto/client/xdgshell/tst_xdgshell.cpp
@@ -26,6 +26,7 @@ private slots:
void switchPopups();
void hidePopupParent();
void pongs();
+ void minMaxSize_data();
void minMaxSize();
void windowGeometry();
void foreignSurface();
@@ -606,12 +607,47 @@ void tst_xdgshell::pongs()
QCOMPARE(pongSpy.first().at(0).toUInt(), serial);
}
+void tst_xdgshell::minMaxSize_data()
+{
+ QTest::addColumn<QSize>("initialMinSize");
+ QTest::addColumn<QSize>("initialMaxSize");
+ QTest::addColumn<QSize>("nextMinSize");
+ QTest::addColumn<QSize>("nextMaxSize");
+ QTest::addColumn<QSize>("expectedInitialMinSize");
+ QTest::addColumn<QSize>("expectedInitialMaxSize");
+ QTest::addColumn<QSize>("expectedNextMinSize");
+ QTest::addColumn<QSize>("expectedNextMaxSize");
+
+ QTest::newRow("onlyMinSize") << QSize(50, 60) << QSize() << QSize(500, 600) << QSize()
+ << QSize(50, 60) << QSize(0, 0) << QSize(500, 600) << QSize(0, 0);
+
+ QTest::newRow("onlyMaxSize") << QSize() << QSize(70, 80) << QSize() << QSize(700, 800)
+ << QSize(0,0 ) << QSize(70, 80) << QSize(0, 0) << QSize(700, 800);
+
+ QTest::newRow("maxIsSentAsZero") << QSize() << QSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX) << QSize() << QSize()
+ << QSize(0,0 ) << QSize(0, 0) << QSize(0, 0) << QSize(0, 0);
+
+
+ QTest::newRow("fullHints") << QSize(50, 60) << QSize(700, 800) << QSize(500, 600) << QSize(710, 810)
+ << QSize(50, 60) << QSize(700, 800) << QSize(500, 600) << QSize(710, 810);
+
+ // setting a minimum above the maximum is not allowed, we should no-op
+ QTest::newRow("invalidResize") << QSize(50, 60) << QSize(100, 100) << QSize(500, 600) << QSize(100, 100)
+ << QSize(50, 60) << QSize(100, 100) << QSize(50, 60) << QSize(100, 100);}
+
void tst_xdgshell::minMaxSize()
{
+ QFETCH(QSize, initialMinSize);
+ QFETCH(QSize, initialMaxSize);
+
+ QFETCH(QSize, expectedInitialMinSize);
+ QFETCH(QSize, expectedInitialMaxSize);
+
QRasterWindow window;
- window.setMinimumSize(QSize(100, 100));
- window.setMaximumSize(QSize(1000, 1000));
- window.resize(400, 320);
+ if (initialMinSize.isValid())
+ window.setMinimumSize(initialMinSize);
+ if (initialMaxSize.isValid())
+ window.setMaximumSize(initialMaxSize);
window.show();
QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
@@ -619,16 +655,21 @@ void tst_xdgshell::minMaxSize()
// we don't roundtrip with our configuration the initial commit should be correct
- QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
- QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+ QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, expectedInitialMinSize);
+ QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, expectedInitialMaxSize);
- window.setMaximumSize(QSize(500, 400));
+ QFETCH(QSize, nextMinSize);
+ QFETCH(QSize, expectedNextMinSize);
+ window.setMinimumSize(nextMinSize);
window.update();
- QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(500, 400));
+ QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, expectedNextMinSize);
+
+ QFETCH(QSize, nextMaxSize);
+ QFETCH(QSize, expectedNextMaxSize);
- window.setMinimumSize(QSize(50, 40));
+ window.setMaximumSize(nextMaxSize);
window.update();
- QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(50, 40));
+ QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, expectedNextMaxSize);
}
void tst_xdgshell::windowGeometry()