Skip to content

Commit

Permalink
fix: opposite scroll direction in internal items
Browse files Browse the repository at this point in the history
Should generate WSeatWheelEvent correctly for internal items. Use
the opposite direction of wayland for Qt.

Refer-to: https://github.com/qt/qtwayland/blob/774c0be247bd04362fc7713919ac151c44e34ced/src/client/qwaylandinputdevice.cpp#L1089
  • Loading branch information
asterwyx authored and zccrs committed Oct 28, 2024
1 parent 096e1d2 commit e90f1c7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/server/kernel/wseat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ bool WSeat::sendEvent(WSurface *target, QObject *shellObject, QObject *eventObje
d->doNotifyAxis(static_cast<wlr_axis_source>(we->wlrSource()),
orientation,
we->wlrDelta(),
we->angleDelta().x()+we->angleDelta().y(), // one of them must be 0
-(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");
Expand Down Expand Up @@ -1080,7 +1080,9 @@ void WSeat::notifyAxis(WCursor *cursor, WInputDevice *device, wlr_axis_source_t
const QPointF &global = cursor->position();
const QPointF local = w ? global - QPointF(w->position()) : QPointF();

QPoint angleDelta = orientation == Qt::Horizontal ? QPoint(delta_discrete, 0) : QPoint(0, delta_discrete);
// Refer to https://github.com/qt/qtwayland/blob/774c0be247bd04362fc7713919ac151c44e34ced/src/client/qwaylandinputdevice.cpp#L1089
// The direction in Qt event is in the opposite direction of wayland one, generate a event identical to Qt's direction.
QPoint angleDelta = orientation == Qt::Horizontal ? QPoint(-delta_discrete, 0) : QPoint(0, -delta_discrete);
WSeatWheelEvent e(source, delta, local, global, QPoint(), angleDelta, Qt::NoButton, d->keyModifiers,
Qt::NoScrollPhase, false, Qt::MouseEventNotSynthesized, qwDevice);
e.setTimestamp(timestamp);
Expand Down

0 comments on commit e90f1c7

Please sign in to comment.