Directory: | ./ |
---|---|
File: | src/client/touch.h |
Date: | 2024-01-22 17:25:27 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 1 | 1 | 100.0% |
Branches: | 3 | 6 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /******************************************************************** | ||
2 | Copyright 2015 Martin Gräßlin <mgraesslin@kde.org> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 2.1 of the License, or (at your option) version 3, or any | ||
8 | later version accepted by the membership of KDE e.V. (or its | ||
9 | successor approved by the membership of KDE e.V.), which shall | ||
10 | act as a proxy defined in Section 6 of version 3 of the license. | ||
11 | |||
12 | This library is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | Lesser General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU Lesser General Public | ||
18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | ||
20 | #ifndef WAYLAND_TOUCH_H | ||
21 | #define WAYLAND_TOUCH_H | ||
22 | |||
23 | #include <QObject> | ||
24 | #include <QPoint> | ||
25 | // STD | ||
26 | #include <Wrapland/Client/wraplandclient_export.h> | ||
27 | #include <memory> | ||
28 | |||
29 | struct wl_touch; | ||
30 | |||
31 | namespace Wrapland | ||
32 | { | ||
33 | namespace Client | ||
34 | { | ||
35 | |||
36 | class Surface; | ||
37 | class Touch; | ||
38 | |||
39 | /** | ||
40 | * TODO | ||
41 | */ | ||
42 | class WRAPLANDCLIENT_EXPORT TouchPoint | ||
43 | { | ||
44 | public: | ||
45 | virtual ~TouchPoint(); | ||
46 | |||
47 | /** | ||
48 | * Unique in the scope of all TouchPoints currently being down. | ||
49 | * As soon as the TouchPoint is now longer down another TouchPoint | ||
50 | * might get assigned the id. | ||
51 | **/ | ||
52 | qint32 id() const; | ||
53 | /** | ||
54 | * The serial when the down event happened. | ||
55 | **/ | ||
56 | quint32 downSerial() const; | ||
57 | /** | ||
58 | * The serial when the up event happened. | ||
59 | **/ | ||
60 | quint32 upSerial() const; | ||
61 | /** | ||
62 | * Most recent timestamp | ||
63 | **/ | ||
64 | quint32 time() const; | ||
65 | /** | ||
66 | * All timestamps, references the positions. | ||
67 | * That is each position has a timestamp. | ||
68 | **/ | ||
69 | QVector<quint32> timestamps() const; | ||
70 | /** | ||
71 | * Most recent position | ||
72 | **/ | ||
73 | QPointF position() const; | ||
74 | /** | ||
75 | * All positions this TouchPoint had, updated with each move. | ||
76 | **/ | ||
77 | QVector<QPointF> positions() const; | ||
78 | /** | ||
79 | * The Surface this TouchPoint happened on. | ||
80 | **/ | ||
81 | QPointer<Surface> surface() const; | ||
82 | /** | ||
83 | * @c true if currently down, @c false otherwise. | ||
84 | **/ | ||
85 | bool isDown() const; | ||
86 | |||
87 | private: | ||
88 | friend class Touch; | ||
89 | explicit TouchPoint(); | ||
90 | class Private; | ||
91 | std::unique_ptr<Private> d; | ||
92 | }; | ||
93 | |||
94 | /** | ||
95 | * @short Wrapper for the wl_touch interface. | ||
96 | * | ||
97 | * This class is a convenient wrapper for the wl_touch interface. | ||
98 | * | ||
99 | * To create an instance use Seat::createTouch. | ||
100 | * | ||
101 | * @see Seat | ||
102 | **/ | ||
103 | class WRAPLANDCLIENT_EXPORT Touch : public QObject | ||
104 | { | ||
105 | Q_OBJECT | ||
106 | public: | ||
107 | explicit Touch(QObject* parent = nullptr); | ||
108 | virtual ~Touch(); | ||
109 | |||
110 | /** | ||
111 | * @returns @c true if managing a wl_pointer. | ||
112 | **/ | ||
113 | bool isValid() const; | ||
114 | /** | ||
115 | * Setup this Touch to manage the @p touch. | ||
116 | * When using Seat::createTouch there is no need to call this | ||
117 | * method. | ||
118 | **/ | ||
119 | void setup(wl_touch* touch); | ||
120 | /** | ||
121 | * Releases the wl_touch interface. | ||
122 | * After the interface has been released the Touch instance is no | ||
123 | * longer valid and can be setup with another wl_touch interface. | ||
124 | * | ||
125 | * This method is automatically invoked when the Seat which created this | ||
126 | * Touch gets released. | ||
127 | **/ | ||
128 | void release(); | ||
129 | |||
130 | /** | ||
131 | * The TouchPoints of the latest touch event sequence. | ||
132 | * Only valid till the next touch event sequence is started | ||
133 | **/ | ||
134 | QVector<TouchPoint*> sequence() const; | ||
135 | |||
136 | operator wl_touch*(); | ||
137 | operator wl_touch*() const; | ||
138 | |||
139 | Q_SIGNALS: | ||
140 | /** | ||
141 | * A new touch sequence is started. The previous sequence is discarded. | ||
142 | * @param startPoint The first point which started the sequence | ||
143 | **/ | ||
144 | void sequenceStarted(Wrapland::Client::TouchPoint* startPoint); | ||
145 | /** | ||
146 | * Sent if the compositor decides the touch stream is a global | ||
147 | * gesture. | ||
148 | **/ | ||
149 | void sequenceCanceled(); | ||
150 | /** | ||
151 | * Emitted once all touch points are no longer down. | ||
152 | **/ | ||
153 | void sequenceEnded(); | ||
154 | /** | ||
155 | * Indicates the end of a contact point list. | ||
156 | **/ | ||
157 | void frameEnded(); | ||
158 | /** | ||
159 | * TouchPoint @p point got added to the sequence. | ||
160 | **/ | ||
161 | void pointAdded(Wrapland::Client::TouchPoint* point); | ||
162 | /** | ||
163 | * TouchPoint @p point is no longer down. | ||
164 | * A new TouchPoint might reuse the Id of the @p point. | ||
165 | **/ | ||
166 | void pointRemoved(Wrapland::Client::TouchPoint* point); | ||
167 | /** | ||
168 | * TouchPoint @p point moved. | ||
169 | **/ | ||
170 | void pointMoved(Wrapland::Client::TouchPoint* point); | ||
171 | |||
172 | private: | ||
173 | class Private; | ||
174 | std::unique_ptr<Private> d; | ||
175 | }; | ||
176 | |||
177 | } | ||
178 | } | ||
179 | |||
180 |
3/6✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
2 | Q_DECLARE_METATYPE(Wrapland::Client::TouchPoint*) |
181 | |||
182 | #endif | ||
183 |