diff --git a/src/input_event.cpp b/src/input_event.cpp index 4523f40938..6fae06b1f4 100644 --- a/src/input_event.cpp +++ b/src/input_event.cpp @@ -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 } diff --git a/src/input_event.h b/src/input_event.h index 5a6e2c00cb..5a8efcc6be 100644 --- a/src/input_event.h +++ b/src/input_event.h @@ -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 { diff --git a/src/tablet_input.cpp b/src/tablet_input.cpp index f453ea234c..485a4a4b9a 100644 --- a/src/tablet_input.cpp +++ b/src/tablet_input.cpp @@ -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));