summaryrefslogtreecommitdiffstats
path: root/src/client/qwaylandinputdevice_p.h
diff options
context:
space:
mode:
authorRobin Burchell <robin.burchell@crimson.no>2017-07-30 21:50:41 +0200
committerJohan Helsing <johan.helsing@qt.io>2019-03-14 13:12:00 +0000
commit1607b8bb38e57d9d5ebdd075a9b1f3f992c5cfde (patch)
treebe94ebba713a87beef0bbc081731e2a6e89cb19a /src/client/qwaylandinputdevice_p.h
parenta1e6810e6914b4b43d9f7f1ee195e75b8d4426ab (diff)
Client: Implement wl_pointer version 5
Version 5 adds frame events, which groups multiple pointer events together, enabling diagonal scrolling, leave and enter without an intermediate state, and together with the new axis_source, axis_discrete and axis_stop also adds what needed to differentiate between wheel events and touchpad scrolling. This patch adds scroll phases and pixel deltas to QWaylandInputDevice, and makes sure handleWheelEvent is called accordingly. [ChangeLog][QPA plugin] Pixel delta is now set for mouse scrolling events if originating from an appropriate device such as a touch pad (requires compositor support for wl_seat version 5 or later). Fixes: QTBUG-69876 Fixes: QTBUG-63720 Change-Id: I094a1ef0365893bee135cae7e6df89fafdafa2f2 Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
Diffstat (limited to 'src/client/qwaylandinputdevice_p.h')
-rw-r--r--src/client/qwaylandinputdevice_p.h80
1 files changed, 64 insertions, 16 deletions
diff --git a/src/client/qwaylandinputdevice_p.h b/src/client/qwaylandinputdevice_p.h
index c2fd57bb0..0da73e5d5 100644
--- a/src/client/qwaylandinputdevice_p.h
+++ b/src/client/qwaylandinputdevice_p.h
@@ -262,6 +262,10 @@ public:
void pointer_axis(uint32_t time,
uint32_t axis,
wl_fixed_t value) override;
+ void pointer_axis_source(uint32_t source) override;
+ void pointer_axis_stop(uint32_t time, uint32_t axis) override;
+ void pointer_axis_discrete(uint32_t axis, int32_t value) override;
+ void pointer_frame() override;
void releaseButtons();
@@ -278,6 +282,30 @@ public:
wl_buffer *mCursorBuffer = nullptr;
Qt::CursorShape mCursorShape = Qt::BitmapCursor;
#endif
+
+ struct FrameData {
+ QWaylandPointerEvent *event = nullptr;
+
+ QPointF delta;
+ QPoint discreteDelta;
+ axis_source axisSource = axis_source_wheel;
+
+ void resetScrollData();
+ bool hasPixelDelta() const;
+ QPoint pixelDeltaAndError(QPointF *accumulatedError) const;
+ QPoint pixelDelta() const { return hasPixelDelta() ? delta.toPoint() : QPoint(); }
+ QPoint angleDelta() const;
+ Qt::MouseEventSource wheelEventSource() const;
+ } mFrameData;
+
+ bool mScrollBeginSent = false;
+ QPointF mScrollDeltaRemainder;
+
+ void setFrameEvent(QWaylandPointerEvent *event);
+ void flushScrollEvent();
+ void flushFrameEvent();
+private: //TODO: should other methods be private as well?
+ bool isDefinitelyTerminated(axis_source source) const;
};
class Q_WAYLAND_CLIENT_EXPORT QWaylandInputDevice::Touch : public QtWayland::wl_touch
@@ -313,38 +341,58 @@ public:
class QWaylandPointerEvent
{
+ Q_GADGET
public:
enum Type {
Enter,
+ Leave,
Motion,
+ Press,
+ Release,
Wheel
};
- inline QWaylandPointerEvent(Type t, ulong ts, const QPointF &l, const QPointF &g, Qt::MouseButtons b, Qt::KeyboardModifiers m)
- : type(t)
- , timestamp(ts)
- , local(l)
- , global(g)
- , buttons(b)
- , modifiers(m)
+ Q_ENUM(Type)
+
+ inline QWaylandPointerEvent(Type type, Qt::ScrollPhase phase, QWaylandWindow *surface,
+ ulong timestamp, const QPointF &localPos, const QPointF &globalPos,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
+ : type(type)
+ , phase(phase)
+ , timestamp(timestamp)
+ , local(localPos)
+ , global(globalPos)
+ , buttons(buttons)
+ , modifiers(modifiers)
+ , surface(surface)
{}
- inline QWaylandPointerEvent(Type t, ulong ts, const QPointF &l, const QPointF &g, const QPoint &pd, const QPoint &ad, Qt::KeyboardModifiers m)
- : type(t)
- , timestamp(ts)
- , local(l)
- , global(g)
- , modifiers(m)
- , pixelDelta(pd)
- , angleDelta(ad)
+ inline QWaylandPointerEvent(Type type, Qt::ScrollPhase phase, QWaylandWindow *surface,
+ ulong timestamp, const QPointF &local, const QPointF &global,
+ const QPoint &pixelDelta, const QPoint &angleDelta,
+ Qt::MouseEventSource source,
+ Qt::KeyboardModifiers modifiers)
+ : type(type)
+ , phase(phase)
+ , timestamp(timestamp)
+ , local(local)
+ , global(global)
+ , modifiers(modifiers)
+ , pixelDelta(pixelDelta)
+ , angleDelta(angleDelta)
+ , source(source)
+ , surface(surface)
{}
Type type;
- ulong timestamp;
+ Qt::ScrollPhase phase = Qt::NoScrollPhase;
+ ulong timestamp = 0;
QPointF local;
QPointF global;
Qt::MouseButtons buttons;
Qt::KeyboardModifiers modifiers;
QPoint pixelDelta;
QPoint angleDelta;
+ Qt::MouseEventSource source = Qt::MouseEventNotSynthesized;
+ QWaylandWindow *surface = nullptr;
};
}