8#include <QtGui/private/qpointingdevice_p.h>
20 : zwp_tablet_manager_v2(
display->wl_registry(),
id,
qMin(version,
uint(1)))
24 const auto seats =
display->inputDevices();
25 for (
auto *seat : seats)
26 createTabletSeat(seat);
42 for (
auto *tablet : m_tablets)
44 for (
auto *tool : m_tools)
46 for (
auto *pad : m_pads)
57 qCDebug(lcQpaInputDevices) <<
"seat" <<
this <<
id <<
"has tablet" << tablet;
58 tablet->setParent(
this);
59 m_tablets.push_back(tablet);
66 if (m_tablets.size() == 1) {
67 tool->setParent(m_tablets.first());
69 d->name = m_tablets.first()->name() + u
" stylus";
71 qCDebug(lcQpaInputDevices) <<
"seat" <<
this <<
"has tool" << tool <<
"for one of these tablets:" << m_tablets;
74 m_tools.push_back(tool);
81 if (m_tablets.size() == 1) {
82 pad->setParent(m_tablets.first());
84 d->name = m_tablets.first()->name() + u
" touchpad";
86 qCDebug(lcQpaInputDevices) <<
"seat" <<
this <<
"has touchpad" << pad <<
"for one of these tablets:" << m_tablets;
89 m_pads.push_back(pad);
112 d->systemId = (
quint64(vid) << 32) | pid;
113 qCDebug(lcQpaInputDevices) <<
"vid" << vid <<
"pid" << pid <<
"stored as systemId in" <<
this;
138 , m_tabletSeat(tabletSeat)
167 case type::type_airbrush:
171 case type::type_brush:
172 case type::type_pencil:
174 case type::type_eraser:
177 case type::type_lens:
180 case type::type_mouse:
181 case type::type_finger:
196 d->systemId = (
quint64(hardware_id_hi) << 32) + hardware_id_lo;
202 switch (capability) {
203 case capability_tilt:
208 case capability_pressure:
211 case capability_distance:
214 case capability_rotation:
217 case capability_slider:
220 case capability_wheel:
225 qCDebug(lcQpaInputDevices) << capability <<
"->" <<
this;
244 qCDebug(lcQpaWayland) <<
"Ignoring zwp_tablet_tool_v2_proximity_v2 with no surface";
247 m_pending.enteredSurface =
true;
253 m_pending.enteredSurface =
false;
254 m_pending.proximitySurface =
nullptr;
259 m_pending.down =
true;
261 if (m_pending.proximitySurface) {
271 m_pending.down =
false;
276 m_pending.surfacePosition =
QPointF(wl_fixed_to_double(
x), wl_fixed_to_double(
y));
281 const int maxPressure = 65535;
282 m_pending.pressure =
qreal(pressure)/maxPressure;
292 m_pending.xTilt = wl_fixed_to_double(tilt_x);
293 m_pending.yTilt = wl_fixed_to_double(tilt_y);
298 m_pending.rotation = wl_fixed_to_double(degrees);
322 if (
state == button_state_pressed)
323 m_pending.buttons |= mouseButton;
325 m_pending.buttons &= ~mouseButton;
329 d->buttonCount =
qMax(
d->buttonCount, 2);
331 d->buttonCount =
qMax(
d->buttonCount, 3);
343 qreal tangentialPressure = 0;
348 if (m_pending.proximitySurface) {
354 globalPosition =
window->mapToGlobal(localPosition.
toPoint());
355 globalPosition += delta;
358 buttons |= m_pending.buttons;
359 pressure = m_pending.pressure;
360 xTilt = int(m_pending.xTilt);
361 yTilt = int(m_pending.yTilt);
362 tangentialPressure = m_pending.slider;
363 rotation = m_pending.rotation;
364 z = int(m_pending.distance);
365 if (m_applied.proximitySurface) {
368 xTilt, yTilt, tangentialPressure, rotation,
z);
371 localPosition, globalPosition, buttons,
372 xTilt, yTilt, tangentialPressure, rotation,
z);
374 }
else if (m_applied.enteredSurface) {
375 Q_ASSERT(m_applied.proximitySurface);
381 globalPosition =
window->mapToGlobal(localPosition.
toPoint());
382 globalPosition += delta;
385 buttons |= m_applied.buttons;
386 pressure = m_applied.pressure;
387 xTilt = int(m_applied.xTilt);
388 yTilt = int(m_applied.yTilt);
389 tangentialPressure = m_applied.slider;
390 rotation = m_applied.rotation;
391 z = int(m_applied.distance);
393 localPosition, globalPosition, buttons,
394 xTilt, yTilt, tangentialPressure, rotation,
z);
397 if (!m_pending.proximitySurface && m_applied.enteredSurface) {
401 m_applied = m_pending;
405bool QWaylandTabletToolV2::State::operator==(
const QWaylandTabletToolV2::State &
o)
const {
408 proximitySurface.data() ==
o.proximitySurface.data() &&
409 enteredSurface ==
o.enteredSurface &&
410 surfacePosition ==
o.surfacePosition &&
412 pressure ==
o.pressure &&
413 rotation ==
o.rotation &&
416 slider ==
o.slider &&
417 buttons ==
o.buttons;
437 d->buttonCount = buttons;
455#include "moc_qwaylandtabletv2_p.cpp"
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
\inmodule QtCore\reentrant
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
static QPointingDevicePrivate * get(QPointingDevice *q)
static QPointingDeviceUniqueId fromNumericId(qint64 id)
Constructs a unique pointer ID from numeric ID id.
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
PointerType
This enum represents what is interacting with the pointing device.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static bool handleTabletEvent(QWindow *window, ulong timestamp, const QPointingDevice *device, const QPointF &local, const QPointF &global, Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt, qreal tangentialPressure, qreal rotation, int z, Qt::KeyboardModifiers modifiers=Qt::NoModifier)
static void registerInputDevice(const QInputDevice *device)
static bool handleTabletEnterLeaveProximityEvent(QWindow *window, ulong timestamp, const QPointingDevice *device, bool inProximity, const QPointF &local=QPointF(), const QPointF &global=QPointF(), Qt::MouseButtons buttons={}, int xTilt=0, int yTilt=0, qreal tangentialPressure=0, qreal rotation=0, int z=0, Qt::KeyboardModifiers modifiers=Qt::NoModifier)
void setLastInputDevice(QWaylandInputDevice *device, uint32_t serial, QWaylandWindow *window)
static QWaylandSurface * fromWlSurface(::wl_surface *surface)
QWaylandTabletSeatV2 * createTabletSeat(QWaylandInputDevice *seat)
void zwp_tablet_pad_v2_removed() override
void zwp_tablet_pad_v2_done() override
void zwp_tablet_pad_v2_buttons(uint32_t buttons) override
void zwp_tablet_pad_v2_path(const QString &path) override
QWaylandTabletPadV2(::zwp_tablet_pad_v2 *pad)
QWaylandInputDevice * seat() const
~QWaylandTabletSeatV2() override
void zwp_tablet_seat_v2_pad_added(struct ::zwp_tablet_pad_v2 *id) override
QWaylandTabletSeatV2(QWaylandTabletManagerV2 *manager, QWaylandInputDevice *seat)
void zwp_tablet_seat_v2_tool_added(struct ::zwp_tablet_tool_v2 *id) override
void zwp_tablet_seat_v2_tablet_added(struct ::zwp_tablet_v2 *id) override
void zwp_tablet_v2_removed() override
void zwp_tablet_v2_path(const QString &path) override
QWaylandTabletV2(::zwp_tablet_v2 *tablet, const QString &seatName)
void zwp_tablet_v2_done() override
void zwp_tablet_v2_id(uint32_t vid, uint32_t pid) override
void zwp_tablet_v2_name(const QString &name) override
QPointF mapFromWlSurface(const QPointF &surfacePosition) const
Converts from wl_surface coordinates to Qt window coordinates.
static QWaylandWindow * fromWlSurface(::wl_surface *surface)
qDeleteAll(list.begin(), list.end())
struct wl_display * display
Combined button and popup list for selecting options.
static Qt::MouseButton mouseButtonFromTablet(uint button)
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLint GLint GLint GLint GLint x
[0]
GLsizei GLsizei GLfloat distance
GLsizei const GLchar *const * path
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
unsigned long long quint64
QNetworkAccessManager manager