path: root/src
diff options
authorMiikka Heikkinen <>2012-11-01 11:28:16 +0200
committerThe Qt Project <>2012-11-06 20:26:43 +0100
commit715902051a6ba28b6a9f86fce28c12c1b977630c (patch)
treea21838765d4b1ce23875bbf24a86e64b3750999a /src
parent7d5b813de363d766266350b12cdd96894b0409d9 (diff)
Fix inconsistent leave/enter events for main window when popup is open
Changed the platform leave event handling logic in QWidgetWindow to match platform leave event handling logic in Qt4, where last mouse receiver is used as leave target only if last mouse receiver wasn't a native window itself. In that case it is assumed to get leave event of its own when relevant. Task-number: QTBUG-27639 Change-Id: Id6edcd29754a15c959f18ab38b20d66e5d446510 Reviewed-by: Friedemann Kleint <> Reviewed-by: Oliver Wolff <>
Diffstat (limited to 'src')
1 files changed, 5 insertions, 1 deletions
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index b49441beba..94e851ac4c 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -244,7 +244,11 @@ void QWidgetWindow::handleEnterLeaveEvent(QEvent *event)
// both native and non-native widgets work similarly.
// When mousegrabbing, leaves are only generated if leaving the parent window.
if (!enter || !QWidget::mouseGrabber()) {
- QWidget *leave = qt_last_mouse_receiver ? : m_widget;
+ // Preferred leave target is the last mouse receiver, unless it has native window,
+ // in which case it is assumed to receive it's own leave event when relevant.
+ QWidget *leave = m_widget;
+ if (qt_last_mouse_receiver && !qt_last_mouse_receiver->internalWinId())
+ leave =;
QApplicationPrivate::dispatchEnterLeave(enter, leave);
qt_last_mouse_receiver = enter;