KWaylandServer

tablet_v2_interface.h
1 /*
2  SPDX-FileCopyrightText: 2019 Aleix Pol Gonzalez <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 #pragma once
7 
8 #include <KWaylandServer/kwaylandserver_export.h>
9 
10 #include <QObject>
11 #include <QVector>
12 
13 namespace KWaylandServer
14 {
15 class ClientConnection;
16 class Display;
17 class SeatInterface;
18 class SurfaceInterface;
19 class TabletCursorV2;
20 class TabletCursorV2Private;
21 class TabletManagerV2InterfacePrivate;
22 class TabletSeatV2Interface;
23 class TabletSeatV2InterfacePrivate;
24 class TabletToolV2InterfacePrivate;
25 class TabletV2Interface;
26 class TabletV2InterfacePrivate;
27 class TabletPadV2Interface;
28 class TabletPadV2InterfacePrivate;
29 class TabletPadRingV2Interface;
30 class TabletPadRingV2InterfacePrivate;
31 class TabletPadStripV2Interface;
32 class TabletPadStripV2InterfacePrivate;
33 class TabletPadGroupV2Interface;
34 class TabletPadGroupV2InterfacePrivate;
35 
36 /**
37  * This is an implementation of wayland-protocols/unstable/tablet/tablet-unstable-v2.xml
38  *
39  * This class is just the means to get a @class TabletSeatInterface, which is
40  * the class that will have all of the information we need.
41  */
42 
43 class KWAYLANDSERVER_EXPORT TabletManagerV2Interface : public QObject
44 {
45  Q_OBJECT
46 public:
47  explicit TabletManagerV2Interface(Display *d, QObject *parent);
48  virtual ~TabletManagerV2Interface();
49 
50  TabletSeatV2Interface *seat(SeatInterface *seat) const;
51 
52 private:
54 };
55 
56 class KWAYLANDSERVER_EXPORT TabletToolV2Interface : public QObject
57 {
58  Q_OBJECT
59 public:
60  virtual ~TabletToolV2Interface();
61 
62  enum Type {
63  Pen = 0x140, ///< Pen
64  Eraser = 0x141, ///< Eraser
65  Brush = 0x142, ///< Brush
66  Pencil = 0x143, ///< Pencil
67  Airbrush = 0x144, ///< Airbrush
68  Finger = 0x145, ///< Finger
69  Mouse = 0x146, ///< Mouse
70  Lens = 0x147, ///< Lens
71  Totem
72  };
73  Q_ENUM(Type)
74 
75  enum Capability {
76  Tilt = 1, ///< Tilt axeis
77  Pressure = 2, ///< Pressure axis
78  Distance = 3, ///< Distance axis
79  Rotation = 4, ///< Z-rotation axis
80  Slider = 5, ///< Slider axis
81  Wheel = 6, ///< Wheel axis
82  };
83  Q_ENUM(Capability)
84 
85  /**
86  * Sets the surface the events will be sent to.
87  *
88  * Make sure the surface supports being sent events to.
89  *
90  * @see TabletV2Interface::isSurfaceSupported
91  */
92  void setCurrentSurface(SurfaceInterface *surface);
93  bool isClientSupported() const;
94 
95  void sendProximityIn(TabletV2Interface *tablet);
96  void sendProximityOut();
97  void sendUp();
98  void sendDown();
99  void sendPressure(quint32 pressure);
100  void sendDistance(quint32 distance);
101  void sendTilt(qreal degreesX, qreal degreesY);
102  void sendRotation(qreal degrees);
103  void sendSlider(qint32 position);
104  void sendWheel(qint32 degrees, qint32 clicks);
105  void sendButton(quint32 button, bool pressed);
106  void sendFrame(quint32 time);
107  void sendMotion(const QPointF &pos);
108 
109 Q_SIGNALS:
110  void cursorChanged(TabletCursorV2 *cursor) const;
111 
112 private:
113  friend class TabletSeatV2InterfacePrivate;
114  friend class TabletSeatV2Interface;
115  explicit TabletToolV2Interface(Display *display,
116  Type type,
117  quint32 hsh,
118  quint32 hsl,
119  quint32 hih,
120  quint32 hil,
121  const QVector<Capability> &capability,
122  QObject *parent);
123  QScopedPointer<TabletToolV2InterfacePrivate> d;
124 };
125 
126 class KWAYLANDSERVER_EXPORT TabletCursorV2 : public QObject
127 {
128  Q_OBJECT
129 public:
130  ~TabletCursorV2() override;
131  QPoint hotspot() const;
132  quint32 enteredSerial() const;
133  SurfaceInterface *surface() const;
134 
135 Q_SIGNALS:
136  void changed();
137 
138 private:
139  TabletCursorV2();
141  friend class TabletToolV2InterfacePrivate;
142 };
143 
144 class KWAYLANDSERVER_EXPORT TabletPadV2Interface : public QObject
145 {
146  Q_OBJECT
147 public:
148  virtual ~TabletPadV2Interface();
149 
150  TabletPadRingV2Interface *ring(uint at) const;
151  TabletPadStripV2Interface *strip(uint at) const;
152  void sendButton(quint32 time, quint32 button, bool pressed);
153 
154  void setCurrentSurface(SurfaceInterface *surface, TabletV2Interface *tablet);
155  SurfaceInterface *currentSurface() const;
156 
157 Q_SIGNALS:
158  void feedback(KWaylandServer::ClientConnection *client, quint32 button, const QString &description, quint32 serial);
159 
160 private:
161  friend class TabletSeatV2Interface;
162  friend class TabletSeatV2InterfacePrivate;
163  explicit TabletPadV2Interface(const QString &path,
164  quint32 buttons,
165  quint32 rings,
166  quint32 strips,
167  quint32 modes,
168  quint32 currentMode,
169  Display *display,
170  TabletSeatV2Interface *parent);
172 };
173 
174 class KWAYLANDSERVER_EXPORT TabletPadRingV2Interface : public QObject
175 {
176  Q_OBJECT
177 public:
178  virtual ~TabletPadRingV2Interface();
179 
180  enum Source {
181  SourceFinger = 1, // finger
182  };
183  Q_ENUM(Source)
184 
185  void sendSource(Source source);
186  void sendAngle(qreal angle);
187  void sendStop();
188  void sendFrame(quint32 time);
189 
190 private:
191  friend class TabletPadGroupV2Interface;
192  friend class TabletPadV2InterfacePrivate;
193  friend class TabletSeatV2InterfacePrivate;
194  explicit TabletPadRingV2Interface(TabletPadV2Interface *parent);
195  QScopedPointer<TabletPadRingV2InterfacePrivate> d;
196 };
197 
198 class KWAYLANDSERVER_EXPORT TabletPadStripV2Interface : public QObject
199 {
200  Q_OBJECT
201 public:
202  virtual ~TabletPadStripV2Interface();
203 
204  enum Source {
205  SourceFinger = 1, // finger
206  };
207 
208  void sendSource(Source source);
209  void sendPosition(quint32 position);
210  void sendFrame(quint32 time);
211  void sendStop();
212 
213 private:
214  friend class TabletPadGroupV2Interface;
215  friend class TabletPadV2InterfacePrivate;
216  friend class TabletSeatV2InterfacePrivate;
217  explicit TabletPadStripV2Interface(TabletPadV2Interface *parent);
219 };
220 
221 class KWAYLANDSERVER_EXPORT TabletPadGroupV2Interface : public QObject
222 {
223  Q_OBJECT
224 public:
225  virtual ~TabletPadGroupV2Interface();
226 
227  void sendModeSwitch(quint32 time, quint32 serial, quint32 mode);
228 
229 private:
230  friend class TabletPadV2Interface;
231  friend class TabletPadV2InterfacePrivate;
232  friend class TabletSeatV2InterfacePrivate;
233  explicit TabletPadGroupV2Interface(quint32 currentMode, TabletPadV2Interface *parent);
235 };
236 
237 class KWAYLANDSERVER_EXPORT TabletV2Interface : public QObject
238 {
239  Q_OBJECT
240 public:
241  virtual ~TabletV2Interface();
242 
243  /**
244  * @returns true if the surface has been bound to the tablet.
245  */
246  bool isSurfaceSupported(SurfaceInterface *surface) const;
247 
248  TabletPadV2Interface *pad() const;
249 
250 private:
251  friend class TabletSeatV2Interface;
252  friend class TabletSeatV2InterfacePrivate;
253  friend class TabletPadV2Interface;
254  friend class TabletToolV2Interface;
255  explicit TabletV2Interface(quint32 vendorId, quint32 productId, const QString &name, const QStringList &paths, QObject *parent);
257 };
258 
259 class KWAYLANDSERVER_EXPORT TabletSeatV2Interface : public QObject
260 {
261  Q_OBJECT
262 public:
263  virtual ~TabletSeatV2Interface();
264 
265  TabletV2Interface *addTablet(quint32 vendorId, quint32 productId, const QString &sysname, const QString &name, const QStringList &paths);
266  TabletPadV2Interface *addTabletPad(const QString &sysname,
267  const QString &name,
268  const QStringList &paths,
269  quint32 buttons,
270  quint32 rings,
271  quint32 strips,
272  quint32 modes,
273  quint32 currentMode,
274  TabletV2Interface *tablet);
275  TabletToolV2Interface *
276  addTool(TabletToolV2Interface::Type type, quint64 hardwareSerial, quint64 hardwareId, const QVector<TabletToolV2Interface::Capability> &capabilities);
277 
278  TabletToolV2Interface *toolByHardwareId(quint64 hardwareId) const;
279  TabletToolV2Interface *toolByHardwareSerial(quint64 hardwareSerial, TabletToolV2Interface::Type type) const;
280  TabletPadV2Interface *padByName(const QString &sysname) const;
281 
282  void removeDevice(const QString &sysname);
283 
284  bool isClientSupported(ClientConnection *client) const;
285 
286 private:
287  friend class TabletManagerV2InterfacePrivate;
288  explicit TabletSeatV2Interface(Display *display, QObject *parent);
290 };
291 
292 }
293 
294 Q_DECLARE_METATYPE(KWaylandServer::TabletSeatV2Interface *)
Convenient Class which represents a wl_client.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 23 2021 23:08:28 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.