Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qwaylandtabletv2_p.h
Go to the documentation of this file.
1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QWAYLANDTABLETV2_P_H
5#define QWAYLANDTABLETV2_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtWaylandClient/private/qwayland-tablet-unstable-v2.h>
19
20#include <QtWaylandClient/private/qtwaylandclientglobal_p.h>
21
22#include <QtCore/QObject>
23#include <QtCore/QPointer>
24#include <QtCore/QPointF>
25#include <QtGui/QPointingDevice>
26#include <QtGui/QInputDevice>
27
29
30namespace QtWaylandClient {
31
32class QWaylandDisplay;
33class QWaylandInputDevice;
34class QWaylandSurface;
35
36class QWaylandTabletSeatV2;
37class QWaylandTabletV2;
38class QWaylandTabletToolV2;
39class QWaylandTabletPadV2;
40
41class Q_WAYLANDCLIENT_EXPORT QWaylandTabletManagerV2 : public QtWayland::zwp_tablet_manager_v2
42{
43public:
45 QWaylandTabletSeatV2 *createTabletSeat(QWaylandInputDevice *seat);
46};
47
48class Q_WAYLANDCLIENT_EXPORT QWaylandTabletSeatV2 : public QObject, public QtWayland::zwp_tablet_seat_v2
49{
51public:
53 ~QWaylandTabletSeatV2() override;
54
55 QWaylandInputDevice *seat() const { return m_seat; }
56
57protected:
58 void zwp_tablet_seat_v2_tablet_added(struct ::zwp_tablet_v2 *id) override;
59 void zwp_tablet_seat_v2_tool_added(struct ::zwp_tablet_tool_v2 *id) override;
60 void zwp_tablet_seat_v2_pad_added(struct ::zwp_tablet_pad_v2 *id) override;
61
62private:
63 QWaylandInputDevice *m_seat;
67};
68
69class Q_WAYLANDCLIENT_EXPORT QWaylandTabletV2 : public QPointingDevice, public QtWayland::zwp_tablet_v2
70{
72public:
73 explicit QWaylandTabletV2(::zwp_tablet_v2 *tablet, const QString &seatName);
74
75protected:
76 // callbacks which act as setters
77 void zwp_tablet_v2_name(const QString &name) override;
78 void zwp_tablet_v2_id(uint32_t vid, uint32_t pid) override;
79 void zwp_tablet_v2_path(const QString &path) override;
80 void zwp_tablet_v2_done() override;
81 void zwp_tablet_v2_removed() override;
82};
83
84class Q_WAYLANDCLIENT_EXPORT QWaylandTabletToolV2 : public QPointingDevice, public QtWayland::zwp_tablet_tool_v2
85{
87public:
88 QWaylandTabletToolV2(QWaylandTabletSeatV2 *tabletSeat, ::zwp_tablet_tool_v2 *tool);
89
90protected:
91 void zwp_tablet_tool_v2_type(uint32_t tool_type) override;
92 void zwp_tablet_tool_v2_hardware_serial(uint32_t hardware_serial_hi, uint32_t hardware_serial_lo) override;
93 void zwp_tablet_tool_v2_hardware_id_wacom(uint32_t hardware_id_hi, uint32_t hardware_id_lo) override;
94 void zwp_tablet_tool_v2_capability(uint32_t capability) override;
95 void zwp_tablet_tool_v2_done() override;
96 void zwp_tablet_tool_v2_removed() override;
97 void zwp_tablet_tool_v2_proximity_in(uint32_t serial, struct ::zwp_tablet_v2 *tablet, struct ::wl_surface *surface) override;
98 void zwp_tablet_tool_v2_proximity_out() override;
99 void zwp_tablet_tool_v2_down(uint32_t serial) override;
100 void zwp_tablet_tool_v2_up() override;
101 void zwp_tablet_tool_v2_motion(wl_fixed_t x, wl_fixed_t y) override;
102 void zwp_tablet_tool_v2_pressure(uint32_t pressure) override;
103 void zwp_tablet_tool_v2_distance(uint32_t distance) override;
104 void zwp_tablet_tool_v2_tilt(wl_fixed_t tilt_x, wl_fixed_t tilt_y) override;
105 void zwp_tablet_tool_v2_rotation(wl_fixed_t degrees) override;
106 void zwp_tablet_tool_v2_slider(int32_t position) override;
107// void zwp_tablet_tool_v2_wheel(wl_fixed_t degrees, int32_t clicks) override;
108 void zwp_tablet_tool_v2_button(uint32_t serial, uint32_t button, uint32_t state) override;
109 void zwp_tablet_tool_v2_frame(uint32_t time) override;
110
111private:
112 QWaylandTabletSeatV2 *m_tabletSeat;
113
114 // Accumulated state (applied on frame event)
115 struct State {
116 bool down = false;
117 QPointer<QWaylandSurface> proximitySurface;
118 bool enteredSurface = false; // Not enough with just proximitySurface, if the surface is deleted, we still want to send a leave event
119 QPointF surfacePosition;
120 uint distance = 0;
121 qreal pressure = 0;
122 qreal rotation = 0;
123 qreal xTilt = 0;
124 qreal yTilt = 0;
125 qreal slider = 0;
126 Qt::MouseButtons buttons = Qt::MouseButton::NoButton; // Actual buttons, down state -> left mouse is mapped inside the frame handler
127 //auto operator<=>(const Point&) const = default; // TODO: use this when upgrading to C++20
128 bool operator==(const State &o) const;
129 } m_pending, m_applied;
130};
131
132class Q_WAYLANDCLIENT_EXPORT QWaylandTabletPadV2 : public QPointingDevice, public QtWayland::zwp_tablet_pad_v2
133{
135public:
136 explicit QWaylandTabletPadV2(::zwp_tablet_pad_v2 *pad);
137
138protected:
139// void zwp_tablet_pad_v2_group(struct ::zwp_tablet_pad_group_v2 *pad_group) override;
140 void zwp_tablet_pad_v2_path(const QString &path) override;
141 void zwp_tablet_pad_v2_buttons(uint32_t buttons) override;
142 void zwp_tablet_pad_v2_done() override;
143// void zwp_tablet_pad_v2_button(uint32_t time, uint32_t button, uint32_t state) override;
144// void zwp_tablet_pad_v2_enter(uint32_t serial, struct ::zwp_tablet_v2 *tablet, struct ::wl_surface *surface) override;
145// void zwp_tablet_pad_v2_leave(uint32_t serial, struct ::wl_surface *surface) override;
146 void zwp_tablet_pad_v2_removed() override;
147};
148
149} // namespace QtWaylandClient
150
152
153#endif // QWAYLANDTABLETV2_P_H
Definition qlist.h:74
\inmodule QtCore
Definition qobject.h:90
\inmodule QtCore\reentrant
Definition qpoint.h:214
\inmodule QtCore
Definition qpointer.h:18
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\qmltype WaylandSurface \instantiates QWaylandSurface \inqmlmodule QtWayland.Compositor
QWaylandInputDevice * seat() const
QPushButton * button
[2]
else opt state
[0]
struct wl_display * display
Definition linuxdmabuf.h:41
Combined button and popup list for selecting options.
@ NoButton
Definition qnamespace.h:56
GLint GLint GLint GLint GLint x
[0]
GLsizei GLsizei GLfloat distance
GLuint name
GLint y
GLsizei const GLchar *const * path
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1219
#define Q_OBJECT
unsigned int uint
Definition qtypes.h:29
double qreal
Definition qtypes.h:92
QNetworkAccessManager manager