From ad1bd1563f3f65d0f7b65687af2ade42f7f9f3d9 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 28 Mar 2012 15:26:17 +0200 Subject: Implement window modality in QtGui MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QWindow already has windowModality() and setWindowModality() as part of its API from commit 516f4e283ba4626d7239630397ef867ab0366071. Platform plugins can use this already to setup modality hints on windows that they create, but it's not enough to implement modality fully. QGuiApplication gets a modalWindow() static method, which is similar to QApplication::activeModalWidget() in that it returns the last modal window to be shown. The modal window "stack" moves from QApplicationPrivate to QGuiApplicationPrivate. The enterModal*() and leaveModal*() functions in QApplicationPrivate are removed and replaced by QGuiApplicationPrivate::showModalWindow() and hideModalWindow(), which are called by QWindow::setVisible() just before calling QPlatformWindow::setVisible(). The virtual QGuiApplicationPrivate::isWindowBlocked() will tell us if a window is blocked by a modal window (and tell which modal window for any interested callers). The default implementation works on the QWindow level. QApplicationPrivate reimplements isWindowBlocked() and adds popup and WA_GroupLeader support. QGuiApplication uses the state set from isWindowBlocked() to block user-input events: mouse press, mouse move, mouse release, wheel, key presses, key releases, enter/leave events, close events, and touch begin, update, and end events. Note also that the modality helper functions in QtWidgets and QApplicationPrivate are left in place and working as they always have. The behavior of QWidget in the presence of modal windows/dialogs should not change. Change-Id: I2c89e6026d40160387787a6e009ae1fdc12dfd69 Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll Reviewed-by: Samuel Rødal Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qwindow_p.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/gui/kernel/qwindow_p.h') diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h index 7f3958b3ff..eb4fab9013 100644 --- a/src/gui/kernel/qwindow_p.h +++ b/src/gui/kernel/qwindow_p.h @@ -79,6 +79,7 @@ public: , windowOrientation(Qt::PrimaryOrientation) , maximumSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX) , modality(Qt::NonModal) + , blockedByModalWindow(false) , transientParent(0) , screen(0) { @@ -120,6 +121,8 @@ public: QSize sizeIncrement; Qt::WindowModality modality; + bool blockedByModalWindow; + QPointer transientParent; QScreen *screen; }; -- cgit v1.2.3