KWin
Loading...
Searching...
No Matches
tablet_v2.h
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2019 Aleix Pol Gonzalez <aleixpol@kde.org>
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 "kwin_export.h"
9
10#include <QList>
11#include <QObject>
12#include <memory>
13
14struct wl_resource;
15
16namespace KWin
17{
18class ClientConnection;
19class Display;
20class SeatInterface;
21class SurfaceInterface;
22class TabletSurfaceCursorV2;
23class TabletSurfaceCursorV2Private;
24class TabletManagerV2InterfacePrivate;
25class TabletSeatV2Interface;
26class TabletSeatV2InterfacePrivate;
27class TabletToolV2InterfacePrivate;
28class TabletV2Interface;
29class TabletV2InterfacePrivate;
30class TabletPadV2Interface;
31class TabletPadV2InterfacePrivate;
32class TabletPadRingV2Interface;
33class TabletPadRingV2InterfacePrivate;
34class TabletPadStripV2Interface;
35class TabletPadStripV2InterfacePrivate;
36class TabletPadGroupV2Interface;
37class TabletPadGroupV2InterfacePrivate;
38
46class KWIN_EXPORT TabletManagerV2Interface : public QObject
47{
48 Q_OBJECT
49public:
50 explicit TabletManagerV2Interface(Display *d, QObject *parent);
52
53 TabletSeatV2Interface *seat(SeatInterface *seat) const;
54
55private:
56 std::unique_ptr<TabletManagerV2InterfacePrivate> d;
57};
58
59class KWIN_EXPORT TabletSurfaceCursorV2 : public QObject
60{
61 Q_OBJECT
62public:
64 QPoint hotspot() const;
65 quint32 enteredSerial() const;
66 SurfaceInterface *surface() const;
67
68Q_SIGNALS:
69 void changed();
70
71private:
73 const std::unique_ptr<TabletSurfaceCursorV2Private> d;
75};
76
77using TabletCursorSourceV2 = std::variant<TabletSurfaceCursorV2 *, QByteArray>;
78
79class KWIN_EXPORT TabletToolV2Interface : public QObject
80{
81 Q_OBJECT
82public:
83 virtual ~TabletToolV2Interface();
84
85 enum Type {
86 Pen = 0x140,
87 Eraser = 0x141,
88 Brush = 0x142,
89 Pencil = 0x143,
90 Airbrush = 0x144,
91 Finger = 0x145,
92 Mouse = 0x146,
93 Lens = 0x147,
94 Totem
95 };
96 Q_ENUM(Type)
97
99 Tilt = 1,
100 Pressure = 2,
101 Distance = 3,
102 Rotation = 4,
103 Slider = 5,
104 Wheel = 6,
105 };
106 Q_ENUM(Capability)
107
108 bool hasCapability(Capability capability) const;
109
117 void setCurrentSurface(SurfaceInterface *surface);
118 SurfaceInterface *currentSurface() const;
119
120 bool isClientSupported() const;
121
122 quint32 proximitySerial() const;
123 std::optional<quint32> downSerial() const;
124
125 void sendProximityIn(TabletV2Interface *tablet);
126 void sendProximityOut();
127 void sendUp();
128 void sendDown();
129 void sendPressure(quint32 pressure);
130 void sendDistance(quint32 distance);
131 void sendTilt(qreal degreesX, qreal degreesY);
132 void sendRotation(qreal degrees);
133 void sendSlider(qint32 position);
134 void sendWheel(qint32 degrees, qint32 clicks);
135 void sendButton(quint32 button, bool pressed);
136 void sendFrame(quint32 time);
137 void sendMotion(const QPointF &pos);
138
139 static TabletToolV2Interface *get(wl_resource *resource);
140
141Q_SIGNALS:
143
144private:
147 explicit TabletToolV2Interface(Display *display,
148 Type type,
149 quint32 hsh,
150 quint32 hsl,
151 quint32 hih,
152 quint32 hil,
153 const QList<Capability> &capability);
154 std::unique_ptr<TabletToolV2InterfacePrivate> d;
155};
156
157class KWIN_EXPORT TabletPadV2Interface : public QObject
158{
159 Q_OBJECT
160public:
161 virtual ~TabletPadV2Interface();
162
163 TabletPadRingV2Interface *ring(uint at) const;
164 TabletPadStripV2Interface *strip(uint at) const;
165 void sendButton(std::chrono::microseconds time, quint32 button, bool pressed);
166
167 void setCurrentSurface(SurfaceInterface *surface, TabletV2Interface *tablet);
168 SurfaceInterface *currentSurface() const;
169
170Q_SIGNALS:
171 void feedback(KWin::ClientConnection *client, quint32 button, const QString &description, quint32 serial);
172
173private:
176 explicit TabletPadV2Interface(const QString &path,
177 quint32 buttons,
178 quint32 rings,
179 quint32 strips,
180 quint32 modes,
181 quint32 currentMode,
182 Display *display,
183 TabletSeatV2Interface *parent);
184 std::unique_ptr<TabletPadV2InterfacePrivate> d;
185};
186
187class KWIN_EXPORT TabletPadRingV2Interface : public QObject
188{
189 Q_OBJECT
190public:
192
193 enum Source {
194 SourceFinger = 1, // finger
195 };
196 Q_ENUM(Source)
197
198 void sendSource(Source source);
199 void sendAngle(qreal angle);
200 void sendStop();
201 void sendFrame(quint32 time);
202
203private:
208 std::unique_ptr<TabletPadRingV2InterfacePrivate> d;
209};
210
211class KWIN_EXPORT TabletPadStripV2Interface : public QObject
212{
213 Q_OBJECT
214public:
216
217 enum Source {
218 SourceFinger = 1, // finger
219 };
220
221 void sendSource(Source source);
222 void sendPosition(quint32 position);
223 void sendFrame(quint32 time);
224 void sendStop();
225
226private:
231 std::unique_ptr<TabletPadStripV2InterfacePrivate> d;
232};
233
234class KWIN_EXPORT TabletPadGroupV2Interface : public QObject
235{
236 Q_OBJECT
237public:
239
240 void sendModeSwitch(quint32 time, quint32 serial, quint32 mode);
241
242private:
246 explicit TabletPadGroupV2Interface(quint32 currentMode, TabletPadV2Interface *parent);
247 std::unique_ptr<TabletPadGroupV2InterfacePrivate> d;
248};
249
250class KWIN_EXPORT TabletV2Interface : public QObject
251{
252 Q_OBJECT
253public:
254 virtual ~TabletV2Interface();
255
259 bool isSurfaceSupported(SurfaceInterface *surface) const;
260
261 TabletPadV2Interface *pad() const;
262
263private:
268 explicit TabletV2Interface(quint32 vendorId, quint32 productId, const QString &name, const QStringList &paths, QObject *parent);
269 std::unique_ptr<TabletV2InterfacePrivate> d;
270};
271
272class KWIN_EXPORT TabletSeatV2Interface : public QObject
273{
274 Q_OBJECT
275public:
277
278 TabletV2Interface *addTablet(quint32 vendorId, quint32 productId, const QString &sysname, const QString &name, const QStringList &paths);
279 TabletPadV2Interface *addTabletPad(const QString &sysname,
280 const QString &name,
281 const QStringList &paths,
282 quint32 buttons,
283 quint32 rings,
284 quint32 strips,
285 quint32 modes,
286 quint32 currentMode,
287 TabletV2Interface *tablet);
289 addTool(TabletToolV2Interface::Type type, quint64 hardwareSerial, quint64 hardwareId, const QList<TabletToolV2Interface::Capability> &capabilities, const QString &deviceSysName);
290
291 TabletToolV2Interface *toolByHardwareId(quint64 hardwareId) const;
292 TabletToolV2Interface *toolByHardwareSerial(quint64 hardwareSerial, TabletToolV2Interface::Type type) const;
293 TabletPadV2Interface *padByName(const QString &sysname) const;
294
295 void removeDevice(const QString &sysname);
296
297 bool isClientSupported(ClientConnection *client) const;
298
299 bool hasImplicitGrab(quint32 serial) const;
300
301private:
303 explicit TabletSeatV2Interface(Display *display, QObject *parent);
304 std::unique_ptr<TabletSeatV2InterfacePrivate> d;
305};
306
307}
308
Convenient Class which represents a wl_client.
Class holding the Wayland server display loop.
Definition display.h:34
Represents a Seat on the Wayland Display.
Definition seat.h:134
Resource representing a wl_surface.
Definition surface.h:80
void feedback(KWin::ClientConnection *client, quint32 button, const QString &description, quint32 serial)
void cursorChanged(const TabletCursorSourceV2 &cursor)
Q_DECLARE_METATYPE(KWin::SwitchEvent::State)
std::variant< TabletSurfaceCursorV2 *, QByteArray > TabletCursorSourceV2
Definition tablet_v2.h:77
struct _XDisplay Display