summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJian Liang <jianliang79@gmail.com>2013-02-06 12:38:24 +0800
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-12 23:52:56 +0100
commita65157e5b7a2a1c2f018507f9d45f5b311cd387c (patch)
treec953e1f29fa19a4bf21da5c0e2badc44650d32d5
parent9253509f3eebdcfc9669dd15caf9c7ec01f15dc7 (diff)
replay mouse press event after a popup widget has been closed
If a popup widget(e.g. a popup menu) has been closed due to a mouse press event, the mouse press event will be consumed by the popup widget and the widget under the mouse pointer can't receive the event. This will lead to confusing behavior such as a push button under the mouse pointer is not been push down. This patch replay the mouse press event if a popup widget has been closed. Change-Id: Id493583dfea9e64ab2964e28d559122c43bbc2a6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com> Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 50b61beb05..d7b9d8c5fb 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -352,6 +352,21 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
&& qt_replay_popup_mouse_event) {
if (m_widget->windowType() != Qt::Popup)
qt_button_down = 0;
+ if (event->type() == QEvent::MouseButtonPress) {
+ // the popup disappeared, replay the mouse press event
+ QWidget *w = QApplication::widgetAt(event->globalPos());
+ if (w && !QApplicationPrivate::isBlockedByModal(w)) {
+ QWindow *win = w->windowHandle();
+ if (!win)
+ win = w->nativeParentWidget()->windowHandle();
+ if (win && win->geometry().contains(event->globalPos())) {
+ const QPoint localPos = win->mapFromGlobal(event->globalPos());
+ QMouseEvent e(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(), event->button(), event->buttons(), event->modifiers());
+ e.setTimestamp(event->timestamp());
+ QApplication::sendSpontaneousEvent(win, &e);
+ }
+ }
+ }
qt_replay_popup_mouse_event = false;
#ifndef QT_NO_CONTEXTMENU
} else if (event->type() == QEvent::MouseButtonPress