Add TabletEvent QPointingDevice constructor workaround for Qt 6

This commit is contained in:
Vlad Zahorodnii 2022-10-10 18:38:54 +03:00
parent 7f80c47758
commit 35606fd9ee
3 changed files with 30 additions and 0 deletions

View file

@ -54,6 +54,16 @@ SwitchEvent::SwitchEvent(State state, quint32 timestamp, quint64 timestampMicros
{
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
TabletEvent::TabletEvent(Type t, const QPointingDevice *dev, const QPointF &pos, const QPointF &globalPos,
qreal pressure, float xTilt, float yTilt,
float tangentialPressure, qreal rotation, float z,
Qt::KeyboardModifiers keyState, Qt::MouseButton button, Qt::MouseButtons buttons, const TabletToolId &tabletId)
: QTabletEvent(t, dev, pos, globalPos, pressure, xTilt, yTilt, tangentialPressure, rotation, z, keyState, button, buttons)
, m_id(tabletId)
{
}
#else
TabletEvent::TabletEvent(Type t, const QPointF &pos, const QPointF &globalPos,
int device, int pointerType, qreal pressure, int xTilt, int yTilt,
qreal tangentialPressure, qreal rotation, int z,
@ -63,5 +73,6 @@ TabletEvent::TabletEvent(Type t, const QPointF &pos, const QPointF &globalPos,
, m_id(tabletId)
{
}
#endif
}

View file

@ -209,11 +209,18 @@ public:
class TabletEvent : public QTabletEvent
{
public:
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
TabletEvent(Type t, const QPointingDevice *dev, const QPointF &pos, const QPointF &globalPos,
qreal pressure, float xTilt, float yTilt,
float tangentialPressure, qreal rotation, float z,
Qt::KeyboardModifiers keyState, Qt::MouseButton button, Qt::MouseButtons buttons, const TabletToolId &tabletId);
#else
TabletEvent(Type t, const QPointF &pos, const QPointF &globalPos,
int device, int pointerType, qreal pressure, int xTilt, int yTilt,
qreal tangentialPressure, qreal rotation, int z,
Qt::KeyboardModifiers keyState, qint64 uniqueID,
Qt::MouseButton button, Qt::MouseButtons buttons, const TabletToolId &tabletId);
#endif
const TabletToolId &tabletId() const
{

View file

@ -72,12 +72,24 @@ void TabletInputRedirection::tabletToolEvent(KWin::InputRedirection::TabletEvent
update();
const auto button = m_tipDown ? Qt::LeftButton : Qt::NoButton;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
// TODO: Not correct, but it should work fine. In long term, we need to stop using QTabletEvent.
const QPointingDevice *dev = QPointingDevice::primaryPointingDevice();
TabletEvent ev(t, dev, pos, pos, pressure,
xTilt, yTilt,
0, // tangentialPressure
rotation,
0, // z
Qt::NoModifier, button, button, tabletToolId);
#else
TabletEvent ev(t, pos, pos, QTabletEvent::Stylus, QTabletEvent::Pen, pressure,
xTilt, yTilt,
0, // tangentialPressure
rotation,
0, // z
Qt::NoModifier, tabletToolId.m_uniqueId, button, button, tabletToolId);
#endif
ev.setTimestamp(time);
input()->processSpies(std::bind(&InputEventSpy::tabletToolEvent, std::placeholders::_1, &ev));