Block input to a window shown while an application modal dialog is visible
Although the window is refused input for the most part from the system, it does not act like that it is blocked by the application modal dialog. This ensures that it is the case and prevents things like being able to double click on the title bar to maximize the window on Windows. Task-number: QTBUG-49102 Change-Id: If1582819b90cb2ec9d891f664da24f13bfec7103 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
parent
a26a3cfbc7
commit
a3d59c7c7f
@ -576,6 +576,8 @@ void QWindow::setVisible(bool visible)
|
||||
QGuiApplicationPrivate::showModalWindow(this);
|
||||
else
|
||||
QGuiApplicationPrivate::hideModalWindow(this);
|
||||
} else if (visible && QGuiApplication::modalWindow()) {
|
||||
QGuiApplicationPrivate::updateBlockedStatus(this);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_CURSOR
|
||||
|
@ -105,6 +105,7 @@ private slots:
|
||||
void stateChange();
|
||||
void flags();
|
||||
void cleanup();
|
||||
void testBlockingWindowShownAfterModalDialog();
|
||||
|
||||
private:
|
||||
QPoint m_availableTopLeft;
|
||||
@ -2241,6 +2242,47 @@ void tst_QWindow::flags()
|
||||
QCOMPARE(window.flags(), baseFlags | Qt::WindowStaysOnTopHint);
|
||||
}
|
||||
|
||||
class EventWindow : public QWindow
|
||||
{
|
||||
public:
|
||||
EventWindow() : QWindow(), gotBlocked(false) {}
|
||||
bool gotBlocked;
|
||||
protected:
|
||||
bool event(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::WindowBlocked)
|
||||
gotBlocked = true;
|
||||
return QWindow::event(e);
|
||||
}
|
||||
};
|
||||
|
||||
void tst_QWindow::testBlockingWindowShownAfterModalDialog()
|
||||
{
|
||||
EventWindow normalWindow;
|
||||
normalWindow.setFramePosition(m_availableTopLeft + QPoint(80, 80));
|
||||
normalWindow.resize(m_testWindowSize);
|
||||
normalWindow.show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&normalWindow));
|
||||
QVERIFY(!normalWindow.gotBlocked);
|
||||
|
||||
QWindow dialog;
|
||||
dialog.setFramePosition(m_availableTopLeft + QPoint(200, 200));
|
||||
dialog.resize(m_testWindowSize);
|
||||
dialog.setModality(Qt::ApplicationModal);
|
||||
dialog.setFlags(Qt::Dialog);
|
||||
dialog.show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&dialog));
|
||||
QVERIFY(normalWindow.gotBlocked);
|
||||
|
||||
EventWindow normalWindowAfter;
|
||||
normalWindowAfter.setFramePosition(m_availableTopLeft + QPoint(80, 80));
|
||||
normalWindowAfter.resize(m_testWindowSize);
|
||||
QVERIFY(!normalWindowAfter.gotBlocked);
|
||||
normalWindowAfter.show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&normalWindowAfter));
|
||||
QVERIFY(normalWindowAfter.gotBlocked);
|
||||
}
|
||||
|
||||
#include <tst_qwindow.moc>
|
||||
QTEST_MAIN(tst_QWindow)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user