diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2014-08-28 12:59:14 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2014-08-28 13:26:06 +0200 |
commit | 4354fef3d4c45a9ac1c01cf99627aad6d3b4d68d (patch) | |
tree | 0e7dedef2b3b69be53b13ae2673cb652a36d9028 /tests | |
parent | 2d12ef0be0f1f9abeeae15ffa430b5a96905b0da (diff) |
Windows: Prevent hidden transient children from being re-shown by Windows.
Bring back code from Qt 4 to handle WM_SHOWWINDOW / SW_PARENTOPENING
correctly.
Task-number: QTBUG-40696
Change-Id: If018bf90573f495dbe32d0c46f522ccde0691ebb
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 0686ca792c..25e5255189 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -39,10 +39,11 @@ ** ****************************************************************************/ -#include <qwindow.h> +#include <qrasterwindow.h> #include <qpa/qwindowsysteminterface.h> #include <qpa/qplatformintegration.h> #include <private/qguiapplication_p.h> +#include <QtGui/QPainter> #include <QtTest/QtTest> @@ -51,6 +52,8 @@ #if defined(Q_OS_QNX) #include <QOpenGLContext> +#elif defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +# include <QtCore/qt_windows.h> #endif // For QSignalSpy slot connections. @@ -94,6 +97,7 @@ private slots: void modalWithChildWindow(); void modalWindowModallity(); void modalWindowPosition(); + void windowsTransientChildren(); void initTestCase(); void cleanup(); @@ -1539,6 +1543,59 @@ void tst_QWindow::modalWindowPosition() QCOMPARE(window.geometry(), origGeo); } +class ColoredWindow : public QRasterWindow { +public: + explicit ColoredWindow(const QColor &color, QWindow *parent = 0) : QRasterWindow(parent), m_color(color) {} + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE + { + QPainter p(this); + p.fillRect(QRect(QPoint(0, 0), size()), m_color); + } + +private: + const QColor m_color; +}; + +static bool isNativeWindowVisible(const QWindow *window) +{ +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) + return IsWindowVisible(reinterpret_cast<HWND>(window->winId())); +#else + Q_UNIMPLEMENTED(); + return window->isVisible(); +#endif +} + +void tst_QWindow::windowsTransientChildren() +{ + if (QGuiApplication::platformName().compare(QStringLiteral("windows"), Qt::CaseInsensitive)) + QSKIP("Windows only test"); + + ColoredWindow mainWindow(Qt::yellow); + mainWindow.setGeometry(QRect(m_availableTopLeft + QPoint(100, 100), m_testWindowSize)); + mainWindow.setTitle(QStringLiteral("Main")); + ColoredWindow child(Qt::blue, &mainWindow); + child.setGeometry(QRect(QPoint(0, 0), m_testWindowSize / 2)); + + ColoredWindow dialog(Qt::red); + dialog.setGeometry(QRect(m_availableTopLeft + QPoint(200, 200), m_testWindowSize)); + dialog.setTitle(QStringLiteral("Dialog")); + dialog.setTransientParent(&mainWindow); + + mainWindow.show(); + child.show(); + dialog.show(); + + QVERIFY(QTest::qWaitForWindowExposed(&dialog)); + mainWindow.setWindowState(Qt::WindowMinimized); + QVERIFY(!isNativeWindowVisible(&dialog)); + dialog.hide(); + mainWindow.setWindowState(Qt::WindowNoState); + // QTBUG-40696, transient children hidden by Qt should not be re-shown by Windows. + QVERIFY(!isNativeWindowVisible(&dialog)); + QVERIFY(isNativeWindowVisible(&child)); // Real children should be visible. +} + #include <tst_qwindow.moc> QTEST_MAIN(tst_QWindow) |