Migrate Migrate XdgForeign to new approach
This commit is contained in:
parent
ed264e2c55
commit
389aec2156
8 changed files with 276 additions and 461 deletions
|
@ -62,7 +62,6 @@ set(SERVER_LIB_SRCS
|
||||||
touch_interface.cpp
|
touch_interface.cpp
|
||||||
viewporter_interface.cpp
|
viewporter_interface.cpp
|
||||||
xdgdecoration_v1_interface.cpp
|
xdgdecoration_v1_interface.cpp
|
||||||
xdgforeign_interface.cpp
|
|
||||||
xdgforeign_v2_interface.cpp
|
xdgforeign_v2_interface.cpp
|
||||||
xdgoutput_interface.cpp
|
xdgoutput_interface.cpp
|
||||||
xdgshell_interface.cpp
|
xdgshell_interface.cpp
|
||||||
|
@ -177,7 +176,7 @@ ecm_add_wayland_server_protocol(SERVER_LIB_SRCS
|
||||||
BASENAME pointer-constraints-unstable-v1
|
BASENAME pointer-constraints-unstable-v1
|
||||||
)
|
)
|
||||||
|
|
||||||
ecm_add_wayland_server_protocol(SERVER_LIB_SRCS
|
ecm_add_qtwayland_server_protocol(SERVER_LIB_SRCS
|
||||||
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/xdg-foreign/xdg-foreign-unstable-v2.xml
|
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/xdg-foreign/xdg-foreign-unstable-v2.xml
|
||||||
BASENAME xdg-foreign-unstable-v2
|
BASENAME xdg-foreign-unstable-v2
|
||||||
)
|
)
|
||||||
|
@ -410,7 +409,7 @@ set(SERVER_LIB_HEADERS
|
||||||
touch_interface.h
|
touch_interface.h
|
||||||
viewporter_interface.h
|
viewporter_interface.h
|
||||||
xdgdecoration_v1_interface.h
|
xdgdecoration_v1_interface.h
|
||||||
xdgforeign_interface.h
|
xdgforeign_v2_interface.h
|
||||||
xdgoutput_interface.h
|
xdgoutput_interface.h
|
||||||
xdgshell_interface.h
|
xdgshell_interface.h
|
||||||
)
|
)
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#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/surface_interface.h"
|
#include "../../src/server/surface_interface.h"
|
||||||
#include "../../src/server/xdgforeign_interface.h"
|
#include "../../src/server/xdgforeign_v2_interface.h"
|
||||||
|
|
||||||
using namespace KWayland::Client;
|
using namespace KWayland::Client;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ private:
|
||||||
|
|
||||||
KWaylandServer::Display *m_display;
|
KWaylandServer::Display *m_display;
|
||||||
QPointer<KWaylandServer::CompositorInterface> m_compositorInterface;
|
QPointer<KWaylandServer::CompositorInterface> m_compositorInterface;
|
||||||
KWaylandServer::XdgForeignInterface *m_foreignInterface;
|
KWaylandServer::XdgForeignV2Interface *m_foreignInterface;
|
||||||
KWayland::Client::ConnectionThread *m_connection;
|
KWayland::Client::ConnectionThread *m_connection;
|
||||||
KWayland::Client::Compositor *m_compositor;
|
KWayland::Client::Compositor *m_compositor;
|
||||||
KWayland::Client::EventQueue *m_queue;
|
KWayland::Client::EventQueue *m_queue;
|
||||||
|
@ -86,8 +86,7 @@ void TestForeign::init()
|
||||||
m_display->start();
|
m_display->start();
|
||||||
QVERIFY(m_display->isRunning());
|
QVERIFY(m_display->isRunning());
|
||||||
|
|
||||||
qRegisterMetaType<KWaylandServer::SurfaceInterface*>("KWaylandServer::SurfaceInterface");
|
qRegisterMetaType<SurfaceInterface*>();
|
||||||
|
|
||||||
// setup connection
|
// setup connection
|
||||||
m_connection = new KWayland::Client::ConnectionThread;
|
m_connection = new KWayland::Client::ConnectionThread;
|
||||||
QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
|
QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
|
||||||
|
@ -127,9 +126,7 @@ void TestForeign::init()
|
||||||
QVERIFY(compositorSpy.wait());
|
QVERIFY(compositorSpy.wait());
|
||||||
m_compositor = registry.createCompositor(compositorSpy.first().first().value<quint32>(), compositorSpy.first().last().value<quint32>(), this);
|
m_compositor = registry.createCompositor(compositorSpy.first().first().value<quint32>(), compositorSpy.first().last().value<quint32>(), this);
|
||||||
|
|
||||||
m_foreignInterface = m_display->createXdgForeignInterface(m_display);
|
m_foreignInterface = m_display->createXdgForeignV2Interface(m_display);
|
||||||
m_foreignInterface->create();
|
|
||||||
QVERIFY(m_foreignInterface->isValid());
|
|
||||||
|
|
||||||
QVERIFY(exporterSpy.wait());
|
QVERIFY(exporterSpy.wait());
|
||||||
//Both importer and exporter should have been triggered by now
|
//Both importer and exporter should have been triggered by now
|
||||||
|
@ -163,17 +160,8 @@ void TestForeign::cleanup()
|
||||||
m_thread = nullptr;
|
m_thread = nullptr;
|
||||||
}
|
}
|
||||||
CLEANUP(m_foreignInterface)
|
CLEANUP(m_foreignInterface)
|
||||||
|
delete m_display;
|
||||||
//internally there are some deleteLaters on exported interfaces
|
m_display = nullptr;
|
||||||
//we want them processed before we delete the connection
|
|
||||||
if (m_display) {
|
|
||||||
QSignalSpy destroyedSpy(m_display, &QObject::destroyed);
|
|
||||||
m_display->deleteLater();
|
|
||||||
m_display = nullptr;
|
|
||||||
destroyedSpy.wait();
|
|
||||||
}
|
|
||||||
|
|
||||||
QVERIFY(m_compositorInterface.isNull());
|
|
||||||
|
|
||||||
#undef CLEANUP
|
#undef CLEANUP
|
||||||
}
|
}
|
||||||
|
@ -189,17 +177,17 @@ void TestForeign::doExport()
|
||||||
m_exportedSurfaceInterface = serverSurfaceCreated.first().first().value<KWaylandServer::SurfaceInterface*>();
|
m_exportedSurfaceInterface = serverSurfaceCreated.first().first().value<KWaylandServer::SurfaceInterface*>();
|
||||||
|
|
||||||
//Export a window
|
//Export a window
|
||||||
m_exported = m_exporter->exportTopLevel(m_exportedSurface, m_connection);
|
m_exported = m_exporter->exportTopLevel(m_exportedSurface);
|
||||||
QVERIFY(m_exported->handle().isEmpty());
|
QVERIFY(m_exported->handle().isEmpty());
|
||||||
QSignalSpy doneSpy(m_exported.data(), &XdgExported::done);
|
QSignalSpy doneSpy(m_exported.data(), &XdgExported::done);
|
||||||
QVERIFY(doneSpy.wait());
|
QVERIFY(doneSpy.wait());
|
||||||
QVERIFY(!m_exported->handle().isEmpty());
|
QVERIFY(!m_exported->handle().isEmpty());
|
||||||
|
|
||||||
QSignalSpy transientSpy(m_foreignInterface, &KWaylandServer::XdgForeignInterface::transientChanged);
|
QSignalSpy transientSpy(m_foreignInterface, &KWaylandServer::XdgForeignV2Interface::transientChanged);
|
||||||
QVERIFY(transientSpy.isValid());
|
QVERIFY(transientSpy.isValid());
|
||||||
|
|
||||||
//Import the just exported window
|
//Import the just exported window
|
||||||
m_imported = m_importer->importTopLevel(m_exported->handle(), m_connection);
|
m_imported = m_importer->importTopLevel(m_exported->handle());
|
||||||
QVERIFY(m_imported->isValid());
|
QVERIFY(m_imported->isValid());
|
||||||
|
|
||||||
QSignalSpy childSurfaceInterfaceCreated(m_compositorInterface, SIGNAL(surfaceCreated(KWaylandServer::SurfaceInterface*)));
|
QSignalSpy childSurfaceInterfaceCreated(m_compositorInterface, SIGNAL(surfaceCreated(KWaylandServer::SurfaceInterface*)));
|
||||||
|
@ -228,7 +216,7 @@ void TestForeign::testDeleteImported()
|
||||||
{
|
{
|
||||||
doExport();
|
doExport();
|
||||||
|
|
||||||
QSignalSpy transientSpy(m_foreignInterface, &KWaylandServer::XdgForeignInterface::transientChanged);
|
QSignalSpy transientSpy(m_foreignInterface, &KWaylandServer::XdgForeignV2Interface::transientChanged);
|
||||||
|
|
||||||
QVERIFY(transientSpy.isValid());
|
QVERIFY(transientSpy.isValid());
|
||||||
m_imported->deleteLater();
|
m_imported->deleteLater();
|
||||||
|
@ -245,7 +233,7 @@ void TestForeign::testDeleteChildSurface()
|
||||||
{
|
{
|
||||||
doExport();
|
doExport();
|
||||||
|
|
||||||
QSignalSpy transientSpy(m_foreignInterface, &KWaylandServer::XdgForeignInterface::transientChanged);
|
QSignalSpy transientSpy(m_foreignInterface, &KWaylandServer::XdgForeignV2Interface::transientChanged);
|
||||||
|
|
||||||
QVERIFY(transientSpy.isValid());
|
QVERIFY(transientSpy.isValid());
|
||||||
m_childSurface->deleteLater();
|
m_childSurface->deleteLater();
|
||||||
|
@ -260,7 +248,7 @@ void TestForeign::testDeleteParentSurface()
|
||||||
{
|
{
|
||||||
doExport();
|
doExport();
|
||||||
|
|
||||||
QSignalSpy transientSpy(m_foreignInterface, &KWaylandServer::XdgForeignInterface::transientChanged);
|
QSignalSpy transientSpy(m_foreignInterface, &KWaylandServer::XdgForeignV2Interface::transientChanged);
|
||||||
|
|
||||||
QVERIFY(transientSpy.isValid());
|
QVERIFY(transientSpy.isValid());
|
||||||
m_exportedSurface->deleteLater();
|
m_exportedSurface->deleteLater();
|
||||||
|
@ -280,7 +268,7 @@ void TestForeign::testDeleteExported()
|
||||||
{
|
{
|
||||||
doExport();
|
doExport();
|
||||||
|
|
||||||
QSignalSpy transientSpy(m_foreignInterface, &KWaylandServer::XdgForeignInterface::transientChanged);
|
QSignalSpy transientSpy(m_foreignInterface, &KWaylandServer::XdgForeignV2Interface::transientChanged);
|
||||||
QSignalSpy destroyedSpy(m_imported.data(), &KWayland::Client::XdgImported::importedDestroyed);
|
QSignalSpy destroyedSpy(m_imported.data(), &KWayland::Client::XdgImported::importedDestroyed);
|
||||||
|
|
||||||
QVERIFY(transientSpy.isValid());
|
QVERIFY(transientSpy.isValid());
|
||||||
|
@ -302,17 +290,17 @@ void TestForeign::testExportTwoTimes()
|
||||||
doExport();
|
doExport();
|
||||||
|
|
||||||
//Export second window
|
//Export second window
|
||||||
KWayland::Client::XdgExported *exported2 = m_exporter->exportTopLevel(m_exportedSurface, m_connection);
|
KWayland::Client::XdgExported *exported2 = m_exporter->exportTopLevel(m_exportedSurface);
|
||||||
QVERIFY(exported2->handle().isEmpty());
|
QVERIFY(exported2->handle().isEmpty());
|
||||||
QSignalSpy doneSpy(exported2, &XdgExported::done);
|
QSignalSpy doneSpy(exported2, &XdgExported::done);
|
||||||
QVERIFY(doneSpy.wait());
|
QVERIFY(doneSpy.wait());
|
||||||
QVERIFY(!exported2->handle().isEmpty());
|
QVERIFY(!exported2->handle().isEmpty());
|
||||||
|
|
||||||
QSignalSpy transientSpy(m_foreignInterface, &KWaylandServer::XdgForeignInterface::transientChanged);
|
QSignalSpy transientSpy(m_foreignInterface, &KWaylandServer::XdgForeignV2Interface::transientChanged);
|
||||||
QVERIFY(transientSpy.isValid());
|
QVERIFY(transientSpy.isValid());
|
||||||
|
|
||||||
//Import the just exported window
|
//Import the just exported window
|
||||||
KWayland::Client::XdgImported *imported2 = m_importer->importTopLevel(exported2->handle(), m_connection);
|
KWayland::Client::XdgImported *imported2 = m_importer->importTopLevel(exported2->handle());
|
||||||
QVERIFY(imported2->isValid());
|
QVERIFY(imported2->isValid());
|
||||||
|
|
||||||
//create a second child surface
|
//create a second child surface
|
||||||
|
@ -341,11 +329,11 @@ void TestForeign::testImportTwoTimes()
|
||||||
{
|
{
|
||||||
doExport();
|
doExport();
|
||||||
|
|
||||||
QSignalSpy transientSpy(m_foreignInterface, &KWaylandServer::XdgForeignInterface::transientChanged);
|
QSignalSpy transientSpy(m_foreignInterface, &KWaylandServer::XdgForeignV2Interface::transientChanged);
|
||||||
QVERIFY(transientSpy.isValid());
|
QVERIFY(transientSpy.isValid());
|
||||||
|
|
||||||
//Import another time the exported window
|
//Import another time the exported window
|
||||||
KWayland::Client::XdgImported *imported2 = m_importer->importTopLevel(m_exported->handle(), m_connection);
|
KWayland::Client::XdgImported *imported2 = m_importer->importTopLevel(m_exported->handle());
|
||||||
QVERIFY(imported2->isValid());
|
QVERIFY(imported2->isValid());
|
||||||
|
|
||||||
//create a second child surface
|
//create a second child surface
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
#include "textinput_interface_p.h"
|
#include "textinput_interface_p.h"
|
||||||
#include "viewporter_interface.h"
|
#include "viewporter_interface.h"
|
||||||
#include "xdgdecoration_v1_interface.h"
|
#include "xdgdecoration_v1_interface.h"
|
||||||
#include "xdgforeign_interface.h"
|
#include "xdgforeign_v2_interface.h"
|
||||||
#include "xdgoutput_interface.h"
|
#include "xdgoutput_interface.h"
|
||||||
#include "xdgshell_interface.h"
|
#include "xdgshell_interface.h"
|
||||||
|
|
||||||
|
@ -401,9 +401,9 @@ PointerConstraintsInterface *Display::createPointerConstraints(const PointerCons
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
XdgForeignInterface *Display::createXdgForeignInterface(QObject *parent)
|
XdgForeignV2Interface *Display::createXdgForeignV2Interface(QObject *parent)
|
||||||
{
|
{
|
||||||
XdgForeignInterface *foreign = new XdgForeignInterface(this, parent);
|
XdgForeignV2Interface *foreign = new XdgForeignV2Interface(this, parent);
|
||||||
connect(this, &Display::aboutToTerminate, foreign, [foreign] { delete foreign; });
|
connect(this, &Display::aboutToTerminate, foreign, [foreign] { delete foreign; });
|
||||||
return foreign;
|
return foreign;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ enum class PointerGesturesInterfaceVersion;
|
||||||
class PointerGesturesInterface;
|
class PointerGesturesInterface;
|
||||||
enum class PointerConstraintsInterfaceVersion;
|
enum class PointerConstraintsInterfaceVersion;
|
||||||
class PointerConstraintsInterface;
|
class PointerConstraintsInterface;
|
||||||
class XdgForeignInterface;
|
class XdgForeignV2Interface;
|
||||||
class AppMenuManagerInterface;
|
class AppMenuManagerInterface;
|
||||||
class ServerSideDecorationPaletteManagerInterface;
|
class ServerSideDecorationPaletteManagerInterface;
|
||||||
class PlasmaVirtualDesktopManagementInterface;
|
class PlasmaVirtualDesktopManagementInterface;
|
||||||
|
@ -231,12 +231,12 @@ public:
|
||||||
PointerConstraintsInterface *createPointerConstraints(const PointerConstraintsInterfaceVersion &version, QObject *parent = nullptr);
|
PointerConstraintsInterface *createPointerConstraints(const PointerConstraintsInterfaceVersion &version, QObject *parent = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the XdgForeignInterface in interface @p version
|
* Creates the XdgForeignV2Interface in interface @p version
|
||||||
*
|
*
|
||||||
* @returns The created manager object
|
* @returns The created manager object
|
||||||
* @since 5.40
|
* @since 5.40
|
||||||
**/
|
**/
|
||||||
XdgForeignInterface *createXdgForeignInterface(QObject *parent = nullptr);
|
XdgForeignV2Interface *createXdgForeignV2Interface(QObject *parent = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the IdleInhibitManagerInterface in interface @p version.
|
* Creates the IdleInhibitManagerInterface in interface @p version.
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
/*
|
|
||||||
SPDX-FileCopyrightText: 2017 Marco Martin <notmart@gmail.com>
|
|
||||||
|
|
||||||
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "xdgforeign_interface.h"
|
|
||||||
#include "xdgforeign_v2_interface_p.h"
|
|
||||||
#include "display.h"
|
|
||||||
#include "global_p.h"
|
|
||||||
#include "resource_p.h"
|
|
||||||
#include "surface_interface_p.h"
|
|
||||||
|
|
||||||
#include "wayland-xdg-foreign-unstable-v2-server-protocol.h"
|
|
||||||
|
|
||||||
#include <QUuid>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
namespace KWaylandServer
|
|
||||||
{
|
|
||||||
|
|
||||||
XdgForeignInterface::Private::Private(Display *display, XdgForeignInterface *q)
|
|
||||||
: q(q)
|
|
||||||
{
|
|
||||||
exporter = new XdgExporterUnstableV2Interface(display, q);
|
|
||||||
importer = new XdgImporterUnstableV2Interface(display, q);
|
|
||||||
|
|
||||||
connect(importer, &XdgImporterUnstableV2Interface::transientChanged,
|
|
||||||
q, &XdgForeignInterface::transientChanged);
|
|
||||||
}
|
|
||||||
|
|
||||||
XdgForeignInterface::XdgForeignInterface(Display *display, QObject *parent)
|
|
||||||
: QObject(parent),
|
|
||||||
d(new Private(display, this))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
XdgForeignInterface::~XdgForeignInterface()
|
|
||||||
{
|
|
||||||
delete d->exporter;
|
|
||||||
delete d->importer;
|
|
||||||
delete d;
|
|
||||||
}
|
|
||||||
|
|
||||||
void XdgForeignInterface::create()
|
|
||||||
{
|
|
||||||
d->exporter->create();
|
|
||||||
d->importer->create();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool XdgForeignInterface::isValid()
|
|
||||||
{
|
|
||||||
return d->exporter->isValid() && d->importer->isValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
SurfaceInterface *XdgForeignInterface::transientFor(SurfaceInterface *surface)
|
|
||||||
{
|
|
||||||
return d->importer->transientFor(surface);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -4,71 +4,71 @@
|
||||||
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "xdgforeign_interface.h"
|
|
||||||
#include "xdgforeign_v2_interface_p.h"
|
#include "xdgforeign_v2_interface_p.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
#include "global_p.h"
|
|
||||||
#include "resource_p.h"
|
|
||||||
#include "surface_interface_p.h"
|
|
||||||
|
|
||||||
#include "wayland-xdg-foreign-unstable-v2-server-protocol.h"
|
|
||||||
|
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
namespace KWaylandServer
|
namespace KWaylandServer
|
||||||
{
|
{
|
||||||
|
|
||||||
class Q_DECL_HIDDEN XdgExporterUnstableV2Interface::Private : public Global::Private
|
XdgForeignV2InterfacePrivate::XdgForeignV2InterfacePrivate(Display *display, XdgForeignV2Interface *_q)
|
||||||
|
: QObject(nullptr)
|
||||||
|
, q(_q)
|
||||||
|
{
|
||||||
|
exporter = new XdgExporterV2Interface(display, _q);
|
||||||
|
importer = new XdgImporterV2Interface(display, _q);
|
||||||
|
|
||||||
|
connect(importer, &XdgImporterV2Interface::transientChanged,
|
||||||
|
q, &XdgForeignV2Interface::transientChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
XdgForeignV2Interface::XdgForeignV2Interface(Display *display, QObject *parent)
|
||||||
|
: QObject(parent),
|
||||||
|
d(new XdgForeignV2InterfacePrivate(display, this))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
XdgForeignV2Interface::~XdgForeignV2Interface()
|
||||||
|
{
|
||||||
|
delete d->exporter;
|
||||||
|
delete d->importer;
|
||||||
|
}
|
||||||
|
|
||||||
|
SurfaceInterface *XdgForeignV2Interface::transientFor(SurfaceInterface *surface)
|
||||||
|
{
|
||||||
|
return d->importer->transientFor(surface);
|
||||||
|
}
|
||||||
|
|
||||||
|
class XdgExporterV2InterfacePrivate : public QtWaylandServer::zxdg_exporter_v2
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Private(XdgExporterUnstableV2Interface *q, Display *d, XdgForeignInterface *foreignInterface);
|
XdgExporterV2InterfacePrivate(XdgExporterV2Interface *_q, Display *display, XdgForeignV2Interface *foreignInterface);
|
||||||
|
|
||||||
XdgForeignInterface *foreignInterface;
|
XdgForeignV2Interface *foreignInterface;
|
||||||
QHash<QString, XdgExportedUnstableV2Interface *> exportedSurfaces;
|
QHash<QString, XdgExportedV2Interface *> exportedSurfaces;
|
||||||
|
XdgExporterV2Interface *q;
|
||||||
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 exportCallback(wl_client *client, wl_resource *resource, uint32_t id, wl_resource * surface);
|
|
||||||
|
|
||||||
XdgExporterUnstableV2Interface *q;
|
|
||||||
static const struct zxdg_exporter_v2_interface s_interface;
|
|
||||||
static const quint32 s_version;
|
static const quint32 s_version;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void zxdg_exporter_v2_destroy(Resource *resource) override;
|
||||||
|
void zxdg_exporter_v2_export_toplevel(Resource *resource, uint32_t id, wl_resource *surface) override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const quint32 XdgExporterUnstableV2Interface::Private::s_version = 1;
|
const quint32 XdgExporterV2InterfacePrivate::s_version = 1;
|
||||||
|
|
||||||
#ifndef K_DOXYGEN
|
XdgExporterV2Interface::XdgExporterV2Interface(Display *display, XdgForeignV2Interface *parent)
|
||||||
const struct zxdg_exporter_v2_interface XdgExporterUnstableV2Interface::Private::s_interface = {
|
: QObject(parent)
|
||||||
destroyCallback,
|
, d(new XdgExporterV2InterfacePrivate(this, display, parent))
|
||||||
exportCallback
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
XdgExporterUnstableV2Interface::XdgExporterUnstableV2Interface(Display *display, XdgForeignInterface *parent)
|
|
||||||
: Global(new Private(this, display, parent), parent)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
XdgExporterUnstableV2Interface::~XdgExporterUnstableV2Interface()
|
XdgExporterV2Interface::~XdgExporterV2Interface() = default;
|
||||||
{}
|
|
||||||
|
|
||||||
XdgExporterUnstableV2Interface::Private *XdgExporterUnstableV2Interface::d_func() const
|
XdgExportedV2Interface *XdgExporterV2Interface::exportedSurface(const QString &handle)
|
||||||
{
|
{
|
||||||
return reinterpret_cast<Private*>(d.data());
|
|
||||||
}
|
|
||||||
|
|
||||||
XdgExportedUnstableV2Interface *XdgExporterUnstableV2Interface::exportedSurface(const QString &handle)
|
|
||||||
{
|
|
||||||
Q_D();
|
|
||||||
|
|
||||||
auto it = d->exportedSurfaces.constFind(handle);
|
auto it = d->exportedSurfaces.constFind(handle);
|
||||||
if (it != d->exportedSurfaces.constEnd()) {
|
if (it != d->exportedSurfaces.constEnd()) {
|
||||||
return it.value();
|
return it.value();
|
||||||
|
@ -76,126 +76,90 @@ XdgExportedUnstableV2Interface *XdgExporterUnstableV2Interface::exportedSurface(
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XdgExporterUnstableV2Interface::Private::destroyCallback(wl_client *client, wl_resource *resource)
|
void XdgExporterV2InterfacePrivate::zxdg_exporter_v2_destroy(Resource *resource)
|
||||||
{
|
{
|
||||||
Q_UNUSED(client)
|
wl_resource_destroy(resource->handle);
|
||||||
Q_UNUSED(resource)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void XdgExporterUnstableV2Interface::Private::exportCallback(wl_client *client, wl_resource *resource, uint32_t id, wl_resource * surface)
|
void XdgExporterV2InterfacePrivate::zxdg_exporter_v2_export_toplevel(Resource *resource, uint32_t id, wl_resource *surface)
|
||||||
{
|
{
|
||||||
auto s = cast(resource);
|
SurfaceInterface *s = SurfaceInterface::get(surface);
|
||||||
QPointer <XdgExportedUnstableV2Interface> e = new XdgExportedUnstableV2Interface(s->q, surface);
|
if (!s) {
|
||||||
|
wl_resource_post_error(resource->handle, 0, "Invalid surface");
|
||||||
e->create(s->display->getConnection(client), wl_resource_get_version(resource), id);
|
|
||||||
|
|
||||||
if (!e->resource()) {
|
|
||||||
wl_resource_post_no_memory(resource);
|
|
||||||
delete e;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wl_resource *XdgExported_resource = wl_resource_create(resource->client(), &zxdg_exported_v2_interface, resource->version(), id);
|
||||||
|
if (!XdgExported_resource) {
|
||||||
|
wl_client_post_no_memory(resource->client());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
XdgExportedV2Interface * xdgExported = new XdgExportedV2Interface(s, XdgExported_resource);
|
||||||
const QString handle = QUuid::createUuid().toString();
|
const QString handle = QUuid::createUuid().toString();
|
||||||
|
|
||||||
//a surface not exported anymore
|
//a surface not exported anymore
|
||||||
connect(e.data(), &XdgExportedUnstableV2Interface::unbound,
|
QObject::connect(xdgExported, &XdgExportedV2Interface::destroyed,
|
||||||
s->q, [s, handle]() {
|
q, [this, handle]() {
|
||||||
s->exportedSurfaces.remove(handle);
|
exportedSurfaces.remove(handle);
|
||||||
emit s->q->surfaceUnexported(handle);
|
emit q->surfaceUnexported(handle);
|
||||||
});
|
});
|
||||||
|
|
||||||
//if the surface dies before this, this dies too
|
//if the surface dies before this, this dies too
|
||||||
connect(SurfaceInterface::get(surface), &QObject::destroyed,
|
QObject::connect(SurfaceInterface::get(surface), &QObject::destroyed,
|
||||||
s->q, [s, e, handle]() {
|
q, [this, xdgExported, handle]() {
|
||||||
if (e) {
|
if (xdgExported) {
|
||||||
e->deleteLater();
|
xdgExported->deleteLater();
|
||||||
}
|
}
|
||||||
s->exportedSurfaces.remove(handle);
|
exportedSurfaces.remove(handle);
|
||||||
emit s->q->surfaceUnexported(handle);
|
emit q->surfaceUnexported(handle);
|
||||||
});
|
});
|
||||||
|
|
||||||
s->exportedSurfaces[handle] = e;
|
exportedSurfaces[handle] = xdgExported;
|
||||||
zxdg_exported_v2_send_handle(e->resource(), handle.toUtf8().constData());
|
zxdg_exported_v2_send_handle(XdgExported_resource, handle.toUtf8().constData());
|
||||||
emit s->q->surfaceExported(handle, e);
|
emit q->surfaceExported(handle, xdgExported);
|
||||||
}
|
}
|
||||||
|
|
||||||
XdgExporterUnstableV2Interface::Private::Private(XdgExporterUnstableV2Interface *q, Display *d,XdgForeignInterface *foreignInterface)
|
XdgExporterV2InterfacePrivate::XdgExporterV2InterfacePrivate(XdgExporterV2Interface *_q, Display *display, XdgForeignV2Interface *foreignInterface)
|
||||||
: Global::Private(d, &zxdg_exporter_v2_interface, s_version)
|
: QtWaylandServer::zxdg_exporter_v2(*display, s_version)
|
||||||
, foreignInterface(foreignInterface)
|
, foreignInterface(foreignInterface)
|
||||||
, q(q)
|
, q(_q)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void XdgExporterUnstableV2Interface::Private::bind(wl_client *client, uint32_t version, uint32_t id)
|
class XdgImporterV2InterfacePrivate : public QtWaylandServer::zxdg_importer_v2
|
||||||
{
|
|
||||||
auto c = display->getConnection(client);
|
|
||||||
wl_resource *resource = c->createResource(&zxdg_exporter_v2_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 XdgExporterUnstableV2Interface::Private::unbind(wl_resource *resource)
|
|
||||||
{
|
|
||||||
Q_UNUSED(resource)
|
|
||||||
// TODO: implement?
|
|
||||||
}
|
|
||||||
|
|
||||||
class Q_DECL_HIDDEN XdgImporterUnstableV2Interface::Private : public Global::Private
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Private(XdgImporterUnstableV2Interface *q, Display *d, XdgForeignInterface *foreignInterface);
|
XdgImporterV2InterfacePrivate(XdgImporterV2Interface *_q, Display *display, XdgForeignV2Interface *foreignInterface);
|
||||||
|
|
||||||
XdgForeignInterface *foreignInterface;
|
XdgForeignV2Interface *foreignInterface;
|
||||||
|
QHash<QString, XdgImportedV2Interface *> importedSurfaces;
|
||||||
QHash<QString, XdgImportedUnstableV2Interface *> importedSurfaces;
|
|
||||||
|
|
||||||
//child->parent hash
|
//child->parent hash
|
||||||
QHash<SurfaceInterface *, XdgImportedUnstableV2Interface *> parents;
|
QHash<SurfaceInterface *, XdgImportedV2Interface *> parents;
|
||||||
//parent->child hash
|
//parent->child hash
|
||||||
QHash<XdgImportedUnstableV2Interface *, SurfaceInterface *> children;
|
QHash<XdgImportedV2Interface *, SurfaceInterface *> children;
|
||||||
|
XdgImporterV2Interface *q;
|
||||||
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 importCallback(wl_client *client, wl_resource *resource, uint32_t id, const char * handle);
|
|
||||||
|
|
||||||
XdgImporterUnstableV2Interface *q;
|
|
||||||
static const struct zxdg_importer_v2_interface s_interface;
|
|
||||||
static const quint32 s_version;
|
static const quint32 s_version;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void zxdg_importer_v2_destroy(Resource *resource) override;
|
||||||
|
void zxdg_importer_v2_import_toplevel(Resource *resource, uint32_t id, const QString &handle) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
const quint32 XdgImporterUnstableV2Interface::Private::s_version = 1;
|
const quint32 XdgImporterV2InterfacePrivate::s_version = 1;
|
||||||
|
|
||||||
#ifndef K_DOXYGEN
|
XdgImporterV2Interface::XdgImporterV2Interface(Display *display, XdgForeignV2Interface *parent)
|
||||||
const struct zxdg_importer_v2_interface XdgImporterUnstableV2Interface::Private::s_interface = {
|
: QObject(parent)
|
||||||
destroyCallback,
|
, d(new XdgImporterV2InterfacePrivate(this, display, parent))
|
||||||
importCallback
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
XdgImporterUnstableV2Interface::XdgImporterUnstableV2Interface(Display *display, XdgForeignInterface *parent)
|
|
||||||
: Global(new Private(this, display, parent), parent)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
XdgImporterUnstableV2Interface::~XdgImporterUnstableV2Interface()
|
XdgImporterV2Interface::~XdgImporterV2Interface() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
XdgImportedUnstableV2Interface *XdgImporterUnstableV2Interface::importedSurface(const QString &handle)
|
XdgImportedV2Interface *XdgImporterV2Interface::importedSurface(const QString &handle)
|
||||||
{
|
{
|
||||||
Q_D();
|
|
||||||
|
|
||||||
auto it = d->importedSurfaces.constFind(handle);
|
auto it = d->importedSurfaces.constFind(handle);
|
||||||
if (it != d->importedSurfaces.constEnd()) {
|
if (it != d->importedSurfaces.constEnd()) {
|
||||||
return it.value();
|
return it.value();
|
||||||
|
@ -203,246 +167,175 @@ XdgImportedUnstableV2Interface *XdgImporterUnstableV2Interface::importedSurface(
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
SurfaceInterface *XdgImporterUnstableV2Interface::transientFor(SurfaceInterface *surface)
|
SurfaceInterface *XdgImporterV2Interface::transientFor(SurfaceInterface *surface)
|
||||||
{
|
{
|
||||||
Q_D();
|
|
||||||
|
|
||||||
auto it = d->parents.constFind(surface);
|
auto it = d->parents.constFind(surface);
|
||||||
if (it == d->parents.constEnd()) {
|
if (it == d->parents.constEnd()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return SurfaceInterface::get((*it)->parentResource());
|
return (*it)->parentResource();
|
||||||
}
|
}
|
||||||
|
|
||||||
XdgImporterUnstableV2Interface::Private *XdgImporterUnstableV2Interface::d_func() const
|
void XdgImporterV2InterfacePrivate::zxdg_importer_v2_destroy(Resource *resource)
|
||||||
{
|
{
|
||||||
return reinterpret_cast<Private*>(d.data());
|
wl_resource_destroy(resource->handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XdgImporterUnstableV2Interface::Private::destroyCallback(wl_client *client, wl_resource *resource)
|
void XdgImporterV2InterfacePrivate::zxdg_importer_v2_import_toplevel(Resource *resource, uint32_t id, const QString &handle)
|
||||||
{
|
{
|
||||||
Q_UNUSED(client)
|
Q_ASSERT(foreignInterface);
|
||||||
Q_UNUSED(resource)
|
|
||||||
}
|
|
||||||
|
|
||||||
void XdgImporterUnstableV2Interface::Private::importCallback(wl_client *client, wl_resource *resource, uint32_t id, const char *h)
|
XdgExportedV2Interface *exp = foreignInterface->d->exporter->exportedSurface(handle);
|
||||||
{
|
|
||||||
auto s = cast(resource);
|
|
||||||
|
|
||||||
Q_ASSERT(s->foreignInterface);
|
|
||||||
const QString handle = QString::fromUtf8(h);
|
|
||||||
|
|
||||||
XdgExportedUnstableV2Interface *exp = s->foreignInterface->d->exporter->exportedSurface(handle);
|
|
||||||
if (!exp) {
|
if (!exp) {
|
||||||
zxdg_imported_v2_send_destroyed(resource);
|
zxdg_imported_v2_send_destroyed(resource->handle);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_resource *surface = exp->parentResource();
|
SurfaceInterface *surface = exp->parentResource();
|
||||||
if (!surface) {
|
if (!surface) {
|
||||||
zxdg_imported_v2_send_destroyed(resource);
|
zxdg_imported_v2_send_destroyed(resource->handle);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointer<XdgImportedUnstableV2Interface> imp = new XdgImportedUnstableV2Interface(s->q, surface);
|
wl_resource *XdgImported_resource = wl_resource_create(resource->client(), &zxdg_imported_v2_interface, resource->version(), id);
|
||||||
imp->create(s->display->getConnection(client), wl_resource_get_version(resource), id);
|
if (!XdgImported_resource) {
|
||||||
|
wl_client_post_no_memory(resource->client());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
XdgImportedV2Interface * XdgImported = new XdgImportedV2Interface(surface, XdgImported_resource);
|
||||||
|
|
||||||
//surface no longer exported
|
//surface no longer exported
|
||||||
connect(exp, &XdgExportedUnstableV2Interface::unbound,
|
QObject::connect(exp, &XdgExportedV2Interface::destroyed,
|
||||||
s->q, [s, imp, handle]() {
|
q, [this, XdgImported, handle, XdgImported_resource]() {
|
||||||
//imp valid when the exported is deleted before the imported
|
//imp valid when the exported is deleted before the imported
|
||||||
if (imp) {
|
if (XdgImported) {
|
||||||
zxdg_imported_v2_send_destroyed(imp->resource());
|
zxdg_imported_v2_send_destroyed(XdgImported_resource);
|
||||||
imp->deleteLater();
|
XdgImported->deleteLater();
|
||||||
}
|
}
|
||||||
s->importedSurfaces.remove(handle);
|
importedSurfaces.remove(handle);
|
||||||
emit s->q->surfaceUnimported(handle);
|
emit q->surfaceUnimported(handle);
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(imp.data(), &XdgImportedUnstableV2Interface::childChanged,
|
QObject::connect(XdgImported, &XdgImportedV2Interface::childChanged,
|
||||||
s->q, [s, imp](SurfaceInterface *child) {
|
q, [this, XdgImported](SurfaceInterface *child) {
|
||||||
//remove any previous association
|
//remove any previous association
|
||||||
auto it = s->children.find(imp);
|
auto it = children.find(XdgImported);
|
||||||
if (it != s->children.end()) {
|
if (it != children.end()) {
|
||||||
s->parents.remove(*it);
|
parents.remove(*it);
|
||||||
s->children.erase(it);
|
children.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
s->parents[child] = imp;
|
parents[child] = XdgImported;
|
||||||
s->children[imp] = child;
|
children[XdgImported] = child;
|
||||||
SurfaceInterface *parent = SurfaceInterface::get(imp->parentResource());
|
SurfaceInterface *parent = XdgImported->parentResource();
|
||||||
emit s->q->transientChanged(child, parent);
|
emit q->transientChanged(child, parent);
|
||||||
|
|
||||||
//child surface destroyed
|
//child surface destroyed
|
||||||
connect(child, &QObject::destroyed,
|
QObject::connect(child, &QObject::destroyed,
|
||||||
s->q, [s, child]() {
|
q, [this, child]() {
|
||||||
auto it = s->parents.find(child);
|
auto it = parents.find(child);
|
||||||
if (it != s->parents.end()) {
|
if (it != parents.end()) {
|
||||||
KWaylandServer::XdgImportedUnstableV2Interface* parent = *it;
|
KWaylandServer::XdgImportedV2Interface* parent = *it;
|
||||||
s->children.remove(*it);
|
children.remove(*it);
|
||||||
s->parents.erase(it);
|
parents.erase(it);
|
||||||
emit s->q->transientChanged(nullptr, SurfaceInterface::get(parent->parentResource()));
|
emit q->transientChanged(nullptr, parent->parentResource());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//surface no longer imported
|
//surface no longer imported
|
||||||
connect(imp.data(), &XdgImportedUnstableV2Interface::unbound,
|
QObject::connect(XdgImported, &XdgImportedV2Interface::destroyed,
|
||||||
s->q, [s, handle, imp]() {
|
q, [this, handle, XdgImported]() {
|
||||||
s->importedSurfaces.remove(handle);
|
importedSurfaces.remove(handle);
|
||||||
emit s->q->surfaceUnimported(handle);
|
emit q->surfaceUnimported(handle);
|
||||||
|
|
||||||
auto it = s->children.find(imp);
|
auto it = children.find(XdgImported);
|
||||||
if (it != s->children.end()) {
|
if (it != children.end()) {
|
||||||
KWaylandServer::SurfaceInterface* child = *it;
|
KWaylandServer::SurfaceInterface* child = *it;
|
||||||
s->parents.remove(*it);
|
parents.remove(*it);
|
||||||
s->children.erase(it);
|
children.erase(it);
|
||||||
emit s->q->transientChanged(child, nullptr);
|
emit q->transientChanged(child, nullptr);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!imp->resource()) {
|
importedSurfaces[handle] = XdgImported;
|
||||||
wl_resource_post_no_memory(resource);
|
emit q->surfaceImported(handle, XdgImported);
|
||||||
delete imp;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
s->importedSurfaces[handle] = imp;
|
|
||||||
emit s->q->surfaceImported(handle, imp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XdgImporterUnstableV2Interface::Private::Private(XdgImporterUnstableV2Interface *q, Display *d, XdgForeignInterface *foreignInterface)
|
XdgImporterV2InterfacePrivate::XdgImporterV2InterfacePrivate(XdgImporterV2Interface *_q, Display *display, XdgForeignV2Interface *foreignInterface)
|
||||||
: Global::Private(d, &zxdg_importer_v2_interface, s_version)
|
: QtWaylandServer::zxdg_importer_v2(*display, s_version)
|
||||||
, foreignInterface(foreignInterface)
|
, foreignInterface(foreignInterface)
|
||||||
, q(q)
|
, q(_q)
|
||||||
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void XdgImporterUnstableV2Interface::Private::bind(wl_client *client, uint32_t version, uint32_t id)
|
XdgExportedV2Interface::XdgExportedV2Interface(SurfaceInterface *surface, wl_resource *resource )
|
||||||
|
: QObject(nullptr)
|
||||||
|
, QtWaylandServer::zxdg_exported_v2(resource)
|
||||||
|
, surface(surface)
|
||||||
{
|
{
|
||||||
auto c = display->getConnection(client);
|
|
||||||
wl_resource *resource = c->createResource(&zxdg_importer_v2_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 XdgImporterUnstableV2Interface::Private::unbind(wl_resource *resource)
|
XdgExportedV2Interface::~XdgExportedV2Interface() = default;
|
||||||
|
|
||||||
|
SurfaceInterface *XdgExportedV2Interface::parentResource()
|
||||||
|
{
|
||||||
|
return surface;
|
||||||
|
}
|
||||||
|
|
||||||
|
void XdgExportedV2Interface::zxdg_exported_v2_destroy(Resource *resource)
|
||||||
|
{
|
||||||
|
wl_resource_destroy(resource->handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void XdgExportedV2Interface::zxdg_exported_v2_destroy_resource(Resource *resource)
|
||||||
{
|
{
|
||||||
Q_UNUSED(resource)
|
Q_UNUSED(resource)
|
||||||
// TODO: implement?
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Q_DECL_HIDDEN XdgExportedUnstableV2Interface::Private : public Resource::Private
|
XdgImportedV2Interface::XdgImportedV2Interface(SurfaceInterface *surface, wl_resource *resource)
|
||||||
{
|
: QObject(nullptr)
|
||||||
public:
|
, QtWaylandServer::zxdg_imported_v2(resource)
|
||||||
Private(XdgExportedUnstableV2Interface *q, XdgExporterUnstableV2Interface *c, wl_resource *parentResource);
|
, surface(surface)
|
||||||
~Private();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
XdgExportedUnstableV2Interface *q_func() {
|
|
||||||
return reinterpret_cast<XdgExportedUnstableV2Interface *>(q);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct zxdg_exported_v2_interface s_interface;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifndef K_DOXYGEN
|
|
||||||
const struct zxdg_exported_v2_interface XdgExportedUnstableV2Interface::Private::s_interface = {
|
|
||||||
resourceDestroyedCallback
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
XdgExportedUnstableV2Interface::XdgExportedUnstableV2Interface(XdgExporterUnstableV2Interface *parent, wl_resource *parentResource)
|
|
||||||
: Resource(new Private(this, parent, parentResource))
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
XdgExportedUnstableV2Interface::~XdgExportedUnstableV2Interface()
|
XdgImportedV2Interface::~XdgImportedV2Interface() = default;
|
||||||
{}
|
|
||||||
|
|
||||||
XdgExportedUnstableV2Interface::Private *XdgExportedUnstableV2Interface::d_func() const
|
SurfaceInterface *XdgImportedV2Interface::child() const
|
||||||
{
|
{
|
||||||
return reinterpret_cast<Private*>(d.data());
|
return parentOf.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
XdgExportedUnstableV2Interface::Private::Private(XdgExportedUnstableV2Interface *q, XdgExporterUnstableV2Interface *c, wl_resource *parentResource)
|
SurfaceInterface *XdgImportedV2Interface::parentResource()
|
||||||
: Resource::Private(q, c, parentResource, &zxdg_exported_v2_interface, &s_interface)
|
|
||||||
{
|
{
|
||||||
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
XdgExportedUnstableV2Interface::Private::~Private()
|
void XdgImportedV2Interface::zxdg_imported_v2_set_parent_of(Resource *resource, wl_resource *surface)
|
||||||
{}
|
|
||||||
|
|
||||||
class Q_DECL_HIDDEN XdgImportedUnstableV2Interface::Private : public Resource::Private
|
|
||||||
{
|
{
|
||||||
public:
|
Q_UNUSED(resource)
|
||||||
Private(XdgImportedUnstableV2Interface *q, XdgImporterUnstableV2Interface *c, wl_resource *parentResource);
|
|
||||||
~Private();
|
|
||||||
|
|
||||||
QPointer<SurfaceInterface> parentOf;
|
|
||||||
|
|
||||||
private:
|
|
||||||
static void setParentOfCallback(wl_client *client, wl_resource *resource, wl_resource * surface);
|
|
||||||
|
|
||||||
XdgImportedUnstableV2Interface *q_func() {
|
|
||||||
return reinterpret_cast<XdgImportedUnstableV2Interface *>(q);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct zxdg_imported_v2_interface s_interface;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifndef K_DOXYGEN
|
|
||||||
const struct zxdg_imported_v2_interface XdgImportedUnstableV2Interface::Private::s_interface = {
|
|
||||||
resourceDestroyedCallback,
|
|
||||||
setParentOfCallback
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
XdgImportedUnstableV2Interface::XdgImportedUnstableV2Interface(XdgImporterUnstableV2Interface *parent, wl_resource *parentResource)
|
|
||||||
: Resource(new Private(this, parent, parentResource))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
XdgImportedUnstableV2Interface::~XdgImportedUnstableV2Interface()
|
|
||||||
{}
|
|
||||||
|
|
||||||
XdgImportedUnstableV2Interface::Private *XdgImportedUnstableV2Interface::d_func() const
|
|
||||||
{
|
|
||||||
return reinterpret_cast<Private*>(d.data());
|
|
||||||
}
|
|
||||||
|
|
||||||
SurfaceInterface *XdgImportedUnstableV2Interface::child() const
|
|
||||||
{
|
|
||||||
Q_D();
|
|
||||||
return d->parentOf.data();
|
|
||||||
}
|
|
||||||
|
|
||||||
void XdgImportedUnstableV2Interface::Private::setParentOfCallback(wl_client *client, wl_resource *resource, wl_resource * surface)
|
|
||||||
{
|
|
||||||
Q_UNUSED(client)
|
|
||||||
|
|
||||||
auto s = cast<Private>(resource);
|
|
||||||
SurfaceInterface *surf = SurfaceInterface::get(surface);
|
SurfaceInterface *surf = SurfaceInterface::get(surface);
|
||||||
|
|
||||||
if (!surf) {
|
if (!surf) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
s->parentOf = surf;
|
parentOf = surf;
|
||||||
emit s->q_func()->childChanged(surf);
|
emit childChanged(surf);
|
||||||
}
|
}
|
||||||
|
|
||||||
XdgImportedUnstableV2Interface::Private::Private(XdgImportedUnstableV2Interface *q, XdgImporterUnstableV2Interface *c, wl_resource *parentResource)
|
void XdgImportedV2Interface::zxdg_imported_v2_destroy(Resource *resource)
|
||||||
: Resource::Private(q, c, parentResource, &zxdg_imported_v2_interface, &s_interface)
|
|
||||||
{
|
{
|
||||||
|
wl_resource_destroy(resource->handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
XdgImportedUnstableV2Interface::Private::~Private()
|
void XdgImportedV2Interface::zxdg_imported_v2_destroy_resource(Resource *resource)
|
||||||
{}
|
{
|
||||||
|
Q_UNUSED(resource)
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,7 @@
|
||||||
#ifndef KWAYLAND_SERVER_XDGFOREIGN_INTERFACE_H
|
#ifndef KWAYLAND_SERVER_XDGFOREIGN_INTERFACE_H
|
||||||
#define KWAYLAND_SERVER_XDGFOREIGN_INTERFACE_H
|
#define KWAYLAND_SERVER_XDGFOREIGN_INTERFACE_H
|
||||||
|
|
||||||
#include "global.h"
|
#include <QObject>
|
||||||
#include "resource.h"
|
|
||||||
|
|
||||||
#include <KWaylandServer/kwaylandserver_export.h>
|
#include <KWaylandServer/kwaylandserver_export.h>
|
||||||
|
|
||||||
|
@ -16,8 +15,9 @@ namespace KWaylandServer
|
||||||
|
|
||||||
class Display;
|
class Display;
|
||||||
class SurfaceInterface;
|
class SurfaceInterface;
|
||||||
class XdgExporterUnstableV2Interface;
|
class XdgExporterV2Interface;
|
||||||
class XdgImporterUnstableV2Interface;
|
class XdgImporterV2Interface;
|
||||||
|
class XdgForeignV2InterfacePrivate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class encapsulates the server side logic of the XdgForeign protocol.
|
* This class encapsulates the server side logic of the XdgForeign protocol.
|
||||||
|
@ -29,23 +29,12 @@ class XdgImporterUnstableV2Interface;
|
||||||
*
|
*
|
||||||
* @since 5.40
|
* @since 5.40
|
||||||
*/
|
*/
|
||||||
class KWAYLANDSERVER_EXPORT XdgForeignInterface : public QObject
|
class KWAYLANDSERVER_EXPORT XdgForeignV2Interface : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
XdgForeignInterface(Display *display, QObject *parent = nullptr);
|
XdgForeignV2Interface(Display *display, QObject *parent = nullptr);
|
||||||
~XdgForeignInterface();
|
~XdgForeignV2Interface() override;
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the native zxdg_exporter_v2 and zxdg_importer_v2 interfaces
|
|
||||||
* and announces them to the client.
|
|
||||||
*/
|
|
||||||
void create();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @returns true if theimporter and exporter are valid and functional
|
|
||||||
*/
|
|
||||||
bool isValid();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If a client did import a surface and set one of its own as child of the
|
* If a client did import a surface and set one of its own as child of the
|
||||||
|
@ -69,10 +58,9 @@ Q_SIGNALS:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class Display;
|
friend class Display;
|
||||||
friend class XdgExporterUnstableV2Interface;
|
friend class XdgExporterV2InterfacePrivate;
|
||||||
friend class XdgImporterUnstableV2Interface;
|
friend class XdgImporterV2InterfacePrivate;
|
||||||
class Private;
|
QScopedPointer<XdgForeignV2InterfacePrivate> d;
|
||||||
Private *d;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -6,102 +6,110 @@
|
||||||
#ifndef KWAYLAND_SERVER_XDGFOREIGNV2_INTERFACE_P_H
|
#ifndef KWAYLAND_SERVER_XDGFOREIGNV2_INTERFACE_P_H
|
||||||
#define KWAYLAND_SERVER_XDGFOREIGNV2_INTERFACE_P_H
|
#define KWAYLAND_SERVER_XDGFOREIGNV2_INTERFACE_P_H
|
||||||
|
|
||||||
#include "global.h"
|
#include "xdgforeign_v2_interface.h"
|
||||||
#include "resource.h"
|
#include "surface_interface_p.h"
|
||||||
|
|
||||||
|
#include <qwayland-server-xdg-foreign-unstable-v2.h>
|
||||||
|
|
||||||
namespace KWaylandServer
|
namespace KWaylandServer
|
||||||
{
|
{
|
||||||
|
|
||||||
class Display;
|
class Display;
|
||||||
class SurfaceInterface;
|
class SurfaceInterface;
|
||||||
class XdgExportedUnstableV2Interface;
|
class XdgExportedV2Interface;
|
||||||
class XdgImportedUnstableV2Interface;
|
class XdgImportedV2Interface;
|
||||||
|
class XdgExporterV2InterfacePrivate;
|
||||||
|
class XdgImporterV2InterfacePrivate;
|
||||||
|
class XdgExportedV2Interface;
|
||||||
|
class XdgImportedV2InterfacePrivate;
|
||||||
|
|
||||||
class Q_DECL_HIDDEN XdgForeignInterface::Private
|
class XdgForeignV2InterfacePrivate : public QObject
|
||||||
{
|
|
||||||
public:
|
|
||||||
Private(Display *display, XdgForeignInterface *q);
|
|
||||||
|
|
||||||
XdgForeignInterface *q;
|
|
||||||
XdgExporterUnstableV2Interface *exporter;
|
|
||||||
XdgImporterUnstableV2Interface *importer;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Q_DECL_HIDDEN XdgExporterUnstableV2Interface : public Global
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
virtual ~XdgExporterUnstableV2Interface();
|
XdgForeignV2InterfacePrivate(Display *display, XdgForeignV2Interface *q);
|
||||||
|
|
||||||
XdgExportedUnstableV2Interface *exportedSurface(const QString &handle);
|
XdgForeignV2Interface *q;
|
||||||
|
XdgExporterV2Interface *exporter;
|
||||||
|
XdgImporterV2Interface *importer;
|
||||||
|
};
|
||||||
|
|
||||||
|
class XdgExporterV2Interface : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit XdgExporterV2Interface(Display *display, XdgForeignV2Interface *parent = nullptr);
|
||||||
|
~XdgExporterV2Interface() override;
|
||||||
|
|
||||||
|
XdgExportedV2Interface *exportedSurface(const QString &handle);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void surfaceExported(const QString &handle, XdgExportedUnstableV2Interface *exported);
|
void surfaceExported(const QString &handle, XdgExportedV2Interface *exported);
|
||||||
void surfaceUnexported(const QString &handle);
|
void surfaceUnexported(const QString &handle);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit XdgExporterUnstableV2Interface(Display *display, XdgForeignInterface *parent = nullptr);
|
QScopedPointer<XdgExporterV2InterfacePrivate> d;
|
||||||
friend class Display;
|
|
||||||
friend class XdgForeignInterface;
|
|
||||||
class Private;
|
|
||||||
Private *d_func() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Q_DECL_HIDDEN XdgImporterUnstableV2Interface : public Global
|
class XdgImporterV2Interface : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
virtual ~XdgImporterUnstableV2Interface();
|
explicit XdgImporterV2Interface(Display *display, XdgForeignV2Interface *parent = nullptr);
|
||||||
|
~XdgImporterV2Interface() override;
|
||||||
|
|
||||||
XdgImportedUnstableV2Interface *importedSurface(const QString &handle);
|
XdgImportedV2Interface *importedSurface(const QString &handle);
|
||||||
SurfaceInterface *transientFor(SurfaceInterface *surface);
|
SurfaceInterface *transientFor(SurfaceInterface *surface);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void surfaceImported(const QString &handle, XdgImportedUnstableV2Interface *imported);
|
void surfaceImported(const QString &handle, XdgImportedV2Interface *imported);
|
||||||
void surfaceUnimported(const QString &handle);
|
void surfaceUnimported(const QString &handle);
|
||||||
void transientChanged(KWaylandServer::SurfaceInterface *child, KWaylandServer::SurfaceInterface *parent);
|
void transientChanged(KWaylandServer::SurfaceInterface *child, KWaylandServer::SurfaceInterface *parent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit XdgImporterUnstableV2Interface(Display *display, XdgForeignInterface *parent = nullptr);
|
QScopedPointer<XdgImporterV2InterfacePrivate> d;
|
||||||
friend class Display;
|
|
||||||
friend class XdgForeignInterface;
|
|
||||||
class Private;
|
|
||||||
Private *d_func() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Q_DECL_HIDDEN XdgExportedUnstableV2Interface : public Resource
|
class XdgExportedV2Interface : public QObject, QtWaylandServer::zxdg_exported_v2
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
public:
|
public:
|
||||||
virtual ~XdgExportedUnstableV2Interface();
|
explicit XdgExportedV2Interface(SurfaceInterface *surface, wl_resource *resource );
|
||||||
|
~XdgExportedV2Interface() override;
|
||||||
|
|
||||||
|
SurfaceInterface *parentResource();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit XdgExportedUnstableV2Interface(XdgExporterUnstableV2Interface *parent, wl_resource *parentResource);
|
SurfaceInterface *surface;
|
||||||
friend class XdgExporterUnstableV2Interface;
|
|
||||||
|
protected:
|
||||||
|
void zxdg_exported_v2_destroy(Resource *resource) override;
|
||||||
|
void zxdg_exported_v2_destroy_resource(Resource *resource) override;
|
||||||
|
|
||||||
class Private;
|
|
||||||
Private *d_func() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Q_DECL_HIDDEN XdgImportedUnstableV2Interface : public Resource
|
class XdgImportedV2Interface : public QObject, QtWaylandServer::zxdg_imported_v2
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
virtual ~XdgImportedUnstableV2Interface();
|
explicit XdgImportedV2Interface(SurfaceInterface *surface, wl_resource *resource);
|
||||||
|
~XdgImportedV2Interface() override;
|
||||||
|
|
||||||
SurfaceInterface *child() const;
|
SurfaceInterface *child() const;
|
||||||
|
SurfaceInterface *parentResource();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void childChanged(KWaylandServer::SurfaceInterface *child);
|
void childChanged(KWaylandServer::SurfaceInterface *child);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit XdgImportedUnstableV2Interface(XdgImporterUnstableV2Interface *parent, wl_resource *parentResource);
|
SurfaceInterface *surface;
|
||||||
friend class XdgImporterUnstableV2Interface;
|
QPointer<SurfaceInterface> parentOf;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void zxdg_imported_v2_set_parent_of(Resource *resource, wl_resource *surface) override;
|
||||||
|
void zxdg_imported_v2_destroy(Resource *resource) override;
|
||||||
|
void zxdg_imported_v2_destroy_resource(Resource *resource) override;
|
||||||
|
|
||||||
class Private;
|
|
||||||
Private *d_func() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue