Commit 9e8d2830 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

Rename tablet interfaces according to the current naming conventions

Tablet interface classes must have "V2" in their names because the
corresponding protocol is still unstable.
parent 06814a92
......@@ -25,7 +25,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
#include "../../src/server/compositor_interface.h"
#include "../../src/server/display.h"
#include "../../src/server/seat_interface.h"
#include "../../src/server/tablet_interface.h"
#include "../../src/server/tablet_v2_interface.h"
#include "KWayland/Client/compositor.h"
#include "KWayland/Client/connection_thread.h"
......@@ -125,10 +125,10 @@ private:
CompositorInterface *m_serverCompositor;
TabletSeat *m_tabletSeatClient = nullptr;
TabletManagerInterface *m_tabletManager;
TabletManagerV2Interface *m_tabletManager;
TabletInterface *m_tablet;
TabletToolInterface *m_tool;
TabletV2Interface *m_tablet;
TabletToolV2Interface *m_tool;
QVector<SurfaceInterface *> m_surfaces;
};
......@@ -144,7 +144,7 @@ void TestTabletInterface::initTestCase()
m_seat = m_display.createSeat(this);
m_seat->create();
m_serverCompositor = m_display.createCompositor(this);
m_tabletManager = m_display.createTabletManagerInterface(this);
m_tabletManager = m_display.createTabletManagerV2(this);
connect(m_serverCompositor, &CompositorInterface::surfaceCreated, this, [this](SurfaceInterface *surface) {
m_surfaces += surface;
......@@ -218,7 +218,7 @@ TestTabletInterface::~TestTabletInterface()
void TestTabletInterface::testAdd()
{
TabletSeatInterface *seatInterface = m_tabletManager->seat(m_seat);
TabletSeatV2Interface *seatInterface = m_tabletManager->seat(m_seat);
QVERIFY(seatInterface);
QSignalSpy tabletSpy(m_tabletSeatClient, &TabletSeat::tabletAdded);
......@@ -228,7 +228,7 @@ void TestTabletInterface::testAdd()
QCOMPARE(m_tabletSeatClient->m_tablets.count(), 1);
QSignalSpy toolSpy(m_tabletSeatClient, &TabletSeat::toolAdded);
m_tool = seatInterface->addTool(KWaylandServer::TabletToolInterface::Pen, 0, 0, {TabletToolInterface::Tilt, TabletToolInterface::Pressure});
m_tool = seatInterface->addTool(KWaylandServer::TabletToolV2Interface::Pen, 0, 0, {TabletToolV2Interface::Tilt, TabletToolV2Interface::Pressure});
QVERIFY(m_tool);
QVERIFY(toolSpy.wait() || toolSpy.count() == 1);
QCOMPARE(m_tabletSeatClient->m_tools.count(), 1);
......
......@@ -55,7 +55,7 @@ set(SERVER_LIB_SRCS
subcompositor_interface.cpp
surface_interface.cpp
surfacerole.cpp
tablet_interface.cpp
tablet_v2_interface.cpp
textinput_v2_interface.cpp
textinput_v3_interface.cpp
touch_interface.cpp
......@@ -422,7 +422,7 @@ set(SERVER_LIB_HEADERS
slide_interface.h
subcompositor_interface.h
surface_interface.h
tablet_interface.h
tablet_v2_interface.h
textinput.h
textinput_v2_interface.h
textinput_v3_interface.h
......
......@@ -39,7 +39,7 @@
#include "shadow_interface.h"
#include "slide_interface.h"
#include "subcompositor_interface.h"
#include "tablet_interface.h"
#include "tablet_v2_interface.h"
#include "textinput_v2_interface_p.h"
#include "textinput_v3_interface_p.h"
#include "viewporter_interface.h"
......@@ -457,9 +457,9 @@ KeyStateInterface *Display::createKeyStateInterface(QObject *parent)
return d;
}
TabletManagerInterface *Display::createTabletManagerInterface(QObject *parent)
TabletManagerV2Interface *Display::createTabletManagerV2(QObject *parent)
{
auto d = new TabletManagerInterface(this, parent);
auto d = new TabletManagerV2Interface(this, parent);
connect(this, &Display::aboutToTerminate, d, [d] { delete d; });
return d;
}
......
......@@ -69,7 +69,7 @@ class XdgDecorationManagerV1Interface;
class EglStreamControllerInterface;
class KeyStateInterface;
class LinuxDmabufUnstableV1Interface;
class TabletManagerInterface;
class TabletManagerV2Interface;
class DataControlDeviceManagerV1Interface;
class PrimarySelectionDeviceManagerV1Interface;
class KeyboardShortcutsInhibitManagerV1Interface;
......@@ -321,7 +321,7 @@ public:
*
* @since 5.67
*/
TabletManagerInterface *createTabletManagerInterface(QObject *parent = nullptr);
TabletManagerV2Interface *createTabletManagerV2(QObject *parent = nullptr);
/**
* Creates the KeyboardShortcutsInhibitorV1Interface
......
......@@ -17,7 +17,7 @@ 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/>.
*********************************************************************/
#include "tablet_interface.h"
#include "tablet_v2_interface.h"
#include "display.h"
#include "resource_p.h"
#include "seat_interface.h"
......@@ -30,10 +30,10 @@ using namespace KWaylandServer;
static int s_version = 1;
class TabletInterface::Private : public QtWaylandServer::zwp_tablet_v2
class TabletV2Interface::Private : public QtWaylandServer::zwp_tablet_v2
{
public:
Private(TabletInterface* q, uint32_t vendorId, uint32_t productId, const QString name, const QStringList &paths)
Private(TabletV2Interface *q, uint32_t vendorId, uint32_t productId, const QString name, const QStringList &paths)
: zwp_tablet_v2()
, q(q)
, m_vendorId(vendorId)
......@@ -58,7 +58,7 @@ public:
}
}
TabletInterface *const q;
TabletV2Interface *const q;
const uint32_t m_vendorId;
const uint32_t m_productId;
const QString m_name;
......@@ -66,22 +66,22 @@ public:
bool removed = false;
};
TabletInterface::TabletInterface(uint32_t vendorId, uint32_t productId,
const QString &name, const QStringList &paths,
QObject *parent)
TabletV2Interface::TabletV2Interface(uint32_t vendorId, uint32_t productId,
const QString &name, const QStringList &paths,
QObject *parent)
: QObject(parent)
, d(new Private(this, vendorId, productId, name, paths))
{
}
TabletInterface::~TabletInterface() = default;
TabletV2Interface::~TabletV2Interface() = default;
bool TabletInterface::isSurfaceSupported(SurfaceInterface *surface) const
bool TabletV2Interface::isSurfaceSupported(SurfaceInterface *surface) const
{
return d->resourceForSurface(surface);
}
void TabletInterface::sendRemoved()
void TabletV2Interface::sendRemoved()
{
d->removed = true;
for (QtWaylandServer::zwp_tablet_v2::Resource *resource : d->resourceMap()) {
......@@ -89,10 +89,10 @@ void TabletInterface::sendRemoved()
}
}
class TabletCursor::Private
class TabletCursorV2::Private
{
public:
Private(TabletCursor* q) : q(q) {}
Private(TabletCursorV2 *q) : q(q) {}
void update(quint32 serial, SurfaceInterface *surface, const QPoint &hotspot)
{
......@@ -104,40 +104,40 @@ public:
Q_EMIT q->changed();
}
TabletCursor* const q;
TabletCursorV2 *const q;
quint32 m_serial = 0;
SurfaceInterface* m_surface = nullptr;
QPoint m_hotspot;
};
TabletCursor::TabletCursor()
TabletCursorV2::TabletCursorV2()
: QObject()
, d(new Private(this))
{
}
TabletCursor::~TabletCursor() = default;
TabletCursorV2::~TabletCursorV2() = default;
QPoint TabletCursor::hotspot() const
QPoint TabletCursorV2::hotspot() const
{
return d->m_hotspot;
}
quint32 TabletCursor::enteredSerial() const
quint32 TabletCursorV2::enteredSerial() const
{
return d->m_serial;
}
SurfaceInterface* TabletCursor::surface() const
SurfaceInterface *TabletCursorV2::surface() const
{
return d->m_surface;
}
class TabletToolInterface::Private : public QtWaylandServer::zwp_tablet_tool_v2
class TabletToolV2Interface::Private : public QtWaylandServer::zwp_tablet_tool_v2
{
public:
Private(TabletToolInterface* q, Display *display, Type type, uint32_t hsh, uint32_t hsl, uint32_t hih,
Private(TabletToolV2Interface *q, Display *display, Type type, uint32_t hsh, uint32_t hsl, uint32_t hih,
uint32_t hil, const QVector<Capability>& capabilities)
: zwp_tablet_tool_v2()
, m_display(display)
......@@ -173,14 +173,14 @@ public:
void zwp_tablet_tool_v2_bind_resource(QtWaylandServer::zwp_tablet_tool_v2::Resource * resource) override
{
TabletCursor *&c = m_cursors[resource->handle];
TabletCursorV2 *&c = m_cursors[resource->handle];
if (!c)
c = new TabletCursor;
c = new TabletCursorV2;
}
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
{
TabletCursor *c = m_cursors[resource->handle];
TabletCursorV2 *c = m_cursors[resource->handle];
c->d->update(serial, SurfaceInterface::get(_surface), {hotspot_x, hotspot_y});
if (resource->handle == targetResource())
q->cursorChanged(c);
......@@ -193,32 +193,32 @@ public:
Display *const m_display;
bool m_cleanup = false;
QPointer<SurfaceInterface> m_surface;
QPointer<TabletInterface> m_lastTablet;
QPointer<TabletV2Interface> m_lastTablet;
const uint32_t m_type;
const uint32_t m_hardwareSerialHigh, m_hardwareSerialLow;
const uint32_t m_hardwareIdHigh, m_hardwareIdLow;
const QVector<Capability> m_capabilities;
QHash<wl_resource *, TabletCursor *> m_cursors;
TabletToolInterface *const q;
QHash<wl_resource *, TabletCursorV2 *> m_cursors;
TabletToolV2Interface *const q;
};
TabletToolInterface::TabletToolInterface(Display *display, Type type, uint32_t hsh,
uint32_t hsl, uint32_t hih, uint32_t hil,
const QVector<Capability>& capabilities,
QObject *parent)
TabletToolV2Interface::TabletToolV2Interface(Display *display, Type type, uint32_t hsh,
uint32_t hsl, uint32_t hih, uint32_t hil,
const QVector<Capability>& capabilities,
QObject *parent)
: QObject(parent)
, d(new Private(this, display, type, hsh, hsl, hih, hil, capabilities))
{
}
TabletToolInterface::~TabletToolInterface() = default;
TabletToolV2Interface::~TabletToolV2Interface() = default;
void TabletToolInterface::setCurrentSurface(SurfaceInterface *surface)
void TabletToolV2Interface::setCurrentSurface(SurfaceInterface *surface)
{
if (d->m_surface == surface)
return;
TabletInterface *const lastTablet = d->m_lastTablet;
TabletV2Interface *const lastTablet = d->m_lastTablet;
if (d->m_surface && d->resourceMap().contains(*d->m_surface->client())) {
sendProximityOut();
sendFrame(0);
......@@ -235,30 +235,30 @@ void TabletToolInterface::setCurrentSurface(SurfaceInterface *surface)
Q_EMIT cursorChanged(d->m_cursors.value(d->targetResource()));
}
bool TabletToolInterface::isClientSupported() const
bool TabletToolV2Interface::isClientSupported() const
{
return d->m_surface && d->targetResource();
}
void TabletToolInterface::sendButton(uint32_t button, bool pressed)
void TabletToolV2Interface::sendButton(uint32_t button, bool pressed)
{
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);
}
void TabletToolInterface::sendMotion(const QPointF &pos)
void TabletToolV2Interface::sendMotion(const QPointF &pos)
{
d->send_motion(d->targetResource(), wl_fixed_from_double(pos.x()),
wl_fixed_from_double(pos.y()));
}
void TabletToolInterface::sendDistance(uint32_t distance)
void TabletToolV2Interface::sendDistance(uint32_t distance)
{
d->send_distance(d->targetResource(), distance);
}
void TabletToolInterface::sendFrame(uint32_t time)
void TabletToolV2Interface::sendFrame(uint32_t time)
{
d->send_frame(d->targetResource(), time);
......@@ -269,33 +269,33 @@ void TabletToolInterface::sendFrame(uint32_t time)
}
}
void TabletToolInterface::sendPressure(uint32_t pressure)
void TabletToolV2Interface::sendPressure(uint32_t pressure)
{
d->send_pressure(d->targetResource(), pressure);
}
void TabletToolInterface::sendRotation(qreal rotation)
void TabletToolV2Interface::sendRotation(qreal rotation)
{
d->send_rotation(d->targetResource(), wl_fixed_from_double(rotation));
}
void TabletToolInterface::sendSlider(int32_t position)
void TabletToolV2Interface::sendSlider(int32_t position)
{
d->send_slider(d->targetResource(), position);
}
void TabletToolInterface::sendTilt(qreal degreesX, qreal degreesY)
void TabletToolV2Interface::sendTilt(qreal degreesX, qreal degreesY)
{
d->send_tilt(d->targetResource(), wl_fixed_from_double(degreesX),
wl_fixed_from_double(degreesY));
}
void TabletToolInterface::sendWheel(int32_t degrees, int32_t clicks)
void TabletToolV2Interface::sendWheel(int32_t degrees, int32_t clicks)
{
d->send_wheel(d->targetResource(), degrees, clicks);
}
void TabletToolInterface::sendProximityIn(TabletInterface *tablet)
void TabletToolV2Interface::sendProximityIn(TabletV2Interface *tablet)
{
wl_resource* tabletResource = tablet->d->resourceForSurface(d->m_surface);
d->send_proximity_in(d->targetResource(), d->m_display->nextSerial(),
......@@ -303,33 +303,33 @@ void TabletToolInterface::sendProximityIn(TabletInterface *tablet)
d->m_lastTablet = tablet;
}
void TabletToolInterface::sendProximityOut()
void TabletToolV2Interface::sendProximityOut()
{
d->send_proximity_out(d->targetResource());
d->m_cleanup = true;
}
void TabletToolInterface::sendDown()
void TabletToolV2Interface::sendDown()
{
d->send_down(d->targetResource(), d->m_display->nextSerial());
}
void TabletToolInterface::sendUp()
void TabletToolV2Interface::sendUp()
{
d->send_up(d->targetResource());
}
void TabletToolInterface::sendRemoved()
void TabletToolV2Interface::sendRemoved()
{
for (QtWaylandServer::zwp_tablet_tool_v2::Resource *resource : d->resourceMap()) {
d->send_removed(resource->handle);
}
}
class TabletSeatInterface::Private : public QtWaylandServer::zwp_tablet_seat_v2
class TabletSeatV2Interface::Private : public QtWaylandServer::zwp_tablet_seat_v2
{
public:
Private(Display *display, TabletSeatInterface *q)
Private(Display *display, TabletSeatV2Interface *q)
: zwp_tablet_seat_v2()
, q(q)
, m_display(display)
......@@ -347,7 +347,7 @@ public:
}
}
void sendToolAdded(Resource *resource, TabletToolInterface *tool)
void sendToolAdded(Resource *resource, TabletToolV2Interface *tool)
{
wl_resource *toolResource = tool->d->add(resource->client(), resource->version())->handle;
send_tool_added(resource->handle, toolResource);
......@@ -362,7 +362,7 @@ public:
}
tool->d->send_done(toolResource);
}
void sendTabletAdded(Resource *resource, TabletInterface *tablet)
void sendTabletAdded(Resource *resource, TabletV2Interface *tablet)
{
wl_resource *tabletResource = tablet->d->add(resource->client(), resource->version())->handle;
send_tablet_added(resource->handle, tabletResource);
......@@ -377,48 +377,48 @@ public:
tablet->d->send_done(tabletResource);
}
TabletSeatInterface *const q;
QVector<TabletToolInterface *> m_tools;
QHash<QString, TabletInterface *> m_tablets;
TabletSeatV2Interface *const q;
QVector<TabletToolV2Interface *> m_tools;
QHash<QString, TabletV2Interface *> m_tablets;
Display *const m_display;
};
TabletSeatInterface::TabletSeatInterface(Display *display, QObject *parent)
TabletSeatV2Interface::TabletSeatV2Interface(Display *display, QObject *parent)
: QObject(parent)
, d(new Private(display, this))
{
}
TabletSeatInterface::~TabletSeatInterface() = default;
TabletSeatV2Interface::~TabletSeatV2Interface() = default;
TabletToolInterface *TabletSeatInterface::addTool(TabletToolInterface::Type type,
quint64 hardwareSerial,
quint64 hardwareId,
const QVector<TabletToolInterface::Capability> &capabilities)
TabletToolV2Interface *TabletSeatV2Interface::addTool(TabletToolV2Interface::Type type,
quint64 hardwareSerial,
quint64 hardwareId,
const QVector<TabletToolV2Interface::Capability> &capabilities)
{
constexpr auto MAX_UINT_32 = std::numeric_limits<quint32>::max();
auto tool = new TabletToolInterface(d->m_display,
type, hardwareSerial >> 32, hardwareSerial & MAX_UINT_32,
hardwareId >> 32, hardwareId & MAX_UINT_32, capabilities, this);
auto tool = new TabletToolV2Interface(d->m_display,
type, hardwareSerial >> 32, hardwareSerial & MAX_UINT_32,
hardwareId >> 32, hardwareId & MAX_UINT_32, capabilities, this);
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) {
auto tti = static_cast<TabletToolInterface *>(object);
auto tti = static_cast<TabletToolV2Interface *>(object);
tti->d->send_removed();
d->m_tools.removeAll(tti);
});
return tool;
}
TabletInterface *TabletSeatInterface::addTablet(uint32_t vendorId, uint32_t productId,
const QString &sysname,
const QString &name,
const QStringList &paths)
TabletV2Interface *TabletSeatV2Interface::addTablet(uint32_t vendorId, uint32_t productId,
const QString &sysname,
const QString &name,
const QStringList &paths)
{
auto iface = new TabletInterface(vendorId, productId, name, paths, this);
auto iface = new TabletV2Interface(vendorId, productId, name, paths, this);
for (QtWaylandServer::zwp_tablet_seat_v2::Resource *r : d->resourceMap()) {
d->sendTabletAdded(r, iface);
......@@ -428,7 +428,7 @@ TabletInterface *TabletSeatInterface::addTablet(uint32_t vendorId, uint32_t prod
return iface;
}
void TabletSeatInterface::removeTablet(const QString &sysname)
void TabletSeatV2Interface::removeTablet(const QString &sysname)
{
auto tablet = d->m_tablets.take(sysname);
if (tablet) {
......@@ -436,33 +436,33 @@ void TabletSeatInterface::removeTablet(const QString &sysname)
}
}
TabletToolInterface *TabletSeatInterface::toolByHardwareId(quint64 hardwareId) const
TabletToolV2Interface *TabletSeatV2Interface::toolByHardwareId(quint64 hardwareId) const
{
for (TabletToolInterface *tool : d->m_tools) {
for (TabletToolV2Interface *tool : d->m_tools) {
if (tool->d->hardwareId() == hardwareId)
return tool;
}
return nullptr;
}
TabletToolInterface *TabletSeatInterface::toolByHardwareSerial(quint64 hardwareSerial) const
TabletToolV2Interface *TabletSeatV2Interface::toolByHardwareSerial(quint64 hardwareSerial) const
{
for (TabletToolInterface *tool : d->m_tools) {
for (TabletToolV2Interface *tool : d->m_tools) {
if (tool->d->hardwareSerial() == hardwareSerial)
return tool;
}
return nullptr;
}
TabletInterface *TabletSeatInterface::tabletByName(const QString &name) const
TabletV2Interface *TabletSeatV2Interface::tabletByName(const QString &name) const
{
return d->m_tablets.value(name);
}
class TabletManagerInterface::Private : public QtWaylandServer::zwp_tablet_manager_v2
class TabletManagerV2Interface::Private : public QtWaylandServer::zwp_tablet_manager_v2
{
public:
Private(Display *display, TabletManagerInterface *q)
Private(Display *display, TabletManagerV2Interface *q)
: zwp_tablet_manager_v2(*display, s_version)
, q(q)
, m_display(display)
......@@ -472,33 +472,33 @@ public:
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);
TabletSeatInterface *tsi = get(seat);
TabletSeatV2Interface *tsi = get(seat);
tsi->d->add(resource->client(), tablet_seat, s_version);
}
TabletSeatInterface *get(SeatInterface *seat)
TabletSeatV2Interface *get(SeatInterface *seat)
{
TabletSeatInterface *&tabletSeat = m_seats[seat];
TabletSeatV2Interface *&tabletSeat = m_seats[seat];
if (!tabletSeat) {
tabletSeat = new TabletSeatInterface(m_display, q);
tabletSeat = new TabletSeatV2Interface(m_display, q);
}
return tabletSeat;
}
TabletManagerInterface *const q;
TabletManagerV2Interface *const q;
Display *const m_display;
QHash<SeatInterface *, TabletSeatInterface *> m_seats;
QHash<SeatInterface *, TabletSeatV2Interface *> m_seats;
};
TabletManagerInterface::TabletManagerInterface(Display *display, QObject *parent)
TabletManagerV2Interface::TabletManagerV2Interface(Display *display, QObject *parent)
: QObject(parent)
, d(new Private(display, this))
{
}
TabletSeatInterface *TabletManagerInterface::seat(SeatInterface *seat) const
TabletSeatV2Interface *TabletManagerV2Interface::seat(SeatInterface *seat) const
{
return d->get(seat);
}
TabletManagerInterface::~TabletManagerInterface() = default;
TabletManagerV2Interface::~TabletManagerV2Interface() = default;
......@@ -27,12 +27,12 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
namespace KWaylandServer
{
class TabletSeatInterface;
class TabletSeatV2Interface;
class Display;
class SeatInterface;
class SurfaceInterface;
class TabletInterface;
class TabletCursor;
class TabletV2Interface;
class TabletCursorV2;
/**
* This is an implementation of wayland-protocols/unstable/tablet/tablet-unstable-v2.xml
......@@ -43,26 +43,26 @@ class TabletCursor;
* @since 5.69
*/
class KWAYLANDSERVER_EXPORT TabletManagerInterface : public QObject
class KWAYLANDSERVER_EXPORT TabletManagerV2Interface : public QObject
{
Q_OBJECT
public: