tablet_v2_interface.h 5.65 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/********************************************************************
Copyright 2019 Aleix Pol Gonzalez <aleixpol@kde.org>

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef WAYLAND_SERVER_TABLET_INTERFACE_H
#define WAYLAND_SERVER_TABLET_INTERFACE_H

23
#include <KWaylandServer/kwaylandserver_export.h>
24

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
25
26
#include <QObject>
#include <QVector>
27

28
namespace KWaylandServer
29
{
30
class TabletSeatV2Interface;
31
32
33
class Display;
class SeatInterface;
class SurfaceInterface;
34
35
class TabletV2Interface;
class TabletCursorV2;
36
37
38
39
40
41
42
43
44
45

/**
 * This is an implementation of wayland-protocols/unstable/tablet/tablet-unstable-v2.xml
 *
 * This class is just the means to get a @class TabletSeatInterface, which is
 * the class that will have all of the information we need.
 *
 * @since 5.69
 */

46
class KWAYLANDSERVER_EXPORT TabletManagerV2Interface : public QObject
47
48
49
{
    Q_OBJECT
public:
50
    virtual ~TabletManagerV2Interface();
51

52
    TabletSeatV2Interface *seat(SeatInterface *seat) const;
53
54
55

private:
    friend class Display;
56
    explicit TabletManagerV2Interface(Display *d, QObject *parent);
57
58
59
60
    class Private;
    QScopedPointer<Private> d;
};

61
class KWAYLANDSERVER_EXPORT TabletToolV2Interface : public QObject
62
63
64
{
    Q_OBJECT
public:
65
    virtual ~TabletToolV2Interface();
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94

    enum Type {
        Pen = 0x140, ///< Pen
        Eraser = 0x141, ///< Eraser
        Brush = 0x142, ///< Brush
        Pencil = 0x143, ///< Pencil
        Airbrush = 0x144, ///< Airbrush
        Finger = 0x145, ///< Finger
        Mouse = 0x146, ///< Mouse
        Lens = 0x147, ///< Lens
        Totem
    };
    Q_ENUM(Type)

    enum Capability {
        Tilt = 1, ///< Tilt axeis
        Pressure = 2, ///< Pressure axis
        Distance = 3, ///< Distance axis
        Rotation = 4, ///< Z-rotation axis
        Slider = 5, ///< Slider axis
        Wheel = 6 ///< Wheel axis
    };
    Q_ENUM(Capability)

    /**
     * Sets the surface the events will be sent to.
     *
     * Make sure the surface supports being sent events to.
     *
95
     * @see TabletV2Interface::isSurfaceSupported
96
97
98
99
100
     */
    void setCurrentSurface(SurfaceInterface *surface);
    bool isClientSupported() const;

    void sendRemoved();
101
    void sendProximityIn(TabletV2Interface *tablet);
102
103
104
105
106
107
108
109
110
111
112
113
114
115
    void sendProximityOut();
    void sendUp();
    void sendDown();
    void sendPressure(quint32 pressure);
    void sendDistance(quint32 distance);
    void sendTilt(qreal degreesX, qreal degreesY);
    void sendRotation(qreal degrees);
    void sendSlider(qint32 position);
    void sendWheel(qint32 degrees, qint32 clicks);
    void sendButton(quint32 button, bool pressed);
    void sendFrame(quint32 time);
    void sendMotion(const QPointF &pos);

Q_SIGNALS:
116
    void cursorChanged(TabletCursorV2 *cursor) const;
117
118

private:
119
120
    friend class TabletSeatV2Interface;
    explicit TabletToolV2Interface(Display *display, Type type, quint32 hsh, quint32 hsl, quint32 hih, quint32 hil, const QVector<Capability> &capability, QObject *parent);
121
122
123
124
    class Private;
    QScopedPointer<Private> d;
};

125
class KWAYLANDSERVER_EXPORT TabletCursorV2 : public QObject
126
127
128
{
    Q_OBJECT
public:
129
    ~TabletCursorV2() override;
130
131
132
133
134
135
136
137
    QPoint hotspot() const;
    quint32 enteredSerial() const;
    SurfaceInterface* surface() const;

Q_SIGNALS:
    void changed();

private:
138
139
    friend class TabletToolV2Interface;
    TabletCursorV2();
140
141
142
143
    class Private;
    const QScopedPointer<Private> d;
};

144
class KWAYLANDSERVER_EXPORT TabletV2Interface : public QObject
145
146
147
{
    Q_OBJECT
public:
148
    virtual ~TabletV2Interface();
149
150
151
152
153
154
155
156
157

    /**
     * @returns true if the surface has been bound to the tablet.
     */
    bool isSurfaceSupported(SurfaceInterface *surface) const;

    void sendRemoved();

private:
158
159
160
    friend class TabletSeatV2Interface;
    friend class TabletToolV2Interface;
    explicit TabletV2Interface(quint32 vendorId, quint32 productId, const QString &name, const QStringList &paths, QObject *parent);
161
162
163
164
    class Private;
    QScopedPointer<Private> d;
};

165
class KWAYLANDSERVER_EXPORT TabletSeatV2Interface : public QObject
166
167
168
{
    Q_OBJECT
public:
169
    virtual ~TabletSeatV2Interface();
170

171
172
    TabletV2Interface *addTablet(quint32 vendorId, quint32 productId, const QString &sysname, const QString &name, const QStringList &paths);
    TabletToolV2Interface *addTool(TabletToolV2Interface::Type type, quint64 hardwareSerial, quint64 hardwareId, const QVector<TabletToolV2Interface::Capability> &capabilities);
173

174
175
176
    TabletToolV2Interface *toolByHardwareId(quint64 hardwareId) const;
    TabletToolV2Interface *toolByHardwareSerial(quint64 hardwareSerial) const;
    TabletV2Interface *tabletByName(const QString &sysname) const;
177
178
179
180

    void removeTablet(const QString &sysname);

private:
181
182
    friend class TabletManagerV2Interface;
    explicit TabletSeatV2Interface(Display *display, QObject *parent);
183
184
185
186
187
188
    class Private;
    QScopedPointer<Private> d;
};

}

189
Q_DECLARE_METATYPE(KWaylandServer::TabletSeatV2Interface *)
190
191

#endif