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 | |
40 | QWaylandPointerGestureSwipe *createPointerGestureSwipe(QWaylandInputDevice *device); |
41 | QWaylandPointerGesturePinch *createPointerGesturePinch(QWaylandInputDevice *device); |
42 | }; |
43 | |
44 | class Q_WAYLANDCLIENT_EXPORT QWaylandPointerGestureSwipe : |
45 | public QtWayland::zwp_pointer_gesture_swipe_v1 |
46 | { |
47 | public: |
48 | QWaylandPointerGestureSwipe(QWaylandInputDevice *p); |
49 | ~QWaylandPointerGestureSwipe() override; |
50 | |
51 | void zwp_pointer_gesture_swipe_v1_begin(uint32_t serial, |
52 | uint32_t time, |
53 | struct ::wl_surface *surface, |
54 | uint32_t fingers) override; |
55 | |
56 | void zwp_pointer_gesture_swipe_v1_update(uint32_t time, |
57 | wl_fixed_t dx, |
58 | wl_fixed_t dy) override; |
59 | |
60 | void zwp_pointer_gesture_swipe_v1_end(uint32_t serial, |
61 | uint32_t time, |
62 | int32_t cancelled) override; |
63 | |
64 | struct ::zwp_pointer_gesture_swipe_v1 *zwp_pointer_gesture_swipe_v1() |
65 | { |
66 | return QtWayland::zwp_pointer_gesture_swipe_v1::object(); |
67 | } |
68 | |
69 | QWaylandInputDevice *mParent = nullptr; |
70 | QPointer<QWaylandWindow> mFocus; |
71 | uint mFingers = 0; |
72 | }; |
73 | |
74 | class Q_WAYLANDCLIENT_EXPORT QWaylandPointerGesturePinch : |
75 | public QtWayland::zwp_pointer_gesture_pinch_v1 |
76 | { |
77 | public: |
78 | QWaylandPointerGesturePinch(QWaylandInputDevice *p); |
79 | ~QWaylandPointerGesturePinch() override; |
80 | |
81 | void zwp_pointer_gesture_pinch_v1_begin(uint32_t serial, |
82 | uint32_t time, |
83 | struct ::wl_surface *surface, |
84 | uint32_t fingers) override; |
85 | |
86 | void zwp_pointer_gesture_pinch_v1_update(uint32_t time, |
87 | wl_fixed_t dx, |
88 | wl_fixed_t dy, |
89 | wl_fixed_t scale, |
90 | wl_fixed_t rotation) override; |
91 | |
92 | void zwp_pointer_gesture_pinch_v1_end(uint32_t serial, |
93 | uint32_t time, |
94 | int32_t cancelled) override; |
95 | |
96 | struct ::zwp_pointer_gesture_pinch_v1 *zwp_pointer_gesture_pinch_v1() |
97 | { |
98 | return QtWayland::zwp_pointer_gesture_pinch_v1::object(); |
99 | } |
100 | |
101 | QWaylandInputDevice *mParent = nullptr; |
102 | QPointer<QWaylandWindow> mFocus; |
103 | uint mFingers = 0; |
104 | |
105 | // We need to convert between absolute scale provided by wayland/libinput and zoom deltas |
106 | // that Qt expects. This stores the scale of the last pinch event or 1.0 if there was none. |
107 | qreal mLastScale = 1; |
108 | }; |
109 | |
110 | } // namespace QtWaylandClient |
111 | |
112 | QT_END_NAMESPACE |
113 | |
114 | #endif // QWAYLANDPOINTERGESTURES_P_H |
115 | |