summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qapplication.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/kernel/qapplication.cpp')
-rw-r--r--src/widgets/kernel/qapplication.cpp46
1 files changed, 39 insertions, 7 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 9d3c5f8616..ed6262ce93 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -2709,16 +2709,48 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
if (receiver->isWindowType())
QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(static_cast<QWindow *>(receiver), e);
- // capture the current mouse/keyboard state
if(e->spontaneous()) {
- if (e->type() == QEvent::MouseButtonPress
- || e->type() == QEvent::MouseButtonRelease) {
+ // Capture the current mouse and keyboard states. Doing so here is
+ // required in order to support QTestLib synthesized events. Real mouse
+ // and keyboard state updates from the platform plugin are managed by
+ // QGuiApplicationPrivate::process(Mouse|Wheel|Key|Touch|Tablet)Event();
+ switch (e->type()) {
+ case QEvent::MouseButtonPress:
+ {
QMouseEvent *me = static_cast<QMouseEvent*>(e);
- if(me->type() == QEvent::MouseButtonPress)
- QApplicationPrivate::mouse_buttons |= me->button();
- else
- QApplicationPrivate::mouse_buttons &= ~me->button();
+ QApplicationPrivate::modifier_buttons = me->modifiers();
+ QApplicationPrivate::mouse_buttons |= me->button();
+ break;
+ }
+ case QEvent::MouseButtonRelease:
+ {
+ QMouseEvent *me = static_cast<QMouseEvent*>(e);
+ QApplicationPrivate::modifier_buttons = me->modifiers();
+ QApplicationPrivate::mouse_buttons &= ~me->button();
+ break;
+ }
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease:
+ case QEvent::MouseMove:
+#ifndef QT_NO_WHEELEVENT
+ case QEvent::Wheel:
+#endif
+ case QEvent::TouchBegin:
+ case QEvent::TouchUpdate:
+ case QEvent::TouchEnd:
+#ifndef QT_NO_TABLETEVENT
+ case QEvent::TabletMove:
+ case QEvent::TabletPress:
+ case QEvent::TabletRelease:
+#endif
+ {
+ QInputEvent *ie = static_cast<QInputEvent*>(e);
+ QApplicationPrivate::modifier_buttons = ie->modifiers();
+ break;
}
+ default:
+ break;
+ }
}
#ifndef QT_NO_GESTURES