Rename screencast wrappers according to unstable protocol naming conventions

Since the screencast protocol is unstable, the ScreencastInterface class
and the ScreencastStreamInterface class must carry version info in their
class names.
This commit is contained in:
Vlad Zahorodnii 2020-09-04 17:45:47 +03:00
parent c3b9d76d33
commit f8b9ea5680
8 changed files with 131 additions and 125 deletions

View file

@ -49,6 +49,7 @@ set(SERVER_LIB_SRCS
relativepointer_interface.cpp
relativepointer_interface_v1.cpp
resource.cpp
screencast_v1_interface.cpp
seat_interface.cpp
server_decoration_interface.cpp
server_decoration_palette_interface.cpp
@ -67,7 +68,6 @@ set(SERVER_LIB_SRCS
xdgforeign_v2_interface.cpp
xdgoutput_v1_interface.cpp
xdgshell_interface.cpp
screencast_interface.cpp
)
ecm_qt_declare_logging_category(SERVER_LIB_SRCS
@ -417,7 +417,7 @@ set(SERVER_LIB_HEADERS
region_interface.h
relativepointer_interface.h
resource.h
screencast_interface.h
screencast_v1_interface.h
seat_interface.h
server_decoration_interface.h
server_decoration_palette_interface.h

View file

@ -77,16 +77,16 @@ add_test(NAME kwayland-testViewporterInterface COMMAND testViewporterInterface)
ecm_mark_as_test(testViewporterInterface)
########################################################
# Test ScreencastInterface
# Test ScreencastV1Interface
########################################################
ecm_add_qtwayland_client_protocol(SCREENCAST_SRCS
PROTOCOL PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/screencast.xml
BASENAME zkde-screencast-unstable-v1
)
add_executable(testScreencastInterface test_screencast.cpp ${SCREENCAST_SRCS})
target_link_libraries(testScreencastInterface Qt5::Test Plasma::KWaylandServer Wayland::Client KF5::WaylandClient)
add_test(NAME kwayland-testScreencastInterface COMMAND testScreencastInterface)
ecm_mark_as_test(testScreencastInterface)
add_executable(testScreencastV1Interface test_screencast.cpp ${SCREENCAST_SRCS})
target_link_libraries(testScreencastV1Interface Qt5::Test Plasma::KWaylandServer Wayland::Client KF5::WaylandClient)
add_test(NAME kwayland-testScreencastV1Interface COMMAND testScreencastV1Interface)
ecm_mark_as_test(testScreencastV1Interface)
########################################################
# Test InputMethod Interface

View file

@ -15,7 +15,7 @@
#include "../../src/server/compositor_interface.h"
#include "../../src/server/display.h"
#include "../../src/server/seat_interface.h"
#include "../../src/server/screencast_interface.h"
#include "../../src/server/screencast_v1_interface.h"
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/event_queue.h>
@ -25,11 +25,12 @@
#include "qwayland-zkde-screencast-unstable-v1.h"
class ScreencastStream : public QObject, public QtWayland::zkde_screencast_stream_unstable_v1
class ScreencastStreamV1 : public QObject, public QtWayland::zkde_screencast_stream_unstable_v1
{
Q_OBJECT
public:
ScreencastStream(::zkde_screencast_stream_unstable_v1 *obj, QObject *parent)
ScreencastStreamV1(::zkde_screencast_stream_unstable_v1 *obj, QObject *parent)
: QObject(parent)
, zkde_screencast_stream_unstable_v1(obj)
{
@ -43,29 +44,32 @@ public:
Q_SIGNALS:
void created(quint32 node);
};
class Screencast : public QObject, public QtWayland::zkde_screencast_unstable_v1
class ScreencastV1 : public QObject, public QtWayland::zkde_screencast_unstable_v1
{
Q_OBJECT
public:
Screencast(QObject* parent)
ScreencastV1(QObject *parent)
: QObject(parent)
{
}
ScreencastStream* createWindowStream(const QString &uuid) {
return new ScreencastStream(stream_window(uuid, 2), this);
ScreencastStreamV1 *createWindowStream(const QString &uuid) {
return new ScreencastStreamV1(stream_window(uuid, 2), this);
}
};
class TestScreencastInterface : public QObject
class TestScreencastV1Interface : public QObject
{
Q_OBJECT
public:
TestScreencastInterface()
TestScreencastV1Interface()
{
}
~TestScreencastInterface() override;
~TestScreencastV1Interface() override;
private Q_SLOTS:
void initTestCase();
@ -74,18 +78,18 @@ private Q_SLOTS:
private:
KWayland::Client::ConnectionThread *m_connection;
KWayland::Client::EventQueue *m_queue = nullptr;
Screencast *m_screencast = nullptr;
ScreencastV1 *m_screencast = nullptr;
KWaylandServer::ScreencastInterface *m_screencastInterface = nullptr;
KWaylandServer::ScreencastV1Interface *m_screencastInterface = nullptr;
QPointer<KWaylandServer::ScreencastStreamInterface> m_triggered = nullptr;
QPointer<KWaylandServer::ScreencastStreamV1Interface> m_triggered = nullptr;
QThread *m_thread;
KWaylandServer::Display *m_display = nullptr;
};
static const QString s_socketName = QStringLiteral("kwin-wayland-server-screencast-test-0");
void TestScreencastInterface::initTestCase()
void TestScreencastV1Interface::initTestCase()
{
delete m_display;
m_display = new KWaylandServer::Display(this);
@ -115,8 +119,8 @@ void TestScreencastInterface::initTestCase()
QSignalSpy screencastSpy(&registry, &KWayland::Client::Registry::interfacesAnnounced);
QVERIFY(screencastSpy.isValid());
m_screencastInterface = m_display->createScreencastInterface(this);
connect(m_screencastInterface, &KWaylandServer::ScreencastInterface::windowScreencastRequested, this, [this] (KWaylandServer::ScreencastStreamInterface* stream, const QString &winid) {
m_screencastInterface = m_display->createScreencastV1Interface(this);
connect(m_screencastInterface, &KWaylandServer::ScreencastV1Interface::windowScreencastRequested, this, [this] (KWaylandServer::ScreencastStreamV1Interface *stream, const QString &winid) {
Q_UNUSED(winid);
stream->sendCreated(123);
m_triggered = stream;
@ -126,7 +130,7 @@ void TestScreencastInterface::initTestCase()
if (interfaceName != "zkde_screencast_unstable_v1")
return;
Q_ASSERT(version == 1);
m_screencast = new Screencast(this);
m_screencast = new ScreencastV1(this);
m_screencast->init(&*registry, name, version);
});
registry.setEventQueue(m_queue);
@ -140,7 +144,7 @@ void TestScreencastInterface::initTestCase()
QVERIFY(m_screencast);
}
TestScreencastInterface::~TestScreencastInterface()
TestScreencastV1Interface::~TestScreencastV1Interface()
{
delete m_queue;
m_queue = nullptr;
@ -157,20 +161,20 @@ TestScreencastInterface::~TestScreencastInterface()
delete m_display;
}
void TestScreencastInterface::testCreate()
void TestScreencastV1Interface::testCreate()
{
auto stream = m_screencast->createWindowStream("3");
QVERIFY(stream);
QSignalSpy spyWorking(stream, &ScreencastStream::created);
QSignalSpy spyWorking(stream, &ScreencastStreamV1::created);
QVERIFY(spyWorking.count() || spyWorking.wait());
QVERIFY(m_triggered);
QSignalSpy spyStop(m_triggered, &KWaylandServer::ScreencastStreamInterface::finished);
QSignalSpy spyStop(m_triggered, &KWaylandServer::ScreencastStreamV1Interface::finished);
stream->close();
QVERIFY(spyStop.count() || spyStop.wait());
}
QTEST_GUILESS_MAIN(TestScreencastInterface)
QTEST_GUILESS_MAIN(TestScreencastV1Interface)
#include "test_screencast.moc"

View file

@ -33,7 +33,7 @@
#include "primaryselectiondevicemanager_v1_interface.h"
#include "relativepointer_interface_p.h"
#include "seat_interface.h"
#include "screencast_interface.h"
#include "screencast_v1_interface.h"
#include "server_decoration_interface.h"
#include "server_decoration_palette_interface.h"
#include "shadow_interface.h"
@ -336,9 +336,9 @@ ServerSideDecorationManagerInterface *Display::createServerSideDecorationManager
return d;
}
ScreencastInterface *Display::createScreencastInterface(QObject *parent)
ScreencastV1Interface *Display::createScreencastV1Interface(QObject *parent)
{
auto s = new ScreencastInterface(this, parent);
auto s = new ScreencastV1Interface(this, parent);
connect(this, &Display::aboutToTerminate, s, [s] { delete s; });
return s;
}

View file

@ -77,7 +77,7 @@ class DataControlDeviceManagerV1Interface;
class PrimarySelectionDeviceManagerV1Interface;
class KeyboardShortcutsInhibitManagerV1Interface;
class ViewporterInterface;
class ScreencastInterface;
class ScreencastV1Interface;
class InputMethodV1Interface;
class InputPanelV1Interface;
class LayerShellV1Interface;
@ -338,7 +338,7 @@ public:
/**
* Creates an interface to request video feeds of different compositor resources
*/
ScreencastInterface *createScreencastInterface(QObject *parent = nullptr);
ScreencastV1Interface *createScreencastV1Interface(QObject *parent = nullptr);
/**
* Creates the layer shell compositor extension.

View file

@ -4,7 +4,7 @@
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "screencast_interface.h"
#include "screencast_v1_interface.h"
#include "display.h"
#include "output_interface.h"
@ -12,14 +12,15 @@
#include "qwayland-server-zkde-screencast-unstable-v1.h"
using namespace KWaylandServer;
namespace KWaylandServer
{
static int s_version = 1;
class KWaylandServer::ScreencastStreamInterfacePrivate : public QtWaylandServer::zkde_screencast_stream_unstable_v1
class ScreencastStreamV1InterfacePrivate : public QtWaylandServer::zkde_screencast_stream_unstable_v1
{
public:
ScreencastStreamInterfacePrivate(ScreencastStreamInterface *q)
ScreencastStreamV1InterfacePrivate(ScreencastStreamV1Interface *q)
: q(q)
{}
@ -32,8 +33,8 @@ public:
q->deleteLater();
}
void zkde_screencast_stream_unstable_v1_close(Resource * resource) override
void zkde_screencast_stream_unstable_v1_close(Resource *resource) override
{
Q_UNUSED(resource);
Q_EMIT q->finished();
@ -42,72 +43,74 @@ public:
}
bool stopped = false;
ScreencastStreamInterface *const q;
ScreencastStreamV1Interface *const q;
};
ScreencastStreamInterface::ScreencastStreamInterface(QObject* parent)
ScreencastStreamV1Interface::ScreencastStreamV1Interface(QObject *parent)
: QObject(parent)
, d(new ScreencastStreamInterfacePrivate(this))
, d(new ScreencastStreamV1InterfacePrivate(this))
{
}
ScreencastStreamInterface::~ScreencastStreamInterface() = default;
ScreencastStreamV1Interface::~ScreencastStreamV1Interface() = default;
void ScreencastStreamInterface::sendCreated(quint32 nodeid)
void ScreencastStreamV1Interface::sendCreated(quint32 nodeid)
{
d->send_created(nodeid);
}
void ScreencastStreamInterface::sendFailed(const QString& error)
void ScreencastStreamV1Interface::sendFailed(const QString &error)
{
d->send_failed(error);
}
void ScreencastStreamInterface::sendClosed()
void ScreencastStreamV1Interface::sendClosed()
{
if (!d->stopped) {
d->send_closed();
}
}
class KWaylandServer::ScreencastInterfacePrivate : public QtWaylandServer::zkde_screencast_unstable_v1
class ScreencastV1InterfacePrivate : public QtWaylandServer::zkde_screencast_unstable_v1
{
public:
ScreencastInterfacePrivate(Display *display, ScreencastInterface* q)
ScreencastV1InterfacePrivate(Display *display, ScreencastV1Interface *q)
: QtWaylandServer::zkde_screencast_unstable_v1(*display, s_version)
, q(q)
{
}
ScreencastStreamInterface *createStream(Resource *resource, quint32 streamid) const
ScreencastStreamV1Interface *createStream(Resource *resource, quint32 streamid) const
{
auto stream = new ScreencastStreamInterface(q);
auto stream = new ScreencastStreamV1Interface(q);
stream->d->init(resource->client(), streamid, resource->version());
return stream;
}
void zkde_screencast_unstable_v1_stream_output(Resource *resource, uint32_t streamid, struct ::wl_resource *output, uint32_t pointer) override
{
Q_EMIT q->outputScreencastRequested(createStream(resource, streamid), OutputInterface::get(output), ScreencastInterface::CursorMode(pointer));
Q_EMIT q->outputScreencastRequested(createStream(resource, streamid), OutputInterface::get(output), ScreencastV1Interface::CursorMode(pointer));
}
void zkde_screencast_unstable_v1_stream_window(Resource *resource, uint32_t streamid, const QString &uuid, uint32_t pointer) override
{
Q_EMIT q->windowScreencastRequested(createStream(resource, streamid), uuid, ScreencastInterface::CursorMode(pointer));
Q_EMIT q->windowScreencastRequested(createStream(resource, streamid), uuid, ScreencastV1Interface::CursorMode(pointer));
}
void zkde_screencast_unstable_v1_destroy(Resource * resource) override
void zkde_screencast_unstable_v1_destroy(Resource *resource) override
{
wl_resource_destroy(resource->handle);
}
ScreencastInterface *const q;
ScreencastV1Interface *const q;
};
ScreencastInterface::ScreencastInterface(Display *display, QObject *parent)
ScreencastV1Interface::ScreencastV1Interface(Display *display, QObject *parent)
: QObject(parent)
, d(new ScreencastInterfacePrivate(display, this))
, d(new ScreencastV1InterfacePrivate(display, this))
{
}
ScreencastInterface::~ScreencastInterface() = default;
ScreencastV1Interface::~ScreencastV1Interface() = default;
} // namespace KWaylandServer

View file

@ -0,0 +1,66 @@
/*
SPDX-FileCopyrightText: 2020 Aleix Pol Gonzalez <aleixpol@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#pragma once
#include <QObject>
#include <QScopedPointer>
#include <KWaylandServer/kwaylandserver_export.h>
struct wl_resource;
namespace KWaylandServer
{
class Display;
class OutputInterface;
class ScreencastV1InterfacePrivate;
class ScreencastStreamV1InterfacePrivate;
class ScreencastStreamV1Interface;
class KWAYLANDSERVER_EXPORT ScreencastStreamV1Interface : public QObject
{
Q_OBJECT
public:
~ScreencastStreamV1Interface() override;
void sendCreated(quint32 nodeid);
void sendFailed(const QString &error);
void sendClosed();
Q_SIGNALS:
void finished();
private:
friend class ScreencastV1InterfacePrivate;
explicit ScreencastStreamV1Interface(QObject *parent);
QScopedPointer<ScreencastStreamV1InterfacePrivate> d;
};
class KWAYLANDSERVER_EXPORT ScreencastV1Interface : public QObject
{
Q_OBJECT
public:
virtual ~ScreencastV1Interface();
enum CursorMode {
Hidden = 1,
Embedded = 2,
Metadata = 4,
};
Q_ENUM(CursorMode);
Q_SIGNALS:
void outputScreencastRequested(ScreencastStreamV1Interface *stream, OutputInterface *output, CursorMode mode);
void windowScreencastRequested(ScreencastStreamV1Interface *stream, const QString &winid, CursorMode mode);
private:
explicit ScreencastV1Interface(Display *display, QObject *parent = nullptr);
friend class Display;
QScopedPointer<ScreencastV1InterfacePrivate> d;
};
}

View file

@ -1,67 +0,0 @@
/*
SPDX-FileCopyrightText: 2020 Aleix Pol Gonzalez <aleixpol@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#pragma once
#include <QObject>
#include <QScopedPointer>
#include <KWaylandServer/kwaylandserver_export.h>
struct wl_resource;
namespace KWaylandServer
{
class Display;
class OutputInterface;
class ScreencastInterfacePrivate;
class ScreencastStreamInterfacePrivate;
class ScreencastStreamInterface;
class KWAYLANDSERVER_EXPORT ScreencastStreamInterface : public QObject
{
Q_OBJECT
public:
~ScreencastStreamInterface() override;
void sendCreated(quint32 nodeid);
void sendFailed(const QString &error);
void sendClosed();
Q_SIGNALS:
void finished();
private:
friend class ScreencastInterfacePrivate;
explicit ScreencastStreamInterface(QObject *parent);
QScopedPointer<ScreencastStreamInterfacePrivate> d;
};
class KWAYLANDSERVER_EXPORT ScreencastInterface : public QObject
{
Q_OBJECT
public:
virtual ~ScreencastInterface();
enum CursorMode {
Hidden = 1,
Embedded = 2,
Metadata = 4,
};
Q_ENUM(CursorMode);
Q_SIGNALS:
void outputScreencastRequested(ScreencastStreamInterface* stream, OutputInterface *output, CursorMode mode);
void windowScreencastRequested(ScreencastStreamInterface* stream, const QString &winid, CursorMode mode);
private:
explicit ScreencastInterface(Display *display, QObject *parent = nullptr);
friend class Display;
QScopedPointer<ScreencastInterfacePrivate> d;
};
}