2020-11-05 07:27:56 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2019 Aleix Pol Gonzalez <aleixpol@kde.org>
|
2020-02-12 15:20:38 +00:00
|
|
|
|
2020-11-05 07:27:56 +00:00
|
|
|
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
|
|
|
*/
|
2020-02-12 15:20:38 +00:00
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
#include "tablet_v2_interface.h"
|
2020-02-12 15:20:38 +00:00
|
|
|
#include "display.h"
|
|
|
|
#include "seat_interface.h"
|
|
|
|
#include "surface_interface.h"
|
|
|
|
|
|
|
|
#include "qwayland-server-tablet-unstable-v2.h"
|
|
|
|
#include <QHash>
|
|
|
|
|
2020-11-04 18:15:15 +00:00
|
|
|
namespace KWaylandServer
|
|
|
|
{
|
2020-02-12 15:20:38 +00:00
|
|
|
|
|
|
|
static int s_version = 1;
|
|
|
|
|
2020-11-04 18:15:15 +00:00
|
|
|
class TabletV2InterfacePrivate : public QtWaylandServer::zwp_tablet_v2
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-12-16 01:44:17 +00:00
|
|
|
TabletV2InterfacePrivate(TabletV2Interface *q, uint32_t vendorId, uint32_t productId, const QString &name, const QStringList &paths)
|
2020-02-12 15:20:38 +00:00
|
|
|
: zwp_tablet_v2()
|
|
|
|
, q(q)
|
|
|
|
, m_vendorId(vendorId)
|
|
|
|
, m_productId(productId)
|
|
|
|
, m_name(name)
|
|
|
|
, m_paths(paths)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_resource *resourceForSurface(SurfaceInterface *surface) const
|
|
|
|
{
|
|
|
|
ClientConnection *client = surface->client();
|
2020-12-16 01:44:17 +00:00
|
|
|
Resource *r = resourceMap().value(*client);
|
2020-02-12 15:20:38 +00:00
|
|
|
return r ? r->handle : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void zwp_tablet_v2_destroy_resource(QtWaylandServer::zwp_tablet_v2::Resource * resource) override
|
|
|
|
{
|
|
|
|
Q_UNUSED(resource);
|
2020-12-16 01:44:17 +00:00
|
|
|
if (m_removed && resourceMap().isEmpty()) {
|
2020-02-12 15:20:38 +00:00
|
|
|
delete q;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletV2Interface *const q;
|
2020-12-16 01:46:33 +00:00
|
|
|
TabletPadV2Interface *m_pad = nullptr;
|
2020-02-12 15:20:38 +00:00
|
|
|
const uint32_t m_vendorId;
|
|
|
|
const uint32_t m_productId;
|
|
|
|
const QString m_name;
|
|
|
|
const QStringList m_paths;
|
2020-12-16 01:44:17 +00:00
|
|
|
bool m_removed = false;
|
2020-02-12 15:20:38 +00:00
|
|
|
};
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletV2Interface::TabletV2Interface(uint32_t vendorId, uint32_t productId,
|
|
|
|
const QString &name, const QStringList &paths,
|
|
|
|
QObject *parent)
|
2020-02-12 15:20:38 +00:00
|
|
|
: QObject(parent)
|
2020-11-04 18:15:15 +00:00
|
|
|
, d(new TabletV2InterfacePrivate(this, vendorId, productId, name, paths))
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletV2Interface::~TabletV2Interface() = default;
|
2020-02-12 15:20:38 +00:00
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
bool TabletV2Interface::isSurfaceSupported(SurfaceInterface *surface) const
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
return d->resourceForSurface(surface);
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
void TabletV2Interface::sendRemoved()
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
2020-12-16 01:44:17 +00:00
|
|
|
d->m_removed = true;
|
2020-02-12 15:20:38 +00:00
|
|
|
for (QtWaylandServer::zwp_tablet_v2::Resource *resource : d->resourceMap()) {
|
|
|
|
d->send_removed(resource->handle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-16 01:46:33 +00:00
|
|
|
TabletPadV2Interface *TabletV2Interface::pad() const
|
|
|
|
{
|
|
|
|
return d->m_pad;
|
|
|
|
}
|
|
|
|
|
2020-11-04 18:15:15 +00:00
|
|
|
class TabletCursorV2Private
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-11-04 18:15:15 +00:00
|
|
|
TabletCursorV2Private(TabletCursorV2 *q) : q(q) {}
|
2020-02-12 15:20:38 +00:00
|
|
|
|
|
|
|
void update(quint32 serial, SurfaceInterface *surface, const QPoint &hotspot)
|
|
|
|
{
|
2020-12-16 01:44:17 +00:00
|
|
|
const bool diff = m_serial != serial || m_surface != surface || m_hotspot != hotspot;
|
|
|
|
if (diff) {
|
|
|
|
m_serial = serial;
|
|
|
|
m_surface = surface;
|
|
|
|
m_hotspot = hotspot;
|
|
|
|
|
2020-02-12 15:20:38 +00:00
|
|
|
Q_EMIT q->changed();
|
2020-12-16 01:44:17 +00:00
|
|
|
}
|
2020-02-12 15:20:38 +00:00
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletCursorV2 *const q;
|
2020-02-12 15:20:38 +00:00
|
|
|
|
|
|
|
quint32 m_serial = 0;
|
|
|
|
SurfaceInterface* m_surface = nullptr;
|
|
|
|
QPoint m_hotspot;
|
|
|
|
};
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletCursorV2::TabletCursorV2()
|
2020-02-12 15:20:38 +00:00
|
|
|
: QObject()
|
2020-11-04 18:15:15 +00:00
|
|
|
, d(new TabletCursorV2Private(this))
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletCursorV2::~TabletCursorV2() = default;
|
2020-02-12 15:20:38 +00:00
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
QPoint TabletCursorV2::hotspot() const
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
return d->m_hotspot;
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
quint32 TabletCursorV2::enteredSerial() const
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
return d->m_serial;
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
SurfaceInterface *TabletCursorV2::surface() const
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
return d->m_surface;
|
|
|
|
}
|
|
|
|
|
2020-11-04 18:15:15 +00:00
|
|
|
class TabletToolV2InterfacePrivate : public QtWaylandServer::zwp_tablet_tool_v2
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-11-04 18:15:15 +00:00
|
|
|
TabletToolV2InterfacePrivate(TabletToolV2Interface *q, Display *display,
|
|
|
|
TabletToolV2Interface::Type type, uint32_t hsh, uint32_t hsl,
|
|
|
|
uint32_t hih, uint32_t hil,
|
|
|
|
const QVector<TabletToolV2Interface::Capability>& capabilities)
|
2020-02-12 15:20:38 +00:00
|
|
|
: zwp_tablet_tool_v2()
|
|
|
|
, m_display(display)
|
|
|
|
, m_type(type)
|
|
|
|
, m_hardwareSerialHigh(hsh)
|
|
|
|
, m_hardwareSerialLow(hsl)
|
|
|
|
, m_hardwareIdHigh(hih)
|
|
|
|
, m_hardwareIdLow(hil)
|
|
|
|
, m_capabilities(capabilities)
|
|
|
|
, q(q)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wl_resource *targetResource()
|
|
|
|
{
|
2020-03-20 00:06:28 +00:00
|
|
|
if (!m_surface)
|
|
|
|
return nullptr;
|
|
|
|
|
2020-02-12 15:20:38 +00:00
|
|
|
ClientConnection *client = m_surface->client();
|
|
|
|
const Resource *r = resourceMap().value(*client);
|
|
|
|
return r ? r->handle : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint64 hardwareId() const
|
|
|
|
{
|
|
|
|
return quint64(quint64(m_hardwareIdHigh) << 32) + m_hardwareIdLow;
|
|
|
|
}
|
|
|
|
quint64 hardwareSerial() const
|
|
|
|
{
|
|
|
|
return quint64(quint64(m_hardwareSerialHigh) << 32) + m_hardwareSerialLow;
|
|
|
|
}
|
|
|
|
|
|
|
|
void zwp_tablet_tool_v2_bind_resource(QtWaylandServer::zwp_tablet_tool_v2::Resource * resource) override
|
|
|
|
{
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletCursorV2 *&c = m_cursors[resource->handle];
|
2020-02-12 15:20:38 +00:00
|
|
|
if (!c)
|
2020-11-04 17:17:26 +00:00
|
|
|
c = new TabletCursorV2;
|
2020-02-12 15:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void zwp_tablet_tool_v2_set_cursor(Resource * resource, uint32_t serial, struct ::wl_resource * _surface, int32_t hotspot_x, int32_t hotspot_y) override
|
|
|
|
{
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletCursorV2 *c = m_cursors[resource->handle];
|
2020-02-12 15:20:38 +00:00
|
|
|
c->d->update(serial, SurfaceInterface::get(_surface), {hotspot_x, hotspot_y});
|
|
|
|
if (resource->handle == targetResource())
|
|
|
|
q->cursorChanged(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
void zwp_tablet_tool_v2_destroy_resource(Resource * resource) override {
|
|
|
|
delete m_cursors.take(resource->handle);
|
2020-12-16 14:42:00 +00:00
|
|
|
if (m_removed && resourceMap().isEmpty()) {
|
|
|
|
delete q;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-05 14:36:57 +00:00
|
|
|
void zwp_tablet_tool_v2_destroy(Resource *resource) override {
|
|
|
|
wl_resource_destroy(resource->handle);
|
|
|
|
}
|
|
|
|
|
2020-02-12 15:20:38 +00:00
|
|
|
Display *const m_display;
|
|
|
|
bool m_cleanup = false;
|
2020-12-16 14:42:00 +00:00
|
|
|
bool m_removed = false;
|
2020-02-12 15:20:38 +00:00
|
|
|
QPointer<SurfaceInterface> m_surface;
|
2020-11-04 17:17:26 +00:00
|
|
|
QPointer<TabletV2Interface> m_lastTablet;
|
2020-02-12 15:20:38 +00:00
|
|
|
const uint32_t m_type;
|
|
|
|
const uint32_t m_hardwareSerialHigh, m_hardwareSerialLow;
|
|
|
|
const uint32_t m_hardwareIdHigh, m_hardwareIdLow;
|
2020-11-04 18:15:15 +00:00
|
|
|
const QVector<TabletToolV2Interface::Capability> m_capabilities;
|
2020-11-04 17:17:26 +00:00
|
|
|
QHash<wl_resource *, TabletCursorV2 *> m_cursors;
|
|
|
|
TabletToolV2Interface *const q;
|
2020-02-12 15:20:38 +00:00
|
|
|
};
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletToolV2Interface::TabletToolV2Interface(Display *display, Type type, uint32_t hsh,
|
|
|
|
uint32_t hsl, uint32_t hih, uint32_t hil,
|
|
|
|
const QVector<Capability>& capabilities,
|
|
|
|
QObject *parent)
|
2020-02-12 15:20:38 +00:00
|
|
|
: QObject(parent)
|
2020-11-04 18:15:15 +00:00
|
|
|
, d(new TabletToolV2InterfacePrivate(this, display, type, hsh, hsl, hih, hil, capabilities))
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletToolV2Interface::~TabletToolV2Interface() = default;
|
2020-02-12 15:20:38 +00:00
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
void TabletToolV2Interface::setCurrentSurface(SurfaceInterface *surface)
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
if (d->m_surface == surface)
|
|
|
|
return;
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletV2Interface *const lastTablet = d->m_lastTablet;
|
2020-02-12 15:20:38 +00:00
|
|
|
if (d->m_surface && d->resourceMap().contains(*d->m_surface->client())) {
|
|
|
|
sendProximityOut();
|
|
|
|
sendFrame(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
d->m_surface = surface;
|
|
|
|
|
|
|
|
if (lastTablet && lastTablet->d->resourceForSurface(surface)) {
|
|
|
|
sendProximityIn(lastTablet);
|
|
|
|
} else {
|
|
|
|
d->m_lastTablet = lastTablet;
|
|
|
|
}
|
|
|
|
|
|
|
|
Q_EMIT cursorChanged(d->m_cursors.value(d->targetResource()));
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
bool TabletToolV2Interface::isClientSupported() const
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
return d->m_surface && d->targetResource();
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
void TabletToolV2Interface::sendButton(uint32_t button, bool pressed)
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
d->send_button(d->targetResource(), d->m_display->nextSerial(), button,
|
|
|
|
pressed ? QtWaylandServer::zwp_tablet_tool_v2::button_state_pressed
|
|
|
|
: QtWaylandServer::zwp_tablet_tool_v2::button_state_released);
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
void TabletToolV2Interface::sendMotion(const QPointF &pos)
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
d->send_motion(d->targetResource(), wl_fixed_from_double(pos.x()),
|
|
|
|
wl_fixed_from_double(pos.y()));
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
void TabletToolV2Interface::sendDistance(uint32_t distance)
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
d->send_distance(d->targetResource(), distance);
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
void TabletToolV2Interface::sendFrame(uint32_t time)
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
d->send_frame(d->targetResource(), time);
|
|
|
|
|
|
|
|
if (d->m_cleanup) {
|
|
|
|
d->m_surface = nullptr;
|
|
|
|
d->m_lastTablet = nullptr;
|
|
|
|
d->m_cleanup = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
void TabletToolV2Interface::sendPressure(uint32_t pressure)
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
d->send_pressure(d->targetResource(), pressure);
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
void TabletToolV2Interface::sendRotation(qreal rotation)
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
d->send_rotation(d->targetResource(), wl_fixed_from_double(rotation));
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
void TabletToolV2Interface::sendSlider(int32_t position)
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
d->send_slider(d->targetResource(), position);
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
void TabletToolV2Interface::sendTilt(qreal degreesX, qreal degreesY)
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
d->send_tilt(d->targetResource(), wl_fixed_from_double(degreesX),
|
|
|
|
wl_fixed_from_double(degreesY));
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
void TabletToolV2Interface::sendWheel(int32_t degrees, int32_t clicks)
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
d->send_wheel(d->targetResource(), degrees, clicks);
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
void TabletToolV2Interface::sendProximityIn(TabletV2Interface *tablet)
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
wl_resource* tabletResource = tablet->d->resourceForSurface(d->m_surface);
|
|
|
|
d->send_proximity_in(d->targetResource(), d->m_display->nextSerial(),
|
|
|
|
tabletResource, d->m_surface->resource());
|
|
|
|
d->m_lastTablet = tablet;
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
void TabletToolV2Interface::sendProximityOut()
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
d->send_proximity_out(d->targetResource());
|
|
|
|
d->m_cleanup = true;
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
void TabletToolV2Interface::sendDown()
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
d->send_down(d->targetResource(), d->m_display->nextSerial());
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
void TabletToolV2Interface::sendUp()
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
d->send_up(d->targetResource());
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
void TabletToolV2Interface::sendRemoved()
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
2020-12-16 14:42:00 +00:00
|
|
|
d->m_removed = true;
|
|
|
|
|
2020-02-12 15:20:38 +00:00
|
|
|
for (QtWaylandServer::zwp_tablet_tool_v2::Resource *resource : d->resourceMap()) {
|
|
|
|
d->send_removed(resource->handle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-16 01:46:33 +00:00
|
|
|
class TabletPadRingV2InterfacePrivate : public QtWaylandServer::zwp_tablet_pad_ring_v2
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TabletPadRingV2InterfacePrivate(TabletPadRingV2Interface *q)
|
|
|
|
: zwp_tablet_pad_ring_v2()
|
|
|
|
, q(q)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_resource *resourceForSurface(SurfaceInterface *surface) const
|
|
|
|
{
|
|
|
|
ClientConnection *client = surface->client();
|
|
|
|
Resource *r = resourceMap().value(*client);
|
|
|
|
return r ? r->handle : nullptr;
|
|
|
|
}
|
|
|
|
|
2021-01-05 14:36:57 +00:00
|
|
|
void zwp_tablet_pad_ring_v2_destroy_resource(Resource *resource) override {
|
|
|
|
Q_UNUSED(resource)
|
2020-12-16 01:46:33 +00:00
|
|
|
if (m_pad->isRemoved() && resourceMap().isEmpty()) {
|
|
|
|
delete q;
|
|
|
|
}
|
|
|
|
}
|
2021-01-05 14:36:57 +00:00
|
|
|
|
|
|
|
void zwp_tablet_pad_ring_v2_destroy(Resource *resource) override {
|
|
|
|
wl_resource_destroy(resource->handle);
|
|
|
|
}
|
2020-12-16 01:46:33 +00:00
|
|
|
TabletPadRingV2Interface *const q;
|
|
|
|
TabletPadV2Interface *m_pad;
|
|
|
|
};
|
|
|
|
|
|
|
|
TabletPadRingV2Interface::TabletPadRingV2Interface(QObject *parent)
|
|
|
|
: QObject(parent)
|
|
|
|
, d(new TabletPadRingV2InterfacePrivate(this))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TabletPadRingV2Interface::~TabletPadRingV2Interface() = default;
|
|
|
|
|
|
|
|
void TabletPadRingV2Interface::sendAngle(qreal angle)
|
|
|
|
{
|
|
|
|
d->send_angle(d->resourceForSurface(d->m_pad->currentSurface()), wl_fixed_from_double(angle));
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabletPadRingV2Interface::sendFrame(quint32 time)
|
|
|
|
{
|
|
|
|
d->send_frame(d->resourceForSurface(d->m_pad->currentSurface()), time);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabletPadRingV2Interface::sendSource(Source source)
|
|
|
|
{
|
|
|
|
d->send_source(d->resourceForSurface(d->m_pad->currentSurface()), source);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabletPadRingV2Interface::sendStop()
|
|
|
|
{
|
|
|
|
d->send_stop(d->resourceForSurface(d->m_pad->currentSurface()));
|
|
|
|
}
|
|
|
|
|
|
|
|
class TabletPadStripV2InterfacePrivate : public QtWaylandServer::zwp_tablet_pad_strip_v2
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TabletPadStripV2InterfacePrivate(TabletPadStripV2Interface *q)
|
|
|
|
: zwp_tablet_pad_strip_v2()
|
|
|
|
, q(q)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_resource *resourceForSurface(SurfaceInterface *surface) const
|
|
|
|
{
|
|
|
|
ClientConnection *client = surface->client();
|
|
|
|
Resource *r = resourceMap().value(*client);
|
|
|
|
return r ? r->handle : nullptr;
|
|
|
|
}
|
|
|
|
|
2021-01-05 14:36:57 +00:00
|
|
|
void zwp_tablet_pad_strip_v2_destroy_resource(Resource *resource) override {
|
|
|
|
Q_UNUSED(resource)
|
2020-12-16 01:46:33 +00:00
|
|
|
if (m_pad->isRemoved() && resourceMap().isEmpty()) {
|
|
|
|
delete q;
|
|
|
|
}
|
|
|
|
}
|
2021-01-05 14:36:57 +00:00
|
|
|
|
|
|
|
void zwp_tablet_pad_strip_v2_destroy(Resource *resource) override {
|
|
|
|
wl_resource_destroy(resource->handle);
|
|
|
|
}
|
2020-12-16 01:46:33 +00:00
|
|
|
TabletPadV2Interface *m_pad = nullptr;
|
|
|
|
TabletPadStripV2Interface *const q;
|
|
|
|
};
|
|
|
|
|
|
|
|
TabletPadStripV2Interface::TabletPadStripV2Interface(QObject *parent)
|
|
|
|
: QObject(parent)
|
|
|
|
, d(new TabletPadStripV2InterfacePrivate(this))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TabletPadStripV2Interface::~TabletPadStripV2Interface() = default;
|
|
|
|
|
|
|
|
void TabletPadStripV2Interface::sendFrame(quint32 time)
|
|
|
|
{
|
|
|
|
d->send_frame(d->resourceForSurface(d->m_pad->currentSurface()), time);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabletPadStripV2Interface::sendPosition(quint32 position)
|
|
|
|
{
|
|
|
|
d->send_position(d->resourceForSurface(d->m_pad->currentSurface()), position);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabletPadStripV2Interface::sendSource(Source source)
|
|
|
|
{
|
|
|
|
d->send_source(d->resourceForSurface(d->m_pad->currentSurface()), source);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabletPadStripV2Interface::sendStop()
|
|
|
|
{
|
|
|
|
d->send_stop(d->resourceForSurface(d->m_pad->currentSurface()));
|
|
|
|
}
|
|
|
|
|
|
|
|
class TabletPadGroupV2InterfacePrivate : public QtWaylandServer::zwp_tablet_pad_group_v2
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TabletPadGroupV2InterfacePrivate(quint32 currentMode, TabletPadGroupV2Interface *q)
|
|
|
|
: zwp_tablet_pad_group_v2()
|
|
|
|
, q(q)
|
|
|
|
, m_currentMode(currentMode)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_resource *resourceForSurface(SurfaceInterface *surface) const
|
|
|
|
{
|
|
|
|
ClientConnection *client = surface->client();
|
|
|
|
Resource *r = resourceMap().value(*client);
|
|
|
|
return r ? r->handle : nullptr;
|
|
|
|
}
|
|
|
|
|
2021-01-05 14:36:57 +00:00
|
|
|
void zwp_tablet_pad_group_v2_destroy_resource(Resource *resource) override {
|
|
|
|
Q_UNUSED(resource)
|
2020-12-16 01:46:33 +00:00
|
|
|
if (m_pad->isRemoved() && resourceMap().isEmpty()) {
|
|
|
|
delete q;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-05 14:36:57 +00:00
|
|
|
void zwp_tablet_pad_group_v2_destroy(Resource *resource) override {
|
|
|
|
wl_resource_destroy(resource->handle);
|
|
|
|
}
|
|
|
|
|
2020-12-16 01:46:33 +00:00
|
|
|
TabletPadGroupV2Interface *const q;
|
|
|
|
TabletPadV2Interface *m_pad = nullptr;
|
|
|
|
quint32 m_currentMode;
|
|
|
|
};
|
|
|
|
|
|
|
|
TabletPadGroupV2Interface::TabletPadGroupV2Interface(quint32 currentMode, QObject *parent)
|
|
|
|
: QObject(parent)
|
|
|
|
, d(new TabletPadGroupV2InterfacePrivate(currentMode, this))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TabletPadGroupV2Interface::~TabletPadGroupV2Interface() = default;
|
|
|
|
|
|
|
|
void TabletPadGroupV2Interface::sendModeSwitch(quint32 time, quint32 serial, quint32 mode)
|
|
|
|
{
|
|
|
|
d->m_currentMode = mode;
|
|
|
|
d->send_mode_switch(d->resourceForSurface(d->m_pad->currentSurface()), time, serial, mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
class TabletPadV2InterfacePrivate : public QtWaylandServer::zwp_tablet_pad_v2
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TabletPadV2InterfacePrivate(const QString &path, quint32 buttons, quint32 rings, quint32 strips, quint32 modes, quint32 currentMode, Display *display, TabletPadV2Interface *q)
|
|
|
|
: zwp_tablet_pad_v2()
|
|
|
|
, q(q)
|
|
|
|
, m_path(path)
|
|
|
|
, m_buttons(buttons)
|
|
|
|
, m_modes(modes)
|
|
|
|
, m_padGroup(new TabletPadGroupV2Interface(currentMode, q))
|
|
|
|
, m_display(display)
|
|
|
|
{
|
|
|
|
for (uint i = 0; i < buttons; ++i) {
|
|
|
|
m_buttons[i] = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_padGroup->d->m_pad = q;
|
|
|
|
m_rings.reserve(rings);
|
|
|
|
for (quint32 i = 0; i < rings; ++i) {
|
|
|
|
m_rings += new TabletPadRingV2Interface(q);
|
|
|
|
m_rings.constLast()->d->m_pad = q;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_strips.reserve(strips);
|
|
|
|
for (quint32 i = 0; i < strips; ++i) {
|
|
|
|
m_strips += new TabletPadStripV2Interface(q);
|
|
|
|
m_strips.constLast()->d->m_pad = q;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-05 14:36:57 +00:00
|
|
|
void zwp_tablet_pad_v2_destroy_resource(Resource *resource) override {
|
|
|
|
Q_UNUSED(resource)
|
2020-12-16 01:46:33 +00:00
|
|
|
if (m_removed && resourceMap().isEmpty()) {
|
|
|
|
delete q;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-05 14:36:57 +00:00
|
|
|
void zwp_tablet_pad_v2_destroy(Resource *resource) override {
|
|
|
|
wl_resource_destroy(resource->handle);
|
|
|
|
}
|
|
|
|
|
2020-12-16 01:46:33 +00:00
|
|
|
void zwp_tablet_pad_v2_set_feedback(Resource *resource, quint32 button, const QString &description, quint32 serial) override {
|
|
|
|
Q_EMIT q->feedback(m_display->getConnection(resource->client()), button, description, serial);
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_resource *resourceForSurface(SurfaceInterface *surface) const
|
|
|
|
{
|
|
|
|
ClientConnection *client = surface->client();
|
|
|
|
Resource *r = resourceMap().value(*client);
|
|
|
|
return r ? r->handle : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
TabletPadV2Interface *const q;
|
|
|
|
|
|
|
|
const QString m_path;
|
|
|
|
QVector<quint32> m_buttons;
|
|
|
|
const int m_modes;
|
|
|
|
|
|
|
|
QVector<TabletPadRingV2Interface *> m_rings;
|
|
|
|
QVector<TabletPadStripV2Interface *> m_strips;
|
|
|
|
TabletPadGroupV2Interface *const m_padGroup;
|
|
|
|
TabletSeatV2Interface *m_seat = nullptr;
|
|
|
|
SurfaceInterface *m_currentSurface = nullptr;
|
|
|
|
bool m_removed = false;
|
|
|
|
Display *const m_display;
|
|
|
|
};
|
|
|
|
|
|
|
|
TabletPadV2Interface::TabletPadV2Interface(const QString &path, quint32 buttons, quint32 rings, quint32 strips, quint32 modes, quint32 currentMode, Display *display, QObject *parent)
|
|
|
|
: QObject(parent)
|
|
|
|
, d(new TabletPadV2InterfacePrivate(path, buttons, rings, strips, modes, currentMode, display, this))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TabletPadV2Interface::~TabletPadV2Interface() = default;
|
|
|
|
|
|
|
|
void TabletPadV2Interface::sendButton(quint32 time, quint32 button, bool pressed)
|
|
|
|
{
|
|
|
|
d->send_button(d->resourceForSurface(currentSurface()), time, button, pressed);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabletPadV2Interface::sendRemoved()
|
|
|
|
{
|
|
|
|
d->m_removed = true;
|
|
|
|
for (auto resource : d->resourceMap()) {
|
|
|
|
d->send_removed(resource->handle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TabletPadRingV2Interface *TabletPadV2Interface::ring(uint at) const
|
|
|
|
{
|
|
|
|
return d->m_rings[at];
|
|
|
|
}
|
|
|
|
|
|
|
|
TabletPadStripV2Interface *TabletPadV2Interface::strip(uint at) const
|
|
|
|
{
|
|
|
|
return d->m_strips[at];
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TabletPadV2Interface::isRemoved() const
|
|
|
|
{
|
|
|
|
return d->m_removed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabletPadV2Interface::setCurrentSurface(SurfaceInterface *surface, TabletV2Interface *tablet)
|
|
|
|
{
|
|
|
|
if (surface == d->m_currentSurface) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (d->m_currentSurface) {
|
|
|
|
d->send_leave(d->m_display->nextSerial(), surface->resource());
|
|
|
|
}
|
|
|
|
|
|
|
|
d->m_currentSurface = surface;
|
|
|
|
if (surface) {
|
|
|
|
wl_resource *tabletResource = tablet->d->resourceForSurface(surface);
|
|
|
|
|
|
|
|
d->send_enter(d->resourceForSurface(surface), d->m_display->nextSerial(), tabletResource, surface->resource());
|
|
|
|
d->m_padGroup->sendModeSwitch(0, d->m_display->nextSerial(), d->m_padGroup->d->m_currentMode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SurfaceInterface *TabletPadV2Interface::currentSurface() const
|
|
|
|
{
|
|
|
|
return d->m_currentSurface;
|
|
|
|
}
|
|
|
|
|
2020-11-04 18:15:15 +00:00
|
|
|
class TabletSeatV2InterfacePrivate : public QtWaylandServer::zwp_tablet_seat_v2
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-11-04 18:15:15 +00:00
|
|
|
TabletSeatV2InterfacePrivate(Display *display, TabletSeatV2Interface *q)
|
2020-02-12 15:20:38 +00:00
|
|
|
: zwp_tablet_seat_v2()
|
|
|
|
, q(q)
|
|
|
|
, m_display(display)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void zwp_tablet_seat_v2_bind_resource(Resource *resource) override
|
|
|
|
{
|
2020-12-16 01:46:33 +00:00
|
|
|
for (auto tablet : qAsConst(m_tablets)) {
|
|
|
|
sendTabletAdded(resource, tablet);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto pad : qAsConst(m_pads)) {
|
|
|
|
sendPadAdded(resource, pad);
|
2020-02-12 15:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (auto *tool : qAsConst(m_tools)) {
|
|
|
|
sendToolAdded(resource, tool);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
void sendToolAdded(Resource *resource, TabletToolV2Interface *tool)
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
2020-12-16 14:42:00 +00:00
|
|
|
if (tool->d->m_removed)
|
|
|
|
return;
|
|
|
|
|
2020-02-12 15:20:38 +00:00
|
|
|
wl_resource *toolResource = tool->d->add(resource->client(), resource->version())->handle;
|
|
|
|
send_tool_added(resource->handle, toolResource);
|
|
|
|
|
|
|
|
tool->d->send_type(toolResource, tool->d->m_type);
|
|
|
|
tool->d->send_hardware_serial(toolResource, tool->d->m_hardwareSerialHigh,
|
|
|
|
tool->d->m_hardwareSerialLow);
|
|
|
|
tool->d->send_hardware_id_wacom(toolResource, tool->d->m_hardwareIdHigh,
|
|
|
|
tool->d->m_hardwareIdLow);
|
|
|
|
for (uint32_t cap : qAsConst(tool->d->m_capabilities)) {
|
|
|
|
tool->d->send_capability(toolResource, cap);
|
|
|
|
}
|
|
|
|
tool->d->send_done(toolResource);
|
|
|
|
}
|
2020-11-04 17:17:26 +00:00
|
|
|
void sendTabletAdded(Resource *resource, TabletV2Interface *tablet)
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
2020-12-16 14:42:00 +00:00
|
|
|
if (tablet->d->m_removed)
|
|
|
|
return;
|
|
|
|
|
2020-02-12 15:20:38 +00:00
|
|
|
wl_resource *tabletResource = tablet->d->add(resource->client(), resource->version())->handle;
|
|
|
|
send_tablet_added(resource->handle, tabletResource);
|
|
|
|
|
|
|
|
tablet->d->send_name(tabletResource, tablet->d->m_name);
|
|
|
|
if (tablet->d->m_vendorId && tablet->d->m_productId) {
|
|
|
|
tablet->d->send_id(tabletResource, tablet->d->m_vendorId, tablet->d->m_productId);
|
|
|
|
}
|
|
|
|
for (const QString &path : qAsConst(tablet->d->m_paths)) {
|
|
|
|
tablet->d->send_path(tabletResource, path);
|
|
|
|
}
|
|
|
|
tablet->d->send_done(tabletResource);
|
|
|
|
}
|
|
|
|
|
2020-12-16 01:46:33 +00:00
|
|
|
void sendPadAdded(Resource *resource, TabletPadV2Interface *pad)
|
|
|
|
{
|
|
|
|
if (pad->d->m_removed)
|
|
|
|
return;
|
|
|
|
|
|
|
|
wl_resource *tabletResource = pad->d->add(resource->client(), resource->version())->handle;
|
|
|
|
send_pad_added(resource->handle, tabletResource);
|
|
|
|
|
|
|
|
pad->d->send_buttons(tabletResource, pad->d->m_buttons.size());
|
|
|
|
pad->d->send_path(tabletResource, pad->d->m_path);
|
|
|
|
|
|
|
|
auto groupResource = pad->d->m_padGroup->d->add(resource->client(), resource->version());
|
|
|
|
pad->d->send_group(tabletResource, groupResource->handle);
|
|
|
|
pad->d->m_padGroup->d->send_modes(groupResource->handle, pad->d->m_modes);
|
|
|
|
|
|
|
|
pad->d->m_padGroup->d->send_buttons(groupResource->handle, QByteArray::fromRawData(reinterpret_cast<const char *>(pad->d->m_buttons.data()), pad->d->m_buttons.size() * sizeof(quint32)));
|
|
|
|
|
|
|
|
for (auto ring : pad->d->m_rings) {
|
|
|
|
auto ringResource = ring->d->add(resource->client(), resource->version());
|
|
|
|
pad->d->m_padGroup->d->send_ring(groupResource->handle, ringResource->handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto strip : pad->d->m_strips) {
|
|
|
|
auto stripResource = strip->d->add(resource->client(), resource->version());
|
|
|
|
pad->d->m_padGroup->d->send_strip(groupResource->handle, stripResource->handle);
|
|
|
|
}
|
|
|
|
pad->d->m_padGroup->d->send_done(groupResource->handle);
|
|
|
|
pad->d->send_done(tabletResource);
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletSeatV2Interface *const q;
|
|
|
|
QVector<TabletToolV2Interface *> m_tools;
|
|
|
|
QHash<QString, TabletV2Interface *> m_tablets;
|
2020-12-16 01:46:33 +00:00
|
|
|
QHash<QString, TabletPadV2Interface *> m_pads;
|
2020-02-12 15:20:38 +00:00
|
|
|
Display *const m_display;
|
|
|
|
};
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletSeatV2Interface::TabletSeatV2Interface(Display *display, QObject *parent)
|
2020-02-12 15:20:38 +00:00
|
|
|
: QObject(parent)
|
2020-11-04 18:15:15 +00:00
|
|
|
, d(new TabletSeatV2InterfacePrivate(display, this))
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletSeatV2Interface::~TabletSeatV2Interface() = default;
|
2020-02-12 15:20:38 +00:00
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletToolV2Interface *TabletSeatV2Interface::addTool(TabletToolV2Interface::Type type,
|
|
|
|
quint64 hardwareSerial,
|
|
|
|
quint64 hardwareId,
|
|
|
|
const QVector<TabletToolV2Interface::Capability> &capabilities)
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
constexpr auto MAX_UINT_32 = std::numeric_limits<quint32>::max();
|
2020-11-04 17:17:26 +00:00
|
|
|
auto tool = new TabletToolV2Interface(d->m_display,
|
|
|
|
type, hardwareSerial >> 32, hardwareSerial & MAX_UINT_32,
|
|
|
|
hardwareId >> 32, hardwareId & MAX_UINT_32, capabilities, this);
|
2020-02-12 15:20:38 +00:00
|
|
|
for (QtWaylandServer::zwp_tablet_seat_v2::Resource *resource : d->resourceMap()) {
|
|
|
|
d->sendToolAdded(resource, tool);
|
|
|
|
}
|
|
|
|
|
|
|
|
d->m_tools.append(tool);
|
|
|
|
QObject::connect(tool, &QObject::destroyed, this, [this](QObject *object) {
|
2020-11-04 17:17:26 +00:00
|
|
|
auto tti = static_cast<TabletToolV2Interface *>(object);
|
2020-02-12 15:20:38 +00:00
|
|
|
tti->d->send_removed();
|
|
|
|
d->m_tools.removeAll(tti);
|
|
|
|
});
|
|
|
|
return tool;
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletV2Interface *TabletSeatV2Interface::addTablet(uint32_t vendorId, uint32_t productId,
|
|
|
|
const QString &sysname,
|
|
|
|
const QString &name,
|
|
|
|
const QStringList &paths)
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
2020-12-16 01:46:33 +00:00
|
|
|
Q_ASSERT(!d->m_tablets.contains(sysname));
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
auto iface = new TabletV2Interface(vendorId, productId, name, paths, this);
|
2020-02-12 15:20:38 +00:00
|
|
|
|
|
|
|
for (QtWaylandServer::zwp_tablet_seat_v2::Resource *r : d->resourceMap()) {
|
|
|
|
d->sendTabletAdded(r, iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
d->m_tablets[sysname] = iface;
|
|
|
|
return iface;
|
|
|
|
}
|
|
|
|
|
2020-12-16 01:46:33 +00:00
|
|
|
TabletPadV2Interface *TabletSeatV2Interface::addTabletPad(const QString &sysname, const QString &name, const QStringList &paths, quint32 buttons, quint32 rings, quint32 strips, quint32 modes, quint32 currentMode, TabletV2Interface *tablet)
|
|
|
|
{
|
|
|
|
Q_UNUSED(name);
|
|
|
|
auto iface = new TabletPadV2Interface(paths.at(0), buttons, rings, strips, modes, currentMode, d->m_display, this);
|
|
|
|
iface->d->m_seat = this;
|
|
|
|
for (auto r : d->resourceMap()) {
|
|
|
|
d->sendPadAdded(r, iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
tablet->d->m_pad = iface;
|
|
|
|
|
|
|
|
d->m_pads[sysname] = iface;
|
|
|
|
return iface;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabletSeatV2Interface::removeDevice(const QString &sysname)
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
auto tablet = d->m_tablets.take(sysname);
|
|
|
|
if (tablet) {
|
|
|
|
tablet->sendRemoved();
|
|
|
|
}
|
2020-12-16 01:46:33 +00:00
|
|
|
|
|
|
|
auto pad = d->m_pads.take(sysname);
|
|
|
|
if (pad) {
|
|
|
|
pad->sendRemoved();
|
|
|
|
}
|
2020-02-12 15:20:38 +00:00
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletToolV2Interface *TabletSeatV2Interface::toolByHardwareId(quint64 hardwareId) const
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
2020-11-04 17:17:26 +00:00
|
|
|
for (TabletToolV2Interface *tool : d->m_tools) {
|
2020-02-12 15:20:38 +00:00
|
|
|
if (tool->d->hardwareId() == hardwareId)
|
|
|
|
return tool;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletToolV2Interface *TabletSeatV2Interface::toolByHardwareSerial(quint64 hardwareSerial) const
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
2020-11-04 17:17:26 +00:00
|
|
|
for (TabletToolV2Interface *tool : d->m_tools) {
|
2020-02-12 15:20:38 +00:00
|
|
|
if (tool->d->hardwareSerial() == hardwareSerial)
|
|
|
|
return tool;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2020-12-16 01:46:33 +00:00
|
|
|
TabletPadV2Interface * TabletSeatV2Interface::padByName(const QString &name) const
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
2020-12-16 01:46:33 +00:00
|
|
|
Q_ASSERT(d->m_pads.contains(name));
|
|
|
|
return d->m_pads.value(name);
|
2020-02-12 15:20:38 +00:00
|
|
|
}
|
|
|
|
|
2020-11-04 18:15:15 +00:00
|
|
|
class TabletManagerV2InterfacePrivate : public QtWaylandServer::zwp_tablet_manager_v2
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-11-04 18:15:15 +00:00
|
|
|
TabletManagerV2InterfacePrivate(Display *display, TabletManagerV2Interface *q)
|
2020-02-12 15:20:38 +00:00
|
|
|
: zwp_tablet_manager_v2(*display, s_version)
|
|
|
|
, q(q)
|
|
|
|
, m_display(display)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void zwp_tablet_manager_v2_get_tablet_seat(Resource *resource, uint32_t tablet_seat,
|
|
|
|
struct ::wl_resource *seat_resource) override {
|
|
|
|
SeatInterface* seat = SeatInterface::get(seat_resource);
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletSeatV2Interface *tsi = get(seat);
|
2020-02-12 15:20:38 +00:00
|
|
|
tsi->d->add(resource->client(), tablet_seat, s_version);
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletSeatV2Interface *get(SeatInterface *seat)
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletSeatV2Interface *&tabletSeat = m_seats[seat];
|
2020-02-12 15:20:38 +00:00
|
|
|
if (!tabletSeat) {
|
2020-11-04 17:17:26 +00:00
|
|
|
tabletSeat = new TabletSeatV2Interface(m_display, q);
|
2020-02-12 15:20:38 +00:00
|
|
|
}
|
|
|
|
return tabletSeat;
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletManagerV2Interface *const q;
|
2020-02-12 15:20:38 +00:00
|
|
|
Display *const m_display;
|
2020-11-04 17:17:26 +00:00
|
|
|
QHash<SeatInterface *, TabletSeatV2Interface *> m_seats;
|
2020-02-12 15:20:38 +00:00
|
|
|
};
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletManagerV2Interface::TabletManagerV2Interface(Display *display, QObject *parent)
|
2020-02-12 15:20:38 +00:00
|
|
|
: QObject(parent)
|
2020-11-04 18:15:15 +00:00
|
|
|
, d(new TabletManagerV2InterfacePrivate(display, this))
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletSeatV2Interface *TabletManagerV2Interface::seat(SeatInterface *seat) const
|
2020-02-12 15:20:38 +00:00
|
|
|
{
|
|
|
|
return d->get(seat);
|
|
|
|
}
|
|
|
|
|
2020-12-16 01:46:33 +00:00
|
|
|
bool TabletSeatV2Interface::isClientSupported(ClientConnection *client) const
|
|
|
|
{
|
|
|
|
return d->resourceMap().value(*client);
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:17:26 +00:00
|
|
|
TabletManagerV2Interface::~TabletManagerV2Interface() = default;
|
2020-11-04 18:15:15 +00:00
|
|
|
|
|
|
|
} // namespace KWaylandServer
|