diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2023-11-13 16:49:25 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2023-11-15 18:25:04 +0100 |
commit | 189f9873ae3f23377708fbf9880398fd6a078715 (patch) | |
tree | 368acceb407c57c68311fb767fb722e33a3dccb8 /tests/auto/gui/kernel | |
parent | 6658ccf5a1a0ef298fde1884e449c062faf011e3 (diff) |
macOS: Take window mask into account when computing QCocoaScreen::topLevelAt
Although not explicitly documented, this is the behavior in practice
on XCB and Windows, and we rely on this behavior in our implementation
of QApplication::widgetAt(), where we punch a temporary hole in the
widget using a mask if it has Qt::WA_TransparentForMouseEvents set.
Pick-to: 6.5 6.6
Fixes: QTBUG-41696
Task-number: QTBUG-119092
Change-Id: Ie7abc31b6930ee6b56fcdf391befc625c1ddf502
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'tests/auto/gui/kernel')
-rw-r--r-- | tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index 2a2dbd0e48..e4f1158d27 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -61,6 +61,8 @@ private slots: void staticFunctions(); + void topLevelAt(); + void settableStyleHints_data(); void settableStyleHints(); // Needs to run last as it changes style hints. }; @@ -1325,6 +1327,37 @@ void tst_QGuiApplication::staticFunctions() QPixmap::defaultDepth(); } +void tst_QGuiApplication::topLevelAt() +{ + int argc = 1; + char *argv[] = { const_cast<char*>("tst_qguiapplication") }; + QGuiApplication app(argc, argv); + + QWindow bottom; + bottom.setObjectName("Bottom"); + bottom.setFlag(Qt::FramelessWindowHint); + bottom.setGeometry(200, 200, 200, 200); + bottom.showNormal(); + QVERIFY(QTest::qWaitForWindowExposed(&bottom)); + QTRY_COMPARE(app.topLevelAt(QPoint(300, 300)), &bottom); + + QWindow top; + top.setObjectName("Top"); + top.setFlag(Qt::FramelessWindowHint); + top.setGeometry(200, 200, 200, 200); + top.showNormal(); + QVERIFY(QTest::qWaitForWindowExposed(&top)); + top.raise(); + QTRY_COMPARE(app.topLevelAt(QPoint(300, 300)), &top); + + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowMasks)) + QSKIP("QWindow::setMask() is not supported."); + + top.setMask(QRect(0, 0, 50, 50)); + QTRY_COMPARE(app.topLevelAt(QPoint(300, 300)), &bottom); + QTRY_COMPARE(app.topLevelAt(QPoint(225, 225)), &top); +} + void tst_QGuiApplication::settableStyleHints_data() { QTest::addColumn<bool>("appInstance"); |