Commit 729601ba authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

Port pointer-constraints-v1 to the new design

parent 0265c55f
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
// server // server
#include "../../src/server/display.h" #include "../../src/server/display.h"
#include "../../src/server/compositor_interface.h" #include "../../src/server/compositor_interface.h"
#include "../../src/server/pointerconstraints_interface.h" #include "../../src/server/pointerconstraints_v1_interface.h"
#include "../../src/server/seat_interface.h" #include "../../src/server/seat_interface.h"
#include "../../src/server/surface_interface.h" #include "../../src/server/surface_interface.h"
...@@ -25,8 +25,8 @@ using namespace KWayland::Client; ...@@ -25,8 +25,8 @@ using namespace KWayland::Client;
using namespace KWaylandServer; using namespace KWaylandServer;
Q_DECLARE_METATYPE(KWayland::Client::PointerConstraints::LifeTime) Q_DECLARE_METATYPE(KWayland::Client::PointerConstraints::LifeTime)
Q_DECLARE_METATYPE(KWaylandServer::ConfinedPointerInterface::LifeTime) Q_DECLARE_METATYPE(KWaylandServer::ConfinedPointerV1Interface::LifeTime)
Q_DECLARE_METATYPE(KWaylandServer::LockedPointerInterface::LifeTime) Q_DECLARE_METATYPE(KWaylandServer::LockedPointerV1Interface::LifeTime)
class TestPointerConstraints : public QObject class TestPointerConstraints : public QObject
{ {
...@@ -47,7 +47,7 @@ private: ...@@ -47,7 +47,7 @@ private:
Display *m_display = nullptr; Display *m_display = nullptr;
CompositorInterface *m_compositorInterface = nullptr; CompositorInterface *m_compositorInterface = nullptr;
SeatInterface *m_seatInterface = nullptr; SeatInterface *m_seatInterface = nullptr;
PointerConstraintsInterface *m_pointerConstraintsInterface = nullptr; PointerConstraintsV1Interface *m_pointerConstraintsInterface = nullptr;
ConnectionThread *m_connection = nullptr; ConnectionThread *m_connection = nullptr;
QThread *m_thread = nullptr; QThread *m_thread = nullptr;
EventQueue *m_queue = nullptr; EventQueue *m_queue = nullptr;
...@@ -71,8 +71,7 @@ void TestPointerConstraints::init() ...@@ -71,8 +71,7 @@ void TestPointerConstraints::init()
m_seatInterface->setHasPointer(true); m_seatInterface->setHasPointer(true);
m_seatInterface->create(); m_seatInterface->create();
m_compositorInterface = m_display->createCompositor(m_display); m_compositorInterface = m_display->createCompositor(m_display);
m_pointerConstraintsInterface = m_display->createPointerConstraints(PointerConstraintsInterfaceVersion::UnstableV1, m_display); m_pointerConstraintsInterface = m_display->createPointerConstraintsV1(m_display);
m_pointerConstraintsInterface->create();
// setup connection // setup connection
m_connection = new KWayland::Client::ConnectionThread; m_connection = new KWayland::Client::ConnectionThread;
...@@ -153,12 +152,12 @@ void TestPointerConstraints::cleanup() ...@@ -153,12 +152,12 @@ void TestPointerConstraints::cleanup()
void TestPointerConstraints::testLockPointer_data() void TestPointerConstraints::testLockPointer_data()
{ {
QTest::addColumn<PointerConstraints::LifeTime>("clientLifeTime"); QTest::addColumn<PointerConstraints::LifeTime>("clientLifeTime");
QTest::addColumn<LockedPointerInterface::LifeTime>("serverLifeTime"); QTest::addColumn<LockedPointerV1Interface::LifeTime>("serverLifeTime");
QTest::addColumn<bool>("hasConstraintAfterUnlock"); QTest::addColumn<bool>("hasConstraintAfterUnlock");
QTest::addColumn<int>("pointerChangedCount"); QTest::addColumn<int>("pointerChangedCount");
QTest::newRow("persistent") << PointerConstraints::LifeTime::Persistent << LockedPointerInterface::LifeTime::Persistent << true << 1; QTest::newRow("persistent") << PointerConstraints::LifeTime::Persistent << LockedPointerV1Interface::LifeTime::Persistent << true << 1;
QTest::newRow("oneshot") << PointerConstraints::LifeTime::OneShot << LockedPointerInterface::LifeTime::OneShot << false << 2; QTest::newRow("oneshot") << PointerConstraints::LifeTime::OneShot << LockedPointerV1Interface::LifeTime::OneShot << false << 2;
} }
void TestPointerConstraints::testLockPointer() void TestPointerConstraints::testLockPointer()
...@@ -173,8 +172,8 @@ void TestPointerConstraints::testLockPointer() ...@@ -173,8 +172,8 @@ void TestPointerConstraints::testLockPointer()
auto serverSurface = surfaceCreatedSpy.first().first().value<SurfaceInterface*>(); auto serverSurface = surfaceCreatedSpy.first().first().value<SurfaceInterface*>();
QVERIFY(serverSurface); QVERIFY(serverSurface);
QVERIFY(serverSurface->lockedPointer().isNull()); QVERIFY(!serverSurface->lockedPointer());
QVERIFY(serverSurface->confinedPointer().isNull()); QVERIFY(!serverSurface->confinedPointer());
// now create the locked pointer // now create the locked pointer
QSignalSpy pointerConstraintsChangedSpy(serverSurface, &SurfaceInterface::pointerConstraintsChanged); QSignalSpy pointerConstraintsChangedSpy(serverSurface, &SurfaceInterface::pointerConstraintsChanged);
...@@ -190,20 +189,20 @@ void TestPointerConstraints::testLockPointer() ...@@ -190,20 +189,20 @@ void TestPointerConstraints::testLockPointer()
auto serverLockedPointer = serverSurface->lockedPointer(); auto serverLockedPointer = serverSurface->lockedPointer();
QVERIFY(serverLockedPointer); QVERIFY(serverLockedPointer);
QVERIFY(serverSurface->confinedPointer().isNull()); QVERIFY(!serverSurface->confinedPointer());
QCOMPARE(serverLockedPointer->isLocked(), false); QCOMPARE(serverLockedPointer->isLocked(), false);
QCOMPARE(serverLockedPointer->region(), QRegion()); QCOMPARE(serverLockedPointer->region(), QRegion());
QFETCH(LockedPointerInterface::LifeTime, serverLifeTime); QFETCH(LockedPointerV1Interface::LifeTime, serverLifeTime);
QCOMPARE(serverLockedPointer->lifeTime(), serverLifeTime); QCOMPARE(serverLockedPointer->lifeTime(), serverLifeTime);
// setting to unlocked now should not trigger an unlocked spy // setting to unlocked now should not trigger an unlocked spy
serverLockedPointer->setLocked(false); serverLockedPointer->setLocked(false);
QVERIFY(!unlockedSpy.wait(500)); QVERIFY(!unlockedSpy.wait(500));
// try setting a region // try setting a region
QSignalSpy destroyedSpy(serverLockedPointer.data(), &QObject::destroyed); QSignalSpy destroyedSpy(serverLockedPointer, &QObject::destroyed);
QVERIFY(destroyedSpy.isValid()); QVERIFY(destroyedSpy.isValid());
QSignalSpy regionChangedSpy(serverLockedPointer.data(), &LockedPointerInterface::regionChanged); QSignalSpy regionChangedSpy(serverLockedPointer, &LockedPointerV1Interface::regionChanged);
QVERIFY(regionChangedSpy.isValid()); QVERIFY(regionChangedSpy.isValid());
lockedPointer->setRegion(m_compositor->createRegion(QRegion(0, 5, 10, 20), m_compositor)); lockedPointer->setRegion(m_compositor->createRegion(QRegion(0, 5, 10, 20), m_compositor));
// it's double buffered // it's double buffered
...@@ -218,7 +217,7 @@ void TestPointerConstraints::testLockPointer() ...@@ -218,7 +217,7 @@ void TestPointerConstraints::testLockPointer()
QCOMPARE(serverLockedPointer->region(), QRegion()); QCOMPARE(serverLockedPointer->region(), QRegion());
// let's lock the surface // let's lock the surface
QSignalSpy lockedChangedSpy(serverLockedPointer.data(), &LockedPointerInterface::lockedChanged); QSignalSpy lockedChangedSpy(serverLockedPointer, &LockedPointerV1Interface::lockedChanged);
QVERIFY(lockedChangedSpy.isValid()); QVERIFY(lockedChangedSpy.isValid());
m_seatInterface->setFocusedPointerSurface(serverSurface); m_seatInterface->setFocusedPointerSurface(serverSurface);
QSignalSpy pointerMotionSpy(m_pointer, &Pointer::motion); QSignalSpy pointerMotionSpy(m_pointer, &Pointer::motion);
...@@ -236,7 +235,7 @@ void TestPointerConstraints::testLockPointer() ...@@ -236,7 +235,7 @@ void TestPointerConstraints::testLockPointer()
QVERIFY(unlockedSpy.isEmpty()); QVERIFY(unlockedSpy.isEmpty());
const QPointF hint = QPointF(1.5, 0.5); const QPointF hint = QPointF(1.5, 0.5);
QSignalSpy hintChangedSpy(serverLockedPointer.data(), &LockedPointerInterface::cursorPositionHintChanged); QSignalSpy hintChangedSpy(serverLockedPointer, &LockedPointerV1Interface::cursorPositionHintChanged);
lockedPointer->setCursorPositionHint(hint); lockedPointer->setCursorPositionHint(hint);
QCOMPARE(serverLockedPointer->cursorPositionHint(), QPointF(-1., -1.)); QCOMPARE(serverLockedPointer->cursorPositionHint(), QPointF(-1., -1.));
surface->commit(Surface::CommitFlag::None); surface->commit(Surface::CommitFlag::None);
...@@ -248,7 +247,7 @@ void TestPointerConstraints::testLockPointer() ...@@ -248,7 +247,7 @@ void TestPointerConstraints::testLockPointer()
QCOMPARE(serverLockedPointer->isLocked(), false); QCOMPARE(serverLockedPointer->isLocked(), false);
QCOMPARE(serverLockedPointer->cursorPositionHint(), QPointF(-1., -1.)); QCOMPARE(serverLockedPointer->cursorPositionHint(), QPointF(-1., -1.));
QCOMPARE(lockedChangedSpy.count(), 2); QCOMPARE(lockedChangedSpy.count(), 2);
QTEST(!serverSurface->lockedPointer().isNull(), "hasConstraintAfterUnlock"); QTEST(bool(serverSurface->lockedPointer()), "hasConstraintAfterUnlock");
QTEST(pointerConstraintsChangedSpy.count(), "pointerChangedCount"); QTEST(pointerConstraintsChangedSpy.count(), "pointerChangedCount");
QVERIFY(unlockedSpy.wait()); QVERIFY(unlockedSpy.wait());
QCOMPARE(unlockedSpy.count(), 1); QCOMPARE(unlockedSpy.count(), 1);
...@@ -267,12 +266,12 @@ void TestPointerConstraints::testLockPointer() ...@@ -267,12 +266,12 @@ void TestPointerConstraints::testLockPointer()
void TestPointerConstraints::testConfinePointer_data() void TestPointerConstraints::testConfinePointer_data()
{ {
QTest::addColumn<PointerConstraints::LifeTime>("clientLifeTime"); QTest::addColumn<PointerConstraints::LifeTime>("clientLifeTime");
QTest::addColumn<ConfinedPointerInterface::LifeTime>("serverLifeTime"); QTest::addColumn<ConfinedPointerV1Interface::LifeTime>("serverLifeTime");
QTest::addColumn<bool>("hasConstraintAfterUnlock"); QTest::addColumn<bool>("hasConstraintAfterUnlock");
QTest::addColumn<int>("pointerChangedCount"); QTest::addColumn<int>("pointerChangedCount");
QTest::newRow("persistent") << PointerConstraints::LifeTime::Persistent << ConfinedPointerInterface::LifeTime::Persistent << true << 1; QTest::newRow("persistent") << PointerConstraints::LifeTime::Persistent << ConfinedPointerV1Interface::LifeTime::Persistent << true << 1;
QTest::newRow("oneshot") << PointerConstraints::LifeTime::OneShot << ConfinedPointerInterface::LifeTime::OneShot << false << 2; QTest::newRow("oneshot") << PointerConstraints::LifeTime::OneShot << ConfinedPointerV1Interface::LifeTime::OneShot << false << 2;
} }
void TestPointerConstraints::testConfinePointer() void TestPointerConstraints::testConfinePointer()
...@@ -287,8 +286,8 @@ void TestPointerConstraints::testConfinePointer() ...@@ -287,8 +286,8 @@ void TestPointerConstraints::testConfinePointer()
auto serverSurface = surfaceCreatedSpy.first().first().value<SurfaceInterface*>(); auto serverSurface = surfaceCreatedSpy.first().first().value<SurfaceInterface*>();
QVERIFY(serverSurface); QVERIFY(serverSurface);
QVERIFY(serverSurface->lockedPointer().isNull()); QVERIFY(!serverSurface->lockedPointer());
QVERIFY(serverSurface->confinedPointer().isNull()); QVERIFY(!serverSurface->confinedPointer());
// now create the confined pointer // now create the confined pointer
QSignalSpy pointerConstraintsChangedSpy(serverSurface, &SurfaceInterface::pointerConstraintsChanged); QSignalSpy pointerConstraintsChangedSpy(serverSurface, &SurfaceInterface::pointerConstraintsChanged);
...@@ -304,20 +303,20 @@ void TestPointerConstraints::testConfinePointer() ...@@ -304,20 +303,20 @@ void TestPointerConstraints::testConfinePointer()
auto serverConfinedPointer = serverSurface->confinedPointer(); auto serverConfinedPointer = serverSurface->confinedPointer();
QVERIFY(serverConfinedPointer); QVERIFY(serverConfinedPointer);
QVERIFY(serverSurface->lockedPointer().isNull()); QVERIFY(!serverSurface->lockedPointer());
QCOMPARE(serverConfinedPointer->isConfined(), false); QCOMPARE(serverConfinedPointer->isConfined(), false);
QCOMPARE(serverConfinedPointer->region(), QRegion()); QCOMPARE(serverConfinedPointer->region(), QRegion());
QFETCH(ConfinedPointerInterface::LifeTime, serverLifeTime); QFETCH(ConfinedPointerV1Interface::LifeTime, serverLifeTime);
QCOMPARE(serverConfinedPointer->lifeTime(), serverLifeTime); QCOMPARE(serverConfinedPointer->lifeTime(), serverLifeTime);
// setting to unconfined now should not trigger an unconfined spy // setting to unconfined now should not trigger an unconfined spy
serverConfinedPointer->setConfined(false); serverConfinedPointer->setConfined(false);
QVERIFY(!unconfinedSpy.wait(500)); QVERIFY(!unconfinedSpy.wait(500));
// try setting a region // try setting a region
QSignalSpy destroyedSpy(serverConfinedPointer.data(), &QObject::destroyed); QSignalSpy destroyedSpy(serverConfinedPointer, &QObject::destroyed);
QVERIFY(destroyedSpy.isValid()); QVERIFY(destroyedSpy.isValid());
QSignalSpy regionChangedSpy(serverConfinedPointer.data(), &ConfinedPointerInterface::regionChanged); QSignalSpy regionChangedSpy(serverConfinedPointer, &ConfinedPointerV1Interface::regionChanged);
QVERIFY(regionChangedSpy.isValid()); QVERIFY(regionChangedSpy.isValid());
confinedPointer->setRegion(m_compositor->createRegion(QRegion(0, 5, 10, 20), m_compositor)); confinedPointer->setRegion(m_compositor->createRegion(QRegion(0, 5, 10, 20), m_compositor));
// it's double buffered // it's double buffered
...@@ -332,7 +331,7 @@ void TestPointerConstraints::testConfinePointer() ...@@ -332,7 +331,7 @@ void TestPointerConstraints::testConfinePointer()
QCOMPARE(serverConfinedPointer->region(), QRegion()); QCOMPARE(serverConfinedPointer->region(), QRegion());
// let's confine the surface // let's confine the surface
QSignalSpy confinedChangedSpy(serverConfinedPointer.data(), &ConfinedPointerInterface::confinedChanged); QSignalSpy confinedChangedSpy(serverConfinedPointer, &ConfinedPointerV1Interface::confinedChanged);
QVERIFY(confinedChangedSpy.isValid()); QVERIFY(confinedChangedSpy.isValid());
m_seatInterface->setFocusedPointerSurface(serverSurface); m_seatInterface->setFocusedPointerSurface(serverSurface);
serverConfinedPointer->setConfined(true); serverConfinedPointer->setConfined(true);
...@@ -346,7 +345,7 @@ void TestPointerConstraints::testConfinePointer() ...@@ -346,7 +345,7 @@ void TestPointerConstraints::testConfinePointer()
serverConfinedPointer->setConfined(false); serverConfinedPointer->setConfined(false);
QCOMPARE(serverConfinedPointer->isConfined(), false); QCOMPARE(serverConfinedPointer->isConfined(), false);
QCOMPARE(confinedChangedSpy.count(), 2); QCOMPARE(confinedChangedSpy.count(), 2);
QTEST(!serverSurface->confinedPointer().isNull(), "hasConstraintAfterUnlock"); QTEST(bool(serverSurface->confinedPointer()), "hasConstraintAfterUnlock");
QTEST(pointerConstraintsChangedSpy.count(), "pointerChangedCount"); QTEST(pointerConstraintsChangedSpy.count(), "pointerChangedCount");
QVERIFY(unconfinedSpy.wait()); QVERIFY(unconfinedSpy.wait());
QCOMPARE(unconfinedSpy.count(), 1); QCOMPARE(unconfinedSpy.count(), 1);
......
...@@ -37,8 +37,7 @@ set(SERVER_LIB_SRCS ...@@ -37,8 +37,7 @@ set(SERVER_LIB_SRCS
plasmavirtualdesktop_interface.cpp plasmavirtualdesktop_interface.cpp
plasmawindowmanagement_interface.cpp plasmawindowmanagement_interface.cpp
pointer_interface.cpp pointer_interface.cpp
pointerconstraints_interface.cpp pointerconstraints_v1_interface.cpp
pointerconstraints_interface_v1.cpp
pointergestures_v1_interface.cpp pointergestures_v1_interface.cpp
primaryselectiondevice_v1_interface.cpp primaryselectiondevice_v1_interface.cpp
primaryselectiondevicemanager_v1_interface.cpp primaryselectiondevicemanager_v1_interface.cpp
...@@ -175,7 +174,7 @@ ecm_add_qtwayland_server_protocol(SERVER_LIB_SRCS ...@@ -175,7 +174,7 @@ ecm_add_qtwayland_server_protocol(SERVER_LIB_SRCS
BASENAME pointer-gestures-unstable-v1 BASENAME pointer-gestures-unstable-v1
) )
ecm_add_wayland_server_protocol(SERVER_LIB_SRCS ecm_add_qtwayland_server_protocol(SERVER_LIB_SRCS
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml PROTOCOL ${WaylandProtocols_DATADIR}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml
BASENAME pointer-constraints-unstable-v1 BASENAME pointer-constraints-unstable-v1
) )
...@@ -409,7 +408,7 @@ set(SERVER_LIB_HEADERS ...@@ -409,7 +408,7 @@ set(SERVER_LIB_HEADERS
plasmavirtualdesktop_interface.h plasmavirtualdesktop_interface.h
plasmawindowmanagement_interface.h plasmawindowmanagement_interface.h
pointer_interface.h pointer_interface.h
pointerconstraints_interface.h pointerconstraints_v1_interface.h
pointergestures_v1_interface.h pointergestures_v1_interface.h
primaryselectiondevicemanager_v1_interface.h primaryselectiondevicemanager_v1_interface.h
region_interface.h region_interface.h
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "plasmashell_interface.h" #include "plasmashell_interface.h"
#include "plasmavirtualdesktop_interface.h" #include "plasmavirtualdesktop_interface.h"
#include "plasmawindowmanagement_interface.h" #include "plasmawindowmanagement_interface.h"
#include "pointerconstraints_interface_p.h" #include "pointerconstraints_v1_interface_p.h"
#include "pointergestures_v1_interface.h" #include "pointergestures_v1_interface.h"
#include "primaryselectiondevicemanager_v1_interface.h" #include "primaryselectiondevicemanager_v1_interface.h"
#include "relativepointer_v1_interface.h" #include "relativepointer_v1_interface.h"
...@@ -380,14 +380,9 @@ PointerGesturesV1Interface *Display::createPointerGesturesV1(QObject *parent) ...@@ -380,14 +380,9 @@ PointerGesturesV1Interface *Display::createPointerGesturesV1(QObject *parent)
return p; return p;
} }
PointerConstraintsInterface *Display::createPointerConstraints(const PointerConstraintsInterfaceVersion &version, QObject *parent) PointerConstraintsV1Interface *Display::createPointerConstraintsV1(QObject *parent)
{ {
PointerConstraintsInterface *p = nullptr; PointerConstraintsV1Interface *p = new PointerConstraintsV1Interface(this, parent);
switch (version) {
case PointerConstraintsInterfaceVersion::UnstableV1:
p = new PointerConstraintsUnstableV1Interface(this, parent);
break;
}
connect(this, &Display::aboutToTerminate, p, [p] { delete p; }); connect(this, &Display::aboutToTerminate, p, [p] { delete p; });
return p; return p;
} }
......
...@@ -59,8 +59,7 @@ class TextInputManagerV3Interface; ...@@ -59,8 +59,7 @@ class TextInputManagerV3Interface;
class XdgShellInterface; class XdgShellInterface;
class RelativePointerManagerV1Interface; class RelativePointerManagerV1Interface;
class PointerGesturesV1Interface; class PointerGesturesV1Interface;
enum class PointerConstraintsInterfaceVersion; class PointerConstraintsV1Interface;
class PointerConstraintsInterface;
class XdgForeignV2Interface; class XdgForeignV2Interface;
class AppMenuManagerInterface; class AppMenuManagerInterface;
class ServerSideDecorationPaletteManagerInterface; class ServerSideDecorationPaletteManagerInterface;
...@@ -228,12 +227,12 @@ public: ...@@ -228,12 +227,12 @@ public:
PointerGesturesV1Interface *createPointerGesturesV1(QObject *parent = nullptr); PointerGesturesV1Interface *createPointerGesturesV1(QObject *parent = nullptr);
/** /**
* Creates the PointerConstraintsInterface in interface @p version * Creates the PointerConstraintsV1Interface
* *
* @returns The created manager object * @returns The created manager object
* @since 5.29 * @since 5.29
**/ **/
PointerConstraintsInterface *createPointerConstraints(const PointerConstraintsInterfaceVersion &version, QObject *parent = nullptr); PointerConstraintsV1Interface *createPointerConstraintsV1(QObject *parent = nullptr);
/** /**
* Creates the XdgForeignV2Interface in interface @p version * Creates the XdgForeignV2Interface in interface @p version
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
*/ */
#include "pointer_interface.h" #include "pointer_interface.h"
#include "pointer_interface_p.h" #include "pointer_interface_p.h"
#include "pointerconstraints_interface.h" #include "pointerconstraints_v1_interface.h"
#include "pointergestures_v1_interface_p.h" #include "pointergestures_v1_interface_p.h"
#include "resource_p.h" #include "resource_p.h"
#include "relativepointer_v1_interface_p.h" #include "relativepointer_v1_interface_p.h"
...@@ -220,7 +220,7 @@ PointerInterface::PointerInterface(SeatInterface *parent, wl_resource *parentRes ...@@ -220,7 +220,7 @@ PointerInterface::PointerInterface(SeatInterface *parent, wl_resource *parentRes
return; return;
} }
} }
if (!d->focusedSurface->lockedPointer().isNull() && d->focusedSurface->lockedPointer()->isLocked()) { if (d->focusedSurface->lockedPointer() && d->focusedSurface->lockedPointer()->isLocked()) {
return; return;
} }
const QPointF pos = d->seat->focusedPointerSurfaceTransformation().map(d->seat->pointerPos()); const QPointF pos = d->seat->focusedPointerSurfaceTransformation().map(d->seat->pointerPos());
......
/*
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 "pointerconstraints_interface_p.h"
#include <functional>
namespace KWaylandServer
{
PointerConstraintsInterface::Private::Private(PointerConstraintsInterfaceVersion interfaceVersion, PointerConstraintsInterface *q, Display *d, const wl_interface *interface, quint32 version)
: Global::Private(d, interface, version)
, interfaceVersion(interfaceVersion)
, q(q)
{
}
PointerConstraintsInterface::PointerConstraintsInterface(Private *d, QObject *parent)
: Global(d, parent)
{
}
PointerConstraintsInterface::~PointerConstraintsInterface() = default;
PointerConstraintsInterfaceVersion PointerConstraintsInterface::interfaceVersion() const
{
Q_D();
return d->interfaceVersion;
}
PointerConstraintsInterface::Private *PointerConstraintsInterface::d_func() const
{
return reinterpret_cast<Private*>(d.data());
}
LockedPointerInterface::Private::Private(PointerConstraintsInterfaceVersion interfaceVersion, LockedPointerInterface *q, Global *c, wl_resource *parentResource, const wl_interface *interface, const void *implementation)
: Resource::Private(q, c, parentResource, interface, implementation)
, interfaceVersion(interfaceVersion)
{
}
LockedPointerInterface::Private::~Private()
{
if (resource) {
wl_resource_destroy(resource);
resource = nullptr;
}
}
void LockedPointerInterface::Private::commit()
{
if (regionIsSet) {
region = pendingRegion;
pendingRegion = QRegion();
regionIsSet = false;
emit q_func()->regionChanged();
}
if (hintIsSet) {
hint = pendingHint;
hintIsSet = false;
emit q_func()->cursorPositionHintChanged();
}
}
LockedPointerInterface::LockedPointerInterface(Private *p, QObject *parent)
: Resource(p, parent)
{
connect(this, &LockedPointerInterface::unbound, this, [this]() { setLocked(false); });
}
LockedPointerInterface::~LockedPointerInterface() = default;
PointerConstraintsInterfaceVersion LockedPointerInterface::interfaceVersion() const
{
Q_D();
return d->interfaceVersion;
}
LockedPointerInterface::LifeTime LockedPointerInterface::lifeTime() const
{
Q_D();
return d->lifeTime;
}
QRegion LockedPointerInterface::region() const
{
Q_D();
return d->region;
}
QPointF LockedPointerInterface::cursorPositionHint() const
{
Q_D();
return d->hint;
}
bool LockedPointerInterface::isLocked() const
{
Q_D();
return d->locked;
}
void LockedPointerInterface::setLocked(bool locked)
{
Q_D();
if (locked == d->locked) {
return;
}
if (!locked) {
d->hint = QPointF(-1., -1.);
}
d->locked = locked;
d->updateLocked();
emit lockedChanged();
}
LockedPointerInterface::Private *LockedPointerInterface::d_func() const
{
return reinterpret_cast<Private*>(d.data());
}
ConfinedPointerInterface::Private::Private(PointerConstraintsInterfaceVersion interfaceVersion, ConfinedPointerInterface *q, Global *c, wl_resource *parentResource, const wl_interface *interface, const void *implementation)
: Resource::Private(q, c, parentResource, interface, implementation)
, interfaceVersion(interfaceVersion)
{
}
ConfinedPointerInterface::Private::~Private()
{
if (resource) {
wl_resource_destroy(resource);
resource = nullptr;
}
}
void ConfinedPointerInterface::Private::commit()
{
if (!regionIsSet) {
return;
}
region = pendingRegion;
pendingRegion = QRegion();
regionIsSet = false;
emit q_func()->regionChanged();
}
ConfinedPointerInterface::ConfinedPointerInterface(Private *p, QObject *parent)
: Resource(p, parent)
{
connect(this, &ConfinedPointerInterface::unbound, this, [this]() { setConfined(false); });
}
ConfinedPointerInterface::~ConfinedPointerInterface() = default;
PointerConstraintsInterfaceVersion ConfinedPointerInterface::interfaceVersion() const
{
Q_D();
return d->interfaceVersion;
}
ConfinedPointerInterface::LifeTime ConfinedPointerInterface::lifeTime() const
{
Q_D();
return d->lifeTime;
}
QRegion ConfinedPointerInterface::region() const
{
Q_D();
return d->region;
}
bool ConfinedPointerInterface::isConfined() const
{
Q_D();
return d->confined;
}
void ConfinedPointerInterface::setConfined(bool confined)
{
Q_D();
if (confined == d->confined) {