Port relative-pointer-v1 interface to the new design
This commit is contained in:
parent
9bf4b6b624
commit
a7f7a5fb17
14 changed files with 205 additions and 393 deletions
|
@ -46,8 +46,7 @@ set(SERVER_LIB_SRCS
|
|||
primaryselectionoffer_v1_interface.cpp
|
||||
primaryselectionsource_v1_interface.cpp
|
||||
region_interface.cpp
|
||||
relativepointer_interface.cpp
|
||||
relativepointer_interface_v1.cpp
|
||||
relativepointer_v1_interface.cpp
|
||||
resource.cpp
|
||||
screencast_v1_interface.cpp
|
||||
seat_interface.cpp
|
||||
|
@ -142,9 +141,9 @@ ecm_add_qtwayland_server_protocol(SERVER_LIB_SRCS
|
|||
BASENAME contrast
|
||||
)
|
||||
|
||||
ecm_add_wayland_server_protocol(SERVER_LIB_SRCS
|
||||
ecm_add_qtwayland_server_protocol(SERVER_LIB_SRCS
|
||||
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/relative-pointer/relative-pointer-unstable-v1.xml
|
||||
BASENAME relativepointer-unstable-v1
|
||||
BASENAME relative-pointer-unstable-v1
|
||||
)
|
||||
|
||||
ecm_add_wayland_server_protocol(SERVER_LIB_SRCS
|
||||
|
@ -415,7 +414,7 @@ set(SERVER_LIB_HEADERS
|
|||
pointergestures_interface.h
|
||||
primaryselectiondevicemanager_v1_interface.h
|
||||
region_interface.h
|
||||
relativepointer_interface.h
|
||||
relativepointer_v1_interface.h
|
||||
resource.h
|
||||
screencast_v1_interface.h
|
||||
seat_interface.h
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include "../../src/server/keyboard_interface.h"
|
||||
#include "../../src/server/pointer_interface.h"
|
||||
#include "../../src/server/pointergestures_interface.h"
|
||||
#include "../../src/server/relativepointer_interface.h"
|
||||
#include "../../src/server/relativepointer_v1_interface.h"
|
||||
#include "../../src/server/seat_interface.h"
|
||||
#include "../../src/server/subcompositor_interface.h"
|
||||
#include "../../src/server/surface_interface.h"
|
||||
|
@ -83,7 +83,7 @@ private:
|
|||
KWaylandServer::CompositorInterface *m_compositorInterface;
|
||||
KWaylandServer::SeatInterface *m_seatInterface;
|
||||
KWaylandServer::SubCompositorInterface *m_subCompositorInterface;
|
||||
KWaylandServer::RelativePointerManagerInterface *m_relativePointerManagerInterface;
|
||||
KWaylandServer::RelativePointerManagerV1Interface *m_relativePointerManagerV1Interface;
|
||||
KWaylandServer::PointerGesturesInterface *m_pointerGesturesInterface;
|
||||
KWayland::Client::ConnectionThread *m_connection;
|
||||
KWayland::Client::Compositor *m_compositor;
|
||||
|
@ -104,7 +104,7 @@ TestWaylandSeat::TestWaylandSeat(QObject *parent)
|
|||
, m_compositorInterface(nullptr)
|
||||
, m_seatInterface(nullptr)
|
||||
, m_subCompositorInterface(nullptr)
|
||||
, m_relativePointerManagerInterface(nullptr)
|
||||
, m_relativePointerManagerV1Interface(nullptr)
|
||||
, m_pointerGesturesInterface(nullptr)
|
||||
, m_connection(nullptr)
|
||||
, m_compositor(nullptr)
|
||||
|
@ -132,11 +132,7 @@ void TestWaylandSeat::init()
|
|||
m_subCompositorInterface = m_display->createSubCompositor(m_display);
|
||||
QVERIFY(m_subCompositorInterface);
|
||||
|
||||
m_relativePointerManagerInterface = m_display->createRelativePointerManager(RelativePointerInterfaceVersion::UnstableV1, m_display);
|
||||
QVERIFY(m_relativePointerManagerInterface);
|
||||
m_relativePointerManagerInterface->create();
|
||||
QVERIFY(m_relativePointerManagerInterface->isValid());
|
||||
|
||||
m_relativePointerManagerV1Interface = m_display->createRelativePointerManagerV1(m_display);
|
||||
m_pointerGesturesInterface = m_display->createPointerGestures(PointerGesturesInterfaceVersion::UnstableV1, m_display);
|
||||
QVERIFY(m_pointerGesturesInterface);
|
||||
m_pointerGesturesInterface->create();
|
||||
|
@ -252,8 +248,8 @@ void TestWaylandSeat::cleanup()
|
|||
delete m_subCompositorInterface;
|
||||
m_subCompositorInterface = nullptr;
|
||||
|
||||
delete m_relativePointerManagerInterface;
|
||||
m_relativePointerManagerInterface = nullptr;
|
||||
delete m_relativePointerManagerV1Interface;
|
||||
m_relativePointerManagerV1Interface = nullptr;
|
||||
|
||||
delete m_pointerGesturesInterface;
|
||||
m_pointerGesturesInterface = nullptr;
|
||||
|
@ -1740,7 +1736,7 @@ void TestWaylandSeat::testDestroy()
|
|||
m_compositorInterface = nullptr;
|
||||
m_seatInterface = nullptr;
|
||||
m_subCompositorInterface = nullptr;
|
||||
m_relativePointerManagerInterface = nullptr;
|
||||
m_relativePointerManagerV1Interface = nullptr;
|
||||
m_pointerGesturesInterface = nullptr;
|
||||
QVERIFY(connectionDiedSpy.wait());
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include "pointerconstraints_interface_p.h"
|
||||
#include "pointergestures_interface_p.h"
|
||||
#include "primaryselectiondevicemanager_v1_interface.h"
|
||||
#include "relativepointer_interface_p.h"
|
||||
#include "relativepointer_v1_interface.h"
|
||||
#include "seat_interface.h"
|
||||
#include "screencast_v1_interface.h"
|
||||
#include "server_decoration_interface.h"
|
||||
|
@ -366,14 +366,9 @@ XdgShellInterface *Display::createXdgShell(QObject *parent)
|
|||
return shell;
|
||||
}
|
||||
|
||||
RelativePointerManagerInterface *Display::createRelativePointerManager(const RelativePointerInterfaceVersion &version, QObject *parent)
|
||||
RelativePointerManagerV1Interface *Display::createRelativePointerManagerV1(QObject *parent)
|
||||
{
|
||||
RelativePointerManagerInterface *r = nullptr;
|
||||
switch (version) {
|
||||
case RelativePointerInterfaceVersion::UnstableV1:
|
||||
r = new RelativePointerManagerUnstableV1Interface(this, parent);
|
||||
break;
|
||||
}
|
||||
RelativePointerManagerV1Interface *r = new RelativePointerManagerV1Interface(this, parent);
|
||||
connect(this, &Display::aboutToTerminate, r, [r] { delete r; });
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -57,8 +57,7 @@ class SubCompositorInterface;
|
|||
class TextInputManagerV2Interface;
|
||||
class TextInputManagerV3Interface;
|
||||
class XdgShellInterface;
|
||||
enum class RelativePointerInterfaceVersion;
|
||||
class RelativePointerManagerInterface;
|
||||
class RelativePointerManagerV1Interface;
|
||||
enum class PointerGesturesInterfaceVersion;
|
||||
class PointerGesturesInterface;
|
||||
enum class PointerConstraintsInterfaceVersion;
|
||||
|
@ -214,12 +213,12 @@ public:
|
|||
XdgShellInterface *createXdgShell(QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* Creates the RelativePointerManagerInterface in interface @p version
|
||||
* Creates the RelativePointerManagerV1Interface
|
||||
*
|
||||
* @returns The created manager object
|
||||
* @since 5.28
|
||||
**/
|
||||
RelativePointerManagerInterface *createRelativePointerManager(const RelativePointerInterfaceVersion &version, QObject *parent = nullptr);
|
||||
RelativePointerManagerV1Interface *createRelativePointerManagerV1(QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* Creates the PointerGesturesInterface in interface @p version
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "pointerconstraints_interface.h"
|
||||
#include "pointergestures_interface_p.h"
|
||||
#include "resource_p.h"
|
||||
#include "relativepointer_interface_p.h"
|
||||
#include "relativepointer_v1_interface_p.h"
|
||||
#include "seat_interface.h"
|
||||
#include "display.h"
|
||||
#include "subcompositor_interface.h"
|
||||
|
@ -64,16 +64,17 @@ void PointerInterface::Private::sendLeave(SurfaceInterface *surface, quint32 ser
|
|||
}
|
||||
}
|
||||
|
||||
void PointerInterface::Private::registerRelativePointer(RelativePointerInterface *relativePointer)
|
||||
void PointerInterface::Private::registerRelativePointerV1(RelativePointerV1Interface *relativePointer)
|
||||
{
|
||||
relativePointers << relativePointer;
|
||||
QObject::connect(relativePointer, &QObject::destroyed, q,
|
||||
[this, relativePointer] {
|
||||
relativePointers.removeOne(relativePointer);
|
||||
}
|
||||
);
|
||||
Q_ASSERT(!relativePointersV1.contains(relativePointer));
|
||||
relativePointersV1.append(relativePointer);
|
||||
}
|
||||
|
||||
void PointerInterface::Private::unregisterRelativePointerV1(RelativePointerV1Interface *relativePointer)
|
||||
{
|
||||
Q_ASSERT(relativePointersV1.contains(relativePointer));
|
||||
relativePointersV1.removeOne(relativePointer);
|
||||
}
|
||||
|
||||
void PointerInterface::Private::registerSwipeGesture(PointerSwipeGestureInterface *gesture)
|
||||
{
|
||||
|
@ -383,11 +384,15 @@ Cursor *PointerInterface::cursor() const
|
|||
void PointerInterface::relativeMotion(const QSizeF &delta, const QSizeF &deltaNonAccelerated, quint64 microseconds)
|
||||
{
|
||||
Q_D();
|
||||
if (d->relativePointers.isEmpty()) {
|
||||
if (d->relativePointersV1.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (auto it = d->relativePointers.constBegin(), end = d->relativePointers.constEnd(); it != end; it++) {
|
||||
(*it)->relativeMotion(delta, deltaNonAccelerated, microseconds);
|
||||
for (RelativePointerV1Interface *relativePointer : qAsConst(d->relativePointersV1)) {
|
||||
relativePointer->send_relative_motion(microseconds >> 32, microseconds & 0xffffffff,
|
||||
wl_fixed_from_double(delta.width()),
|
||||
wl_fixed_from_double(delta.height()),
|
||||
wl_fixed_from_double(deltaNonAccelerated.width()),
|
||||
wl_fixed_from_double(deltaNonAccelerated.height()));
|
||||
}
|
||||
d->sendFrame();
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ namespace KWaylandServer
|
|||
|
||||
class Cursor;
|
||||
class PointerGesturesUnstableV1Interface;
|
||||
class RelativePointerManagerUnstableV1Interface;
|
||||
class SeatInterface;
|
||||
class SurfaceInterface;
|
||||
|
||||
|
@ -63,7 +62,7 @@ private:
|
|||
void axis(Qt::Orientation orientation, quint32 delta);
|
||||
void relativeMotion(const QSizeF &delta, const QSizeF &deltaNonAccelerated, quint64 microseconds);
|
||||
friend class SeatInterface;
|
||||
friend class RelativePointerManagerUnstableV1Interface;
|
||||
friend class RelativePointerV1Interface;
|
||||
friend class PointerGesturesUnstableV1Interface;
|
||||
explicit PointerInterface(SeatInterface *parent, wl_resource *parentResource);
|
||||
class Private;
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace KWaylandServer
|
|||
{
|
||||
class PointerPinchGestureInterface;
|
||||
class PointerSwipeGestureInterface;
|
||||
class RelativePointerInterface;
|
||||
class RelativePointerV1Interface;
|
||||
|
||||
class PointerInterface::Private : public Resource::Private
|
||||
{
|
||||
|
@ -27,7 +27,7 @@ public:
|
|||
QPointer<SurfaceInterface> focusedChildSurface;
|
||||
QMetaObject::Connection destroyConnection;
|
||||
Cursor *cursor = nullptr;
|
||||
QVector<RelativePointerInterface*> relativePointers;
|
||||
QVector<RelativePointerV1Interface *> relativePointersV1;
|
||||
QVector<PointerSwipeGestureInterface*> swipeGestures;
|
||||
QVector<PointerPinchGestureInterface*> pinchGestures;
|
||||
|
||||
|
@ -35,10 +35,12 @@ public:
|
|||
void sendEnter(SurfaceInterface *surface, const QPointF &parentSurfacePosition, quint32 serial);
|
||||
void sendFrame();
|
||||
|
||||
void registerRelativePointer(RelativePointerInterface *relativePointer);
|
||||
void registerRelativePointerV1(RelativePointerV1Interface *relativePointer);
|
||||
void registerSwipeGesture(PointerSwipeGestureInterface *gesture);
|
||||
void registerPinchGesture(PointerPinchGestureInterface *gesture);
|
||||
|
||||
void unregisterRelativePointerV1(RelativePointerV1Interface *relativePointer);
|
||||
|
||||
void startSwipeGesture(quint32 serial, quint32 fingerCount);
|
||||
void updateSwipeGesture(const QSizeF &delta);
|
||||
void endSwipeGesture(quint32 serial);
|
||||
|
|
83
src/wayland/relativepointer_v1_interface.cpp
Normal file
83
src/wayland/relativepointer_v1_interface.cpp
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
|
||||
SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||
*/
|
||||
|
||||
#include "relativepointer_v1_interface.h"
|
||||
#include "display.h"
|
||||
#include "pointer_interface_p.h"
|
||||
#include "relativepointer_v1_interface_p.h"
|
||||
|
||||
namespace KWaylandServer
|
||||
{
|
||||
|
||||
static const int s_version = 1;
|
||||
|
||||
RelativePointerManagerV1InterfacePrivate::RelativePointerManagerV1InterfacePrivate(Display *display)
|
||||
: QtWaylandServer::zwp_relative_pointer_manager_v1(*display, s_version)
|
||||
{
|
||||
}
|
||||
|
||||
void RelativePointerManagerV1InterfacePrivate::zwp_relative_pointer_manager_v1_destroy(Resource *resource)
|
||||
{
|
||||
wl_resource_destroy(resource->handle);
|
||||
}
|
||||
|
||||
void RelativePointerManagerV1InterfacePrivate::zwp_relative_pointer_manager_v1_get_relative_pointer(Resource *resource, uint32_t id, struct ::wl_resource *pointer_resource)
|
||||
{
|
||||
PointerInterface *pointer = PointerInterface::get(pointer_resource);
|
||||
if (!pointer) {
|
||||
wl_resource_post_error(resource->handle, WL_DISPLAY_ERROR_INVALID_OBJECT,
|
||||
"invalid pointer");
|
||||
return;
|
||||
}
|
||||
|
||||
wl_resource *relativePointerResource = wl_resource_create(resource->client(),
|
||||
&zwp_relative_pointer_v1_interface,
|
||||
resource->version(), id);
|
||||
if (!relativePointerResource) {
|
||||
wl_resource_post_no_memory(resource->handle);
|
||||
return;
|
||||
}
|
||||
|
||||
new RelativePointerV1Interface(pointer, relativePointerResource);
|
||||
}
|
||||
|
||||
RelativePointerManagerV1Interface::RelativePointerManagerV1Interface(Display *display, QObject *parent)
|
||||
: QObject(parent)
|
||||
, d(new RelativePointerManagerV1InterfacePrivate(display))
|
||||
{
|
||||
}
|
||||
|
||||
RelativePointerManagerV1Interface::~RelativePointerManagerV1Interface()
|
||||
{
|
||||
}
|
||||
|
||||
RelativePointerV1Interface::RelativePointerV1Interface(PointerInterface *pointer, ::wl_resource *resource)
|
||||
: QtWaylandServer::zwp_relative_pointer_v1(resource)
|
||||
, pointer(pointer)
|
||||
{
|
||||
pointer->d_func()->registerRelativePointerV1(this);
|
||||
}
|
||||
|
||||
RelativePointerV1Interface::~RelativePointerV1Interface()
|
||||
{
|
||||
if (pointer) {
|
||||
pointer->d_func()->unregisterRelativePointerV1(this);
|
||||
}
|
||||
}
|
||||
|
||||
void RelativePointerV1Interface::zwp_relative_pointer_v1_destroy_resource(Resource *resource)
|
||||
{
|
||||
Q_UNUSED(resource)
|
||||
delete this;
|
||||
}
|
||||
|
||||
void RelativePointerV1Interface::zwp_relative_pointer_v1_destroy(Resource *resource)
|
||||
{
|
||||
wl_resource_destroy(resource->handle);
|
||||
}
|
||||
|
||||
} // namespace KWaylandServer
|
39
src/wayland/relativepointer_v1_interface.h
Normal file
39
src/wayland/relativepointer_v1_interface.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
|
||||
SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <KWaylandServer/kwaylandserver_export.h>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace KWaylandServer
|
||||
{
|
||||
|
||||
class Display;
|
||||
class RelativePointerManagerV1InterfacePrivate;
|
||||
|
||||
/**
|
||||
* Manager object to create relative pointer interfaces.
|
||||
*
|
||||
* Once created the interaction happens through the SeatInterface class
|
||||
* which automatically delegates relative motion events to the created relative pointer
|
||||
* interfaces.
|
||||
*/
|
||||
class KWAYLANDSERVER_EXPORT RelativePointerManagerV1Interface : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RelativePointerManagerV1Interface(Display *display, QObject *parent = nullptr);
|
||||
~RelativePointerManagerV1Interface() override;
|
||||
|
||||
private:
|
||||
QScopedPointer<RelativePointerManagerV1InterfacePrivate> d;
|
||||
};
|
||||
|
||||
} // namespace KWaylandServer
|
44
src/wayland/relativepointer_v1_interface_p.h
Normal file
44
src/wayland/relativepointer_v1_interface_p.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
|
||||
SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "qwayland-server-relative-pointer-unstable-v1.h"
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
namespace KWaylandServer
|
||||
{
|
||||
|
||||
class Display;
|
||||
class PointerInterface;
|
||||
|
||||
class RelativePointerManagerV1InterfacePrivate : public QtWaylandServer::zwp_relative_pointer_manager_v1
|
||||
{
|
||||
public:
|
||||
explicit RelativePointerManagerV1InterfacePrivate(Display *display);
|
||||
|
||||
protected:
|
||||
void zwp_relative_pointer_manager_v1_destroy(Resource *resource) override;
|
||||
void zwp_relative_pointer_manager_v1_get_relative_pointer(Resource *resource, uint32_t id,
|
||||
struct ::wl_resource *pointer_resource) override;
|
||||
};
|
||||
|
||||
class RelativePointerV1Interface : public QtWaylandServer::zwp_relative_pointer_v1
|
||||
{
|
||||
public:
|
||||
RelativePointerV1Interface(PointerInterface *pointer, ::wl_resource *resource);
|
||||
~RelativePointerV1Interface() override;
|
||||
|
||||
QPointer<PointerInterface> pointer;
|
||||
|
||||
protected:
|
||||
void zwp_relative_pointer_v1_destroy_resource(Resource *resource) override;
|
||||
void zwp_relative_pointer_v1_destroy(Resource *resource) override;
|
||||
};
|
||||
|
||||
} // namespace KWaylandServer
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||
*/
|
||||
#include "relativepointer_interface_p.h"
|
||||
|
||||
namespace KWaylandServer
|
||||
{
|
||||
|
||||
RelativePointerManagerInterface::Private::Private(RelativePointerInterfaceVersion interfaceVersion, RelativePointerManagerInterface *q, Display *d, const wl_interface *interface, quint32 version)
|
||||
: Global::Private(d, interface, version)
|
||||
, interfaceVersion(interfaceVersion)
|
||||
, q(q)
|
||||
{
|
||||
}
|
||||
|
||||
RelativePointerManagerInterface::RelativePointerManagerInterface(Private *d, QObject *parent)
|
||||
: Global(d, parent)
|
||||
{
|
||||
}
|
||||
|
||||
RelativePointerManagerInterface::~RelativePointerManagerInterface() = default;
|
||||
|
||||
RelativePointerInterfaceVersion RelativePointerManagerInterface::interfaceVersion() const
|
||||
{
|
||||
Q_D();
|
||||
return d->interfaceVersion;
|
||||
}
|
||||
|
||||
RelativePointerManagerInterface::Private *RelativePointerManagerInterface::d_func() const
|
||||
{
|
||||
return reinterpret_cast<Private*>(d.data());
|
||||
}
|
||||
|
||||
RelativePointerInterface::Private::Private(RelativePointerInterface *q, Global *c, wl_resource *parentResource, const wl_interface *interface, const void *implementation)
|
||||
: Resource::Private(q, c, parentResource, interface, implementation)
|
||||
{
|
||||
}
|
||||
|
||||
RelativePointerInterface::Private::~Private()
|
||||
{
|
||||
if (resource) {
|
||||
wl_resource_destroy(resource);
|
||||
resource = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
RelativePointerInterface::RelativePointerInterface(Private *p, QObject *parent)
|
||||
: Resource(p, parent)
|
||||
{
|
||||
}
|
||||
|
||||
RelativePointerInterface::~RelativePointerInterface() = default;
|
||||
|
||||
void RelativePointerInterface::relativeMotion(const QSizeF &delta, const QSizeF &deltaNonAccelerated, quint64 microseconds)
|
||||
{
|
||||
Q_D();
|
||||
d->relativeMotion(delta, deltaNonAccelerated, microseconds);
|
||||
}
|
||||
|
||||
RelativePointerInterface::Private *RelativePointerInterface::d_func() const
|
||||
{
|
||||
return reinterpret_cast<Private*>(d.data());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||
*/
|
||||
#ifndef KWAYLAND_SERVER_RELATIVE_POINTER_INTERFACE_H
|
||||
#define KWAYLAND_SERVER_RELATIVE_POINTER_INTERFACE_H
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include <KWaylandServer/kwaylandserver_export.h>
|
||||
|
||||
namespace KWaylandServer
|
||||
{
|
||||
|
||||
class Display;
|
||||
|
||||
enum class RelativePointerInterfaceVersion {
|
||||
/**
|
||||
* zwp_relative_pointer_manager_v1 and zwp_relative_pointer_v1
|
||||
**/
|
||||
UnstableV1
|
||||
};
|
||||
|
||||
/**
|
||||
* Manager object to create relative pointer interfaces.
|
||||
*
|
||||
* Once created the interaction happens through the SeatInterface class
|
||||
* which automatically delegates relative motion events to the created relative pointer
|
||||
* interfaces.
|
||||
*
|
||||
* @see SeatInterface::relativePointerMotion
|
||||
* @since 5.28
|
||||
**/
|
||||
class KWAYLANDSERVER_EXPORT RelativePointerManagerInterface : public Global
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
virtual ~RelativePointerManagerInterface();
|
||||
|
||||
/**
|
||||
* @returns The interface version used by this RelativePointerManagerInterface
|
||||
**/
|
||||
RelativePointerInterfaceVersion interfaceVersion() const;
|
||||
|
||||
protected:
|
||||
class Private;
|
||||
explicit RelativePointerManagerInterface(Private *d, QObject *parent = nullptr);
|
||||
|
||||
private:
|
||||
Private *d_func() const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||
*/
|
||||
#ifndef KWAYLAND_SERVER_RELATIVEPOINTER_INTERFACE_P_H
|
||||
#define KWAYLAND_SERVER_RELATIVEPOINTER_INTERFACE_P_H
|
||||
#include "relativepointer_interface.h"
|
||||
#include "resource_p.h"
|
||||
#include "global_p.h"
|
||||
|
||||
|
||||
namespace KWaylandServer
|
||||
{
|
||||
|
||||
class RelativePointerManagerInterface::Private : public Global::Private
|
||||
{
|
||||
public:
|
||||
RelativePointerInterfaceVersion interfaceVersion;
|
||||
|
||||
protected:
|
||||
Private(RelativePointerInterfaceVersion interfaceVersion, RelativePointerManagerInterface *q, Display *d, const wl_interface *interface, quint32 version);
|
||||
RelativePointerManagerInterface *q;
|
||||
};
|
||||
|
||||
class RelativePointerManagerUnstableV1Interface : public RelativePointerManagerInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit RelativePointerManagerUnstableV1Interface(Display *display, QObject *parent = nullptr);
|
||||
virtual ~RelativePointerManagerUnstableV1Interface();
|
||||
|
||||
private:
|
||||
class Private;
|
||||
};
|
||||
|
||||
class RelativePointerInterface : public Resource
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
virtual ~RelativePointerInterface();
|
||||
void relativeMotion(const QSizeF &delta, const QSizeF &deltaNonAccelerated, quint64 microseconds);
|
||||
|
||||
protected:
|
||||
class Private;
|
||||
explicit RelativePointerInterface(Private *p, QObject *parent = nullptr);
|
||||
|
||||
private:
|
||||
Private *d_func() const;
|
||||
};
|
||||
|
||||
class RelativePointerInterface::Private : public Resource::Private
|
||||
{
|
||||
public:
|
||||
~Private();
|
||||
virtual void relativeMotion(const QSizeF &delta, const QSizeF &deltaNonAccelerated, quint64 microseconds) = 0;
|
||||
|
||||
protected:
|
||||
Private(RelativePointerInterface *q, Global *c, wl_resource *parentResource, const wl_interface *interface, const void *implementation);
|
||||
|
||||
private:
|
||||
RelativePointerInterface *q_func() {
|
||||
return reinterpret_cast<RelativePointerInterface *>(q);
|
||||
}
|
||||
};
|
||||
|
||||
class RelativePointerUnstableV1Interface : public RelativePointerInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
virtual ~RelativePointerUnstableV1Interface();
|
||||
|
||||
private:
|
||||
explicit RelativePointerUnstableV1Interface(RelativePointerManagerUnstableV1Interface *parent, wl_resource *parentResource);
|
||||
friend class RelativePointerManagerUnstableV1Interface;
|
||||
|
||||
class Private;
|
||||
Private *d_func() const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,143 +0,0 @@
|
|||
/*
|
||||
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||
*/
|
||||
#include "relativepointer_interface_p.h"
|
||||
#include "display.h"
|
||||
#include "pointer_interface_p.h"
|
||||
#include <wayland-relativepointer-unstable-v1-server-protocol.h>
|
||||
#include <QSizeF>
|
||||
|
||||
namespace KWaylandServer
|
||||
{
|
||||
|
||||
class RelativePointerManagerUnstableV1Interface::Private : public RelativePointerManagerInterface::Private
|
||||
{
|
||||
public:
|
||||
Private(RelativePointerManagerUnstableV1Interface *q, Display *d);
|
||||
|
||||
private:
|
||||
void bind(wl_client *client, uint32_t version, uint32_t id) override;
|
||||
|
||||
static void unbind(wl_resource *resource);
|
||||
static Private *cast(wl_resource *r) {
|
||||
return reinterpret_cast<Private*>(wl_resource_get_user_data(r));
|
||||
}
|
||||
|
||||
static void destroyCallback(wl_client *client, wl_resource *resource);
|
||||
static void getRelativePointerCallback(wl_client *client, wl_resource *resource, uint32_t id, wl_resource * pointer);
|
||||
|
||||
RelativePointerManagerUnstableV1Interface *q;
|
||||
|
||||
static const struct zwp_relative_pointer_manager_v1_interface s_interface;
|
||||
static const quint32 s_version;
|
||||
};
|
||||
|
||||
const quint32 RelativePointerManagerUnstableV1Interface::Private::s_version = 1;
|
||||
|
||||
#ifndef K_DOXYGEN
|
||||
const struct zwp_relative_pointer_manager_v1_interface RelativePointerManagerUnstableV1Interface::Private::s_interface = {
|
||||
destroyCallback,
|
||||
getRelativePointerCallback
|
||||
};
|
||||
#endif
|
||||
|
||||
void RelativePointerManagerUnstableV1Interface::Private::destroyCallback(wl_client *client, wl_resource *resource)
|
||||
{
|
||||
Q_UNUSED(client)
|
||||
wl_resource_destroy(resource);
|
||||
}
|
||||
|
||||
void RelativePointerManagerUnstableV1Interface::Private::getRelativePointerCallback(wl_client *client, wl_resource *resource, uint32_t id, wl_resource *pointer)
|
||||
{
|
||||
PointerInterface *p = PointerInterface::get(pointer);
|
||||
if (!p) {
|
||||
// TODO: raise error?
|
||||
return;
|
||||
}
|
||||
auto m = cast(resource);
|
||||
auto *r = new RelativePointerUnstableV1Interface(m->q, resource);
|
||||
r->d->create(m->display->getConnection(client), version, id);
|
||||
p->d_func()->registerRelativePointer(r);
|
||||
}
|
||||
|
||||
RelativePointerManagerUnstableV1Interface::Private::Private(RelativePointerManagerUnstableV1Interface *q, Display *d)
|
||||
: RelativePointerManagerInterface::Private(RelativePointerInterfaceVersion::UnstableV1, q, d, &zwp_relative_pointer_manager_v1_interface, s_version)
|
||||
, q(q)
|
||||
{
|
||||
}
|
||||
|
||||
void RelativePointerManagerUnstableV1Interface::Private::bind(wl_client *client, uint32_t version, uint32_t id)
|
||||
{
|
||||
auto c = display->getConnection(client);
|
||||
wl_resource *resource = c->createResource(&zwp_relative_pointer_manager_v1_interface, qMin(version, s_version), id);
|
||||
if (!resource) {
|
||||
wl_client_post_no_memory(client);
|
||||
return;
|
||||
}
|
||||
wl_resource_set_implementation(resource, &s_interface, this, unbind);
|
||||
// TODO: should we track?
|
||||
}
|
||||
|
||||
void RelativePointerManagerUnstableV1Interface::Private::unbind(wl_resource *resource)
|
||||
{
|
||||
Q_UNUSED(resource)
|
||||
// TODO: implement?
|
||||
}
|
||||
|
||||
RelativePointerManagerUnstableV1Interface::RelativePointerManagerUnstableV1Interface(Display *display, QObject *parent)
|
||||
: RelativePointerManagerInterface(new Private(this, display), parent)
|
||||
{
|
||||
}
|
||||
|
||||
RelativePointerManagerUnstableV1Interface::~RelativePointerManagerUnstableV1Interface() = default;
|
||||
|
||||
class RelativePointerUnstableV1Interface::Private : public RelativePointerInterface::Private
|
||||
{
|
||||
public:
|
||||
Private(RelativePointerUnstableV1Interface *q, RelativePointerManagerUnstableV1Interface *c, wl_resource *parentResource);
|
||||
~Private();
|
||||
void relativeMotion(const QSizeF &delta, const QSizeF &deltaNonAccelerated, quint64 microseconds) override;
|
||||
|
||||
private:
|
||||
RelativePointerUnstableV1Interface *q_func() {
|
||||
return reinterpret_cast<RelativePointerUnstableV1Interface *>(q);
|
||||
}
|
||||
|
||||
static const struct zwp_relative_pointer_v1_interface s_interface;
|
||||
};
|
||||
|
||||
#ifndef K_DOXYGEN
|
||||
const struct zwp_relative_pointer_v1_interface RelativePointerUnstableV1Interface::Private::s_interface = {
|
||||
resourceDestroyedCallback
|
||||
};
|
||||
#endif
|
||||
|
||||
RelativePointerUnstableV1Interface::Private::Private(RelativePointerUnstableV1Interface *q, RelativePointerManagerUnstableV1Interface *c, wl_resource *parentResource)
|
||||
: RelativePointerInterface::Private(q, c, parentResource, &zwp_relative_pointer_v1_interface, &s_interface)
|
||||
{
|
||||
}
|
||||
|
||||
RelativePointerUnstableV1Interface::Private::~Private() = default;
|
||||
|
||||
void RelativePointerUnstableV1Interface::Private::relativeMotion(const QSizeF &delta, const QSizeF &deltaNonAccelerated, quint64 microseconds)
|
||||
{
|
||||
if (!resource) {
|
||||
return;
|
||||
}
|
||||
zwp_relative_pointer_v1_send_relative_motion(resource, (microseconds >> 32), microseconds,
|
||||
wl_fixed_from_double(delta.width()),
|
||||
wl_fixed_from_double(delta.height()),
|
||||
wl_fixed_from_double(deltaNonAccelerated.width()),
|
||||
wl_fixed_from_double(deltaNonAccelerated.height()));
|
||||
}
|
||||
|
||||
RelativePointerUnstableV1Interface::RelativePointerUnstableV1Interface(RelativePointerManagerUnstableV1Interface *parent, wl_resource *parentResource)
|
||||
: RelativePointerInterface(new Private(this, parent, parentResource))
|
||||
{
|
||||
}
|
||||
|
||||
RelativePointerUnstableV1Interface::~RelativePointerUnstableV1Interface() = default;
|
||||
|
||||
}
|
Loading…
Reference in a new issue