diff options
author | Lars Knoll <lars.knoll@digia.com> | 2015-06-02 08:43:17 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-06-02 08:02:35 +0000 |
commit | beef975f92e42143c464d68afa6b8cd4f7ef7389 (patch) | |
tree | 147efd478a0e3e9b693684522adb20a3674268eb /src/gui/kernel | |
parent | d83bd9c6f5abd936b853029bf7030ebb4792f9fb (diff) |
Cleanup the mouse event handling in testlib
Calling QCursor::setPos() to emulate mouse move events
is a rather bad idea, as it creates round trips through
the server, leading to timing issues etc.
In addition, we should not call qapp->notify(), but rather
route the events through the proper QPA interface. This
is required to properly generate all other events such
as enter/leave etc. As this breaks existing tests,
put the new behavior behind an #ifdef for now. Like this,
we can fix tests one by one, and then turn on the define by
default for 5.6 (with a changelog message).
We emulate timestamps to avoid creating double clicks
by mistake. In addition, fix QGuiApplication::processMouseEvent
to not push events back into the QPA event queue (as this is
a bad hack and breaks the new testing system).
Change-Id: I71774cb56674d7fb66b9a7cf1e1ada1629536408
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 10 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface.cpp | 4 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 4146ddd8ba..024578ccdd 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1695,12 +1695,14 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo // A mouse event should not change both position and buttons at the same time. Instead we // should first send a move event followed by a button changed event. Since this is not the case // with the current event, we split it in two. - QWindowSystemInterfacePrivate::MouseEvent *mouseButtonEvent = new QWindowSystemInterfacePrivate::MouseEvent( + QWindowSystemInterfacePrivate::MouseEvent mouseButtonEvent( e->window.data(), e->timestamp, e->type, e->localPos, e->globalPos, e->buttons, e->modifiers); if (e->flags & QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic) - mouseButtonEvent->flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic; - QWindowSystemInterfacePrivate::windowSystemEventQueue.prepend(mouseButtonEvent); - stateChange = Qt::NoButton; + mouseButtonEvent.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic; + e->buttons = buttons; + processMouseEvent(e); + processMouseEvent(&mouseButtonEvent); + return; } QWindow *window = e->window.data(); diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index de8e5fbe64..823387b702 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -810,8 +810,8 @@ Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QWindowSystemInterface::TouchPo } #endif -Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *w, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods = Qt::NoModifier) { - unsigned long timestamp = QWindowSystemInterfacePrivate::eventTime.elapsed(); +Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *w, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods, int timestamp) +{ QWindowSystemInterfacePrivate::MouseEvent e(w, timestamp, local, global, b, mods, Qt::MouseEventNotSynthesized); QGuiApplicationPrivate::processWindowSystemEvent(&e); } |