Skip to content

Commit

Permalink
fix very low scroll factor
Browse files Browse the repository at this point in the history
  • Loading branch information
lbwtw committed Nov 1, 2024
1 parent 6e88ca5 commit a9557ab
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/server/kernel/wseat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,26 @@ 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,
const QPointingDevice *device = QPointingDevice::primaryPointingDevice())
: 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

Expand Down Expand Up @@ -848,12 +850,11 @@ bool WSeat::sendEvent(WSurface *target, QObject *shellObject, QObject *eventObje
}
case QEvent::Wheel: {
if (auto we = dynamic_cast<WSeatWheelEvent*>(event)) {
Qt::Orientation orientation = we->angleDelta().x() == 0 ? Qt::Vertical : Qt::Horizontal;
d->doNotifyAxis(static_cast<wlr_axis_source>(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");
}
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit a9557ab

Please sign in to comment.