diff options
Diffstat (limited to 'src/gui/kernel/qguiapplication.cpp')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 64d2f8001f..efb34ffe9f 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -105,6 +105,7 @@ QPointF QGuiApplicationPrivate::lastCursorPosition(0.0, 0.0); bool QGuiApplicationPrivate::tabletState = false; QWindow *QGuiApplicationPrivate::tabletPressTarget = 0; +QWindow *QGuiApplicationPrivate::currentMouseWindow = 0; QPlatformIntegration *QGuiApplicationPrivate::platform_integration = 0; QPlatformTheme *QGuiApplicationPrivate::platform_theme = 0; @@ -455,7 +456,19 @@ void QGuiApplicationPrivate::showModalWindow(QWindow *modal) { self->modalWindowList.prepend(modal); - QEvent e(QEvent::WindowBlocked); + // Send leave for currently entered window if it should be blocked + if (currentMouseWindow && (currentMouseWindow->windowType() & Qt::Popup) != Qt::Popup) { + bool shouldBeBlocked = self->isWindowBlocked(currentMouseWindow); + if (shouldBeBlocked) { + // Remove the new window from modalWindowList temporarily so leave can go through + self->modalWindowList.removeFirst(); + QEvent e(QEvent::Leave); + QGuiApplication::sendEvent(currentMouseWindow, &e); + currentMouseWindow = 0; + self->modalWindowList.prepend(modal); + } + } + QWindowList windows = QGuiApplication::topLevelWindows(); for (int i = 0; i < windows.count(); ++i) { QWindow *window = windows.at(i); @@ -470,7 +483,6 @@ void QGuiApplicationPrivate::hideModalWindow(QWindow *window) { self->modalWindowList.removeAll(window); - QEvent e(QEvent::WindowUnblocked); QWindowList windows = QGuiApplication::topLevelWindows(); for (int i = 0; i < windows.count(); ++i) { QWindow *window = windows.at(i); @@ -1410,6 +1422,8 @@ void QGuiApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::En return; } + currentMouseWindow = e->enter; + QEvent event(QEvent::Enter); QCoreApplication::sendSpontaneousEvent(e->enter.data(), &event); } @@ -1423,6 +1437,8 @@ void QGuiApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::Le return; } + currentMouseWindow = 0; + QEvent event(QEvent::Leave); QCoreApplication::sendSpontaneousEvent(e->leave.data(), &event); } |