summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@qt.io>2017-09-13 20:35:36 +0200
committerGatis Paeglis <gatis.paeglis@qt.io>2017-10-10 22:09:29 +0000
commit2764d82dc4b2ffdc2a21bd78c75cec14f59c2adf (patch)
treea7c8188ea96a411c65574ec6de28f8a27a83fb64
parent72dfe1deb32bc1efcb71ea61a4de6e76ad396ee7 (diff)
tablet: use enhanced mouse event when synthesizing mouse
All the required data is just there, few lines above. Instead of throwing it away and then deducing again in mouse event handler, use the enhanced mouse constructor. Tablet event handler was the last remaining user of the obsolete mouse event constructor. This patch removes the now unused construtor. Change-Id: I0df7f1b82f0e768f651aa7fbe2d4efce93e992fa Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
-rw-r--r--src/gui/kernel/qguiapplication.cpp36
-rw-r--r--src/gui/kernel/qwindowsysteminterface_p.h7
2 files changed, 23 insertions, 20 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 20fe738469..d967b03fee 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -2409,20 +2409,30 @@ void QGuiApplicationPrivate::processTabletEvent(QWindowSystemInterfacePrivate::T
break;
}
}
- QTabletEvent ev(type, local, e->global,
- e->device, e->pointerType, e->pressure, e->xTilt, e->yTilt,
- e->tangentialPressure, e->rotation, e->z,
- e->modifiers, e->uid, button, e->buttons);
- ev.setAccepted(false);
- ev.setTimestamp(e->timestamp);
- QGuiApplication::sendSpontaneousEvent(window, &ev);
+ QTabletEvent tabletEvent(type, local, e->global,
+ e->device, e->pointerType, e->pressure, e->xTilt, e->yTilt,
+ e->tangentialPressure, e->rotation, e->z,
+ e->modifiers, e->uid, button, e->buttons);
+ tabletEvent.setAccepted(false);
+ tabletEvent.setTimestamp(e->timestamp);
+ QGuiApplication::sendSpontaneousEvent(window, &tabletEvent);
pointData.state = e->buttons;
- if (!ev.isAccepted() && !QWindowSystemInterfacePrivate::TabletEvent::platformSynthesizesMouse
- && qApp->testAttribute(Qt::AA_SynthesizeMouseForUnhandledTabletEvents)) {
- QWindowSystemInterfacePrivate::MouseEvent fake(window, e->timestamp, e->local, e->global,
- e->buttons, e->modifiers, Qt::MouseEventSynthesizedByQt);
- fake.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic;
- processMouseEvent(&fake);
+ if (!tabletEvent.isAccepted()
+ && !QWindowSystemInterfacePrivate::TabletEvent::platformSynthesizesMouse
+ && qApp->testAttribute(Qt::AA_SynthesizeMouseForUnhandledTabletEvents)) {
+
+ const QEvent::Type mouseType = [&]() {
+ switch (type) {
+ case QEvent::TabletPress: return QEvent::MouseButtonPress;
+ case QEvent::TabletMove: return QEvent::MouseMove;
+ case QEvent::TabletRelease: return QEvent::MouseButtonRelease;
+ default: Q_UNREACHABLE();
+ }
+ }();
+ QWindowSystemInterfacePrivate::MouseEvent mouseEvent(window, e->timestamp, e->local,
+ e->global, e->buttons, e->modifiers, button, mouseType, Qt::MouseEventSynthesizedByQt);
+ mouseEvent.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic;
+ processMouseEvent(&mouseEvent);
}
#else
Q_UNUSED(e)
diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h
index 4fdf34c7b3..152ea92919 100644
--- a/src/gui/kernel/qwindowsysteminterface_p.h
+++ b/src/gui/kernel/qwindowsysteminterface_p.h
@@ -225,13 +225,6 @@ public:
class MouseEvent : public InputEvent {
public:
- // TODO - remove this ctor when all usages of it in QGuiApplication are cleaned out
- MouseEvent(QWindow * w, ulong time, const QPointF &local, const QPointF &global,
- Qt::MouseButtons b, Qt::KeyboardModifiers mods,
- Qt::MouseEventSource src = Qt::MouseEventNotSynthesized, bool frame = false)
- : InputEvent(w, time, Mouse, mods), localPos(local), globalPos(global), buttons(b),
- source(src), nonClientArea(frame), button(Qt::NoButton), buttonType(QEvent::None) { }
-
MouseEvent(QWindow *w, ulong time, const QPointF &local, const QPointF &global,
Qt::MouseButtons state, Qt::KeyboardModifiers mods,
Qt::MouseButton b, QEvent::Type type,