KWayland

touch.h
1 /*
2  SPDX-FileCopyrightText: 2015 Martin Gräßlin <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 #ifndef WAYLAND_TOUCH_H
7 #define WAYLAND_TOUCH_H
8 
9 #include <QObject>
10 #include <QPoint>
11 
12 #include <KWayland/Client/kwaylandclient_export.h>
13 
14 struct wl_touch;
15 
16 namespace KWayland
17 {
18 namespace Client
19 {
20 class Surface;
21 class Touch;
22 
23 /**
24  * TODO
25  */
26 class KWAYLANDCLIENT_EXPORT TouchPoint
27 {
28 public:
29  virtual ~TouchPoint();
30 
31  /**
32  * Unique in the scope of all TouchPoints currently being down.
33  * As soon as the TouchPoint is now longer down another TouchPoint
34  * might get assigned the id.
35  **/
36  qint32 id() const;
37  /**
38  * The serial when the down event happened.
39  **/
40  quint32 downSerial() const;
41  /**
42  * The serial when the up event happened.
43  **/
44  quint32 upSerial() const;
45  /**
46  * Most recent timestamp
47  **/
48  quint32 time() const;
49  /**
50  * All timestamps, references the positions.
51  * That is each position has a timestamp.
52  **/
53  QVector<quint32> timestamps() const;
54  /**
55  * Most recent position
56  **/
57  QPointF position() const;
58  /**
59  * All positions this TouchPoint had, updated with each move.
60  **/
61  QVector<QPointF> positions() const;
62  /**
63  * The Surface this TouchPoint happened on.
64  **/
65  QPointer<Surface> surface() const;
66  /**
67  * @c true if currently down, @c false otherwise.
68  **/
69  bool isDown() const;
70 
71 private:
72  friend class Touch;
73  explicit TouchPoint();
74  class Private;
76 };
77 
78 /**
79  * @short Wrapper for the wl_touch interface.
80  *
81  * This class is a convenient wrapper for the wl_touch interface.
82  *
83  * To create an instance use Seat::createTouch.
84  *
85  * @see Seat
86  **/
87 class KWAYLANDCLIENT_EXPORT Touch : public QObject
88 {
89  Q_OBJECT
90 public:
91  explicit Touch(QObject *parent = nullptr);
92  virtual ~Touch();
93 
94  /**
95  * @returns @c true if managing a wl_pointer.
96  **/
97  bool isValid() const;
98  /**
99  * Setup this Touch to manage the @p touch.
100  * When using Seat::createTouch there is no need to call this
101  * method.
102  **/
103  void setup(wl_touch *touch);
104  /**
105  * Releases the wl_touch interface.
106  * After the interface has been released the Touch instance is no
107  * longer valid and can be setup with another wl_touch interface.
108  *
109  * This method is automatically invoked when the Seat which created this
110  * Touch gets released.
111  **/
112  void release();
113  /**
114  * Destroys the data held by this Touch.
115  * This method is supposed to be used when the connection to the Wayland
116  * server goes away. If the connection is not valid anymore, it's not
117  * possible to call release anymore as that calls into the Wayland
118  * connection and the call would fail. This method cleans up the data, so
119  * that the instance can be deleted or set up to a new wl_touch interface
120  * once there is a new connection available.
121  *
122  * This method is automatically invoked when the Seat which created this
123  * Touch gets destroyed.
124  *
125  * @see release
126  **/
127  void destroy();
128 
129  /**
130  * The TouchPoints of the latest touch event sequence.
131  * Only valid till the next touch event sequence is started
132  **/
133  QVector<TouchPoint *> sequence() const;
134 
135  operator wl_touch *();
136  operator wl_touch *() const;
137 
138 Q_SIGNALS:
139  /**
140  * A new touch sequence is started. The previous sequence is discarded.
141  * @param startPoint The first point which started the sequence
142  **/
143  void sequenceStarted(KWayland::Client::TouchPoint *startPoint);
144  /**
145  * Sent if the compositor decides the touch stream is a global
146  * gesture.
147  **/
148  void sequenceCanceled();
149  /**
150  * Emitted once all touch points are no longer down.
151  **/
152  void sequenceEnded();
153  /**
154  * Indicates the end of a contact point list.
155  **/
156  void frameEnded();
157  /**
158  * TouchPoint @p point got added to the sequence.
159  **/
160  void pointAdded(KWayland::Client::TouchPoint *point);
161  /**
162  * TouchPoint @p point is no longer down.
163  * A new TouchPoint might reuse the Id of the @p point.
164  **/
165  void pointRemoved(KWayland::Client::TouchPoint *point);
166  /**
167  * TouchPoint @p point moved.
168  **/
169  void pointMoved(KWayland::Client::TouchPoint *point);
170 
171 private:
172  class Private;
174 };
175 
176 }
177 }
178 
179 Q_DECLARE_METATYPE(KWayland::Client::TouchPoint *)
180 
181 #endif
Wrapper for the wl_touch interface.
Definition: touch.h:87
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Sep 23 2021 22:51:10 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.