diff --git a/src/server/kernel/wseat.cpp b/src/server/kernel/wseat.cpp index 40bfc7e9..28fc3fc8 100644 --- a/src/server/kernel/wseat.cpp +++ b/src/server/kernel/wseat.cpp @@ -46,7 +46,7 @@ Q_LOGGING_CATEGORY(qLcWlrGestureEvents, "waylib.server.seat.events.gesture", QtW #if QT_CONFIG(wheelevent) class Q_DECL_HIDDEN WSeatWheelEvent : public QWheelEvent { public: - WSeatWheelEvent(wlr_axis_source_t wlr_source, double wlr_delta, + WSeatWheelEvent(wlr_axis_source_t wlr_source, double wlr_delta, Qt::Orientation orientation, const QPointF &pos, const QPointF &globalPos, QPoint pixelDelta, QPoint angleDelta, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase, bool inverted, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized, @@ -54,16 +54,18 @@ class Q_DECL_HIDDEN WSeatWheelEvent : public QWheelEvent { : QWheelEvent(pos, globalPos, pixelDelta, angleDelta, buttons, modifiers, phase, inverted, source, device) , m_wlrSource(wlr_source) , m_wlrDelta(wlr_delta) + , m_orientation(orientation) { } inline wlr_axis_source_t wlrSource() const { return m_wlrSource; } inline double wlrDelta() const { return m_wlrDelta; } - + inline Qt::Orientation orientation() const { return m_orientation; } protected: wlr_axis_source_t m_wlrSource; double m_wlrDelta; + Qt::Orientation m_orientation; }; #endif @@ -848,12 +850,11 @@ bool WSeat::sendEvent(WSurface *target, QObject *shellObject, QObject *eventObje } case QEvent::Wheel: { if (auto we = dynamic_cast(event)) { - Qt::Orientation orientation = we->angleDelta().x() == 0 ? Qt::Vertical : Qt::Horizontal; d->doNotifyAxis(static_cast(we->wlrSource()), - orientation, - we->wlrDelta(), - -(we->angleDelta().x()+we->angleDelta().y()), // one of them must be 0, restore to wayland direction here. - we->timestamp()); + we->orientation(), + we->wlrDelta(), + -(we->angleDelta().x() + we->angleDelta().y()), // one of them must be 0, restore to wayland direction here. + we->timestamp()); } else { qWarning("An Wheel event was received that was not sent by wlroot and will be ignored"); } @@ -1085,14 +1086,14 @@ void WSeat::notifyAxis(WCursor *cursor, WInputDevice *device, wlr_axis_source_t QPoint angleDelta, pixelDelta; if (Qt::Horizontal == orientation) { - angleDelta = QPoint(-delta, 0); - pixelDelta = QPoint(-delta_discrete, 0); + angleDelta = QPoint(-delta_discrete, 0); + pixelDelta = QPoint(-delta, 0); } else { - angleDelta = QPoint(0, -delta); - pixelDelta = QPoint(0, -delta_discrete); + angleDelta = QPoint(0, -delta_discrete); + pixelDelta = QPoint(0, -delta); } - WSeatWheelEvent e(source, delta, local, global, pixelDelta, angleDelta, Qt::NoButton, d->keyModifiers, + WSeatWheelEvent e(source, delta, orientation, local, global, pixelDelta, angleDelta, Qt::NoButton, d->keyModifiers, Qt::NoScrollPhase, false, Qt::MouseEventNotSynthesized, qwDevice); e.setTimestamp(timestamp);