| 1 | // Copyright (C) 2021 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QWAYLANDPOINTERGESTURES_P_H |
| 5 | #define QWAYLANDPOINTERGESTURES_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtWaylandClient/private/qwayland-pointer-gestures-unstable-v1.h> |
| 19 | |
| 20 | #include <QtWaylandClient/private/qtwaylandclientglobal_p.h> |
| 21 | |
| 22 | #include <QtCore/QObject> |
| 23 | #include <QtCore/QPointer> |
| 24 | |
| 25 | QT_BEGIN_NAMESPACE |
| 26 | |
| 27 | namespace QtWaylandClient { |
| 28 | |
| 29 | class QWaylandDisplay; |
| 30 | class QWaylandWindow; |
| 31 | class QWaylandInputDevice; |
| 32 | class QWaylandPointerGestureSwipe; |
| 33 | class QWaylandPointerGesturePinch; |
| 34 | |
| 35 | class Q_WAYLANDCLIENT_EXPORT QWaylandPointerGestures : public QtWayland::zwp_pointer_gestures_v1 |
| 36 | { |
| 37 | public: |
| 38 | explicit QWaylandPointerGestures(QWaylandDisplay *display, uint id, uint version); |
| 39 | ~QWaylandPointerGestures(); |
| 40 | |
| 41 | QWaylandPointerGestureSwipe *createPointerGestureSwipe(QWaylandInputDevice *device); |
| 42 | QWaylandPointerGesturePinch *createPointerGesturePinch(QWaylandInputDevice *device); |
| 43 | }; |
| 44 | |
| 45 | class Q_WAYLANDCLIENT_EXPORT QWaylandPointerGestureSwipe : |
| 46 | public QtWayland::zwp_pointer_gesture_swipe_v1 |
| 47 | { |
| 48 | public: |
| 49 | QWaylandPointerGestureSwipe(QWaylandInputDevice *p); |
| 50 | ~QWaylandPointerGestureSwipe() override; |
| 51 | |
| 52 | void zwp_pointer_gesture_swipe_v1_begin(uint32_t serial, |
| 53 | uint32_t time, |
| 54 | struct ::wl_surface *surface, |
| 55 | uint32_t fingers) override; |
| 56 | |
| 57 | void zwp_pointer_gesture_swipe_v1_update(uint32_t time, |
| 58 | wl_fixed_t dx, |
| 59 | wl_fixed_t dy) override; |
| 60 | |
| 61 | void zwp_pointer_gesture_swipe_v1_end(uint32_t serial, |
| 62 | uint32_t time, |
| 63 | int32_t cancelled) override; |
| 64 | |
| 65 | struct ::zwp_pointer_gesture_swipe_v1 *zwp_pointer_gesture_swipe_v1() |
| 66 | { |
| 67 | return QtWayland::zwp_pointer_gesture_swipe_v1::object(); |
| 68 | } |
| 69 | |
| 70 | QWaylandInputDevice *mParent = nullptr; |
| 71 | QPointer<QWaylandWindow> mFocus; |
| 72 | uint mFingers = 0; |
| 73 | }; |
| 74 | |
| 75 | class Q_WAYLANDCLIENT_EXPORT QWaylandPointerGesturePinch : |
| 76 | public QtWayland::zwp_pointer_gesture_pinch_v1 |
| 77 | { |
| 78 | public: |
| 79 | QWaylandPointerGesturePinch(QWaylandInputDevice *p); |
| 80 | ~QWaylandPointerGesturePinch() override; |
| 81 | |
| 82 | void zwp_pointer_gesture_pinch_v1_begin(uint32_t serial, |
| 83 | uint32_t time, |
| 84 | struct ::wl_surface *surface, |
| 85 | uint32_t fingers) override; |
| 86 | |
| 87 | void zwp_pointer_gesture_pinch_v1_update(uint32_t time, |
| 88 | wl_fixed_t dx, |
| 89 | wl_fixed_t dy, |
| 90 | wl_fixed_t scale, |
| 91 | wl_fixed_t rotation) override; |
| 92 | |
| 93 | void zwp_pointer_gesture_pinch_v1_end(uint32_t serial, |
| 94 | uint32_t time, |
| 95 | int32_t cancelled) override; |
| 96 | |
| 97 | struct ::zwp_pointer_gesture_pinch_v1 *zwp_pointer_gesture_pinch_v1() |
| 98 | { |
| 99 | return QtWayland::zwp_pointer_gesture_pinch_v1::object(); |
| 100 | } |
| 101 | |
| 102 | QWaylandInputDevice *mParent = nullptr; |
| 103 | QPointer<QWaylandWindow> mFocus; |
| 104 | uint mFingers = 0; |
| 105 | |
| 106 | // We need to convert between absolute scale provided by wayland/libinput and zoom deltas |
| 107 | // that Qt expects. This stores the scale of the last pinch event or 1.0 if there was none. |
| 108 | qreal mLastScale = 1; |
| 109 | }; |
| 110 | |
| 111 | } // namespace QtWaylandClient |
| 112 | |
| 113 | QT_END_NAMESPACE |
| 114 | |
| 115 | #endif // QWAYLANDPOINTERGESTURES_P_H |
| 116 | |