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>
This commit is contained in:
Gatis Paeglis 2017-09-13 20:35:36 +02:00
parent 72dfe1deb3
commit 2764d82dc4
2 changed files with 23 additions and 20 deletions

View File

@ -2409,20 +2409,30 @@ void QGuiApplicationPrivate::processTabletEvent(QWindowSystemInterfacePrivate::T
break;
}
}
QTabletEvent ev(type, local, e->global,
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);
ev.setAccepted(false);
ev.setTimestamp(e->timestamp);
QGuiApplication::sendSpontaneousEvent(window, &ev);
tabletEvent.setAccepted(false);
tabletEvent.setTimestamp(e->timestamp);
QGuiApplication::sendSpontaneousEvent(window, &tabletEvent);
pointData.state = e->buttons;
if (!ev.isAccepted() && !QWindowSystemInterfacePrivate::TabletEvent::platformSynthesizesMouse
if (!tabletEvent.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);
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)

View File

@ -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,