Drop Global and Resource classes
They're unused.
This commit is contained in:
parent
0d2879c62d
commit
e4bf7e0334
9 changed files with 0 additions and 501 deletions
|
@ -21,7 +21,6 @@ set(SERVER_LIB_SRCS
|
|||
eglstream_controller_interface.cpp
|
||||
fakeinput_interface.cpp
|
||||
filtered_display.cpp
|
||||
global.cpp
|
||||
idle_interface.cpp
|
||||
idleinhibit_v1_interface.cpp
|
||||
inputmethod_v1_interface.cpp
|
||||
|
@ -47,7 +46,6 @@ set(SERVER_LIB_SRCS
|
|||
primaryselectionsource_v1_interface.cpp
|
||||
region_interface.cpp
|
||||
relativepointer_v1_interface.cpp
|
||||
resource.cpp
|
||||
screencast_v1_interface.cpp
|
||||
seat_interface.cpp
|
||||
server_decoration_interface.cpp
|
||||
|
@ -342,7 +340,6 @@ set(SERVER_LIB_HEADERS
|
|||
eglstream_controller_interface.h
|
||||
fakeinput_interface.h
|
||||
filtered_display.h
|
||||
global.h
|
||||
idle_interface.h
|
||||
idleinhibit_v1_interface.h
|
||||
inputmethod_v1_interface.h
|
||||
|
@ -364,7 +361,6 @@ set(SERVER_LIB_HEADERS
|
|||
pointergestures_v1_interface.h
|
||||
primaryselectiondevicemanager_v1_interface.h
|
||||
relativepointer_v1_interface.h
|
||||
resource.h
|
||||
screencast_v1_interface.h
|
||||
seat_interface.h
|
||||
server_decoration_interface.h
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "datacontroldevicemanager_v1_interface.h"
|
||||
#include "datacontroldevice_v1_interface.h"
|
||||
#include "datacontrolsource_v1_interface.h"
|
||||
#include "global_p.h"
|
||||
#include "display.h"
|
||||
#include "seat_interface_p.h"
|
||||
// Wayland
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
*/
|
||||
#include "datadevicemanager_interface.h"
|
||||
#include "datasource_interface.h"
|
||||
#include "global_p.h"
|
||||
#include "display.h"
|
||||
#include "seat_interface_p.h"
|
||||
// Wayland
|
||||
|
|
|
@ -1,95 +0,0 @@
|
|||
/*
|
||||
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||
*/
|
||||
#include "global.h"
|
||||
#include "global_p.h"
|
||||
#include "display.h"
|
||||
// wayland
|
||||
#include <wayland-server.h>
|
||||
|
||||
namespace KWaylandServer
|
||||
{
|
||||
|
||||
Global::Private::Private(Display *d, const wl_interface *interface, quint32 version)
|
||||
: display(d)
|
||||
, m_interface(interface)
|
||||
, m_version(version)
|
||||
{
|
||||
}
|
||||
|
||||
Global::Private::~Private() = default;
|
||||
|
||||
void Global::Private::bind(wl_client *client, void *data, uint32_t version, uint32_t id)
|
||||
{
|
||||
auto d = reinterpret_cast<Private*>(data);
|
||||
d->bind(client, version, id);
|
||||
}
|
||||
|
||||
void Global::Private::create()
|
||||
{
|
||||
Q_ASSERT(!global);
|
||||
global = wl_global_create(*display, m_interface, m_version, this, bind);
|
||||
}
|
||||
|
||||
static void handleDisplayDestroyed(struct wl_listener *listener, void *data)
|
||||
{
|
||||
Q_UNUSED(data)
|
||||
Global *global = static_cast<DisplayDestroyListener *>(listener)->global;
|
||||
global->destroy();
|
||||
}
|
||||
|
||||
Global::Global(Global::Private *d, QObject *parent)
|
||||
: QObject(parent)
|
||||
, d(d)
|
||||
{
|
||||
d->displayDestroyListener.notify = handleDisplayDestroyed;
|
||||
d->displayDestroyListener.global = this;
|
||||
d->displayDestroyListener.link.next = nullptr;
|
||||
d->displayDestroyListener.link.prev = nullptr;
|
||||
wl_display_add_destroy_listener(*d->display, &d->displayDestroyListener);
|
||||
}
|
||||
|
||||
Global::~Global()
|
||||
{
|
||||
destroy();
|
||||
wl_list_remove(&d->displayDestroyListener.link);
|
||||
}
|
||||
|
||||
void Global::create()
|
||||
{
|
||||
d->create();
|
||||
}
|
||||
|
||||
void Global::destroy()
|
||||
{
|
||||
if (!d->global) {
|
||||
return;
|
||||
}
|
||||
Q_EMIT aboutToDestroyGlobal();
|
||||
wl_global_destroy(d->global);
|
||||
d->global = nullptr;
|
||||
}
|
||||
|
||||
bool Global::isValid() const
|
||||
{
|
||||
return d->global != nullptr;
|
||||
}
|
||||
|
||||
Global::operator wl_global*() const
|
||||
{
|
||||
return d->global;
|
||||
}
|
||||
|
||||
Global::operator wl_global*()
|
||||
{
|
||||
return d->global;
|
||||
}
|
||||
|
||||
Display *Global::display()
|
||||
{
|
||||
return d->display;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
/*
|
||||
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <KWaylandServer/kwaylandserver_export.h>
|
||||
|
||||
struct wl_global;
|
||||
|
||||
namespace KWaylandServer
|
||||
{
|
||||
class Display;
|
||||
|
||||
/**
|
||||
* @brief Base class for all Globals.
|
||||
*
|
||||
* Any class representing a Global should be derived from this base class.
|
||||
* This class provides common functionality for all globals. A global is an
|
||||
* object listed as an interface on the registry on client side.
|
||||
*
|
||||
* Normally a Global gets factored by the Display. For each Global-derived class there
|
||||
* is a dedicated factory method. After creating an instance through the factory method
|
||||
* it is not yet announced on the registry. One needs to call ::create on it. This allows
|
||||
* to setup the Global before it gets announced, ensuring that the client's state is correct
|
||||
* from the start.
|
||||
*
|
||||
* As an example shown for @link OutputInterface @endlink:
|
||||
* @code
|
||||
* Display *display; // The existing display
|
||||
* auto o = display->createOutput();
|
||||
* o->setManufacturer(QStringLiteral("The KDE Community"));
|
||||
* // setup further data on the OutputInterface
|
||||
* o->create(); // announces OutputInterface
|
||||
* @endcode
|
||||
*
|
||||
* @see Display
|
||||
*
|
||||
*/
|
||||
class KWAYLANDSERVER_EXPORT Global : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
virtual ~Global();
|
||||
/**
|
||||
* Creates the global by creating a native wl_global and by that announcing it
|
||||
* to the clients.
|
||||
*/
|
||||
void create();
|
||||
/**
|
||||
* Destroys the low level wl_global. Afterwards the Global is no longer shown to clients.
|
||||
*/
|
||||
void destroy();
|
||||
/**
|
||||
* @returns whether the Global got created
|
||||
*/
|
||||
bool isValid() const;
|
||||
|
||||
/**
|
||||
* @returns the Display the Global got created on.
|
||||
*/
|
||||
Display *display();
|
||||
|
||||
/**
|
||||
* Cast operator to the native wl_global this Global represents.
|
||||
*/
|
||||
operator wl_global*();
|
||||
/**
|
||||
* Cast operator to the native wl_global this Global represents.
|
||||
*/
|
||||
operator wl_global*() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* This signal is emitted when the client is in the process of removing the wl_global.
|
||||
* At the time the signal is emitted the global is still valid and allows to perform
|
||||
* cleanup tasks.
|
||||
*/
|
||||
void aboutToDestroyGlobal();
|
||||
|
||||
protected:
|
||||
class Private;
|
||||
explicit Global(Private *d, QObject *parent = nullptr);
|
||||
QScopedPointer<Private> d;
|
||||
};
|
||||
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
#include <wayland-server-core.h>
|
||||
|
||||
namespace KWaylandServer
|
||||
{
|
||||
|
||||
struct DisplayDestroyListener : public wl_listener
|
||||
{
|
||||
Global *global = nullptr;
|
||||
};
|
||||
|
||||
class Global::Private
|
||||
{
|
||||
public:
|
||||
static constexpr quint32 version = 0;
|
||||
virtual ~Private();
|
||||
void create();
|
||||
|
||||
// We need to reset display from the destroy listener, but due to the private class
|
||||
// being nested, this is not easy to do so. Either way, we are moving away from the
|
||||
// old approach, so it's not worth wasting our time.
|
||||
QPointer<Display> display;
|
||||
wl_global *global = nullptr;
|
||||
DisplayDestroyListener displayDestroyListener;
|
||||
|
||||
protected:
|
||||
Private(Display *d, const wl_interface *interface, quint32 version);
|
||||
virtual void bind(wl_client *client, uint32_t version, uint32_t id) = 0;
|
||||
|
||||
static void bind(wl_client *client, void *data, uint32_t version, uint32_t id);
|
||||
|
||||
const wl_interface *const m_interface;
|
||||
const quint32 m_version;
|
||||
};
|
||||
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
/*
|
||||
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||
*/
|
||||
#include "resource.h"
|
||||
#include "resource_p.h"
|
||||
#include "clientconnection.h"
|
||||
|
||||
#include <wayland-server.h>
|
||||
|
||||
namespace KWaylandServer
|
||||
{
|
||||
|
||||
QList<Resource::Private*> Resource::Private::s_allResources;
|
||||
|
||||
Resource::Private::Private(Resource *q, Global *g, wl_resource *parentResource, const wl_interface *interface, const void *implementation)
|
||||
: parentResource(parentResource)
|
||||
, global(g)
|
||||
, q(q)
|
||||
, m_interface(interface)
|
||||
, m_interfaceImplementation(implementation)
|
||||
{
|
||||
s_allResources << this;
|
||||
}
|
||||
|
||||
Resource::Private::~Private()
|
||||
{
|
||||
s_allResources.removeAll(this);
|
||||
if (resource) {
|
||||
wl_resource_destroy(resource);
|
||||
}
|
||||
}
|
||||
|
||||
void Resource::Private::create(ClientConnection *c, quint32 version, quint32 id)
|
||||
{
|
||||
Q_ASSERT(!resource);
|
||||
Q_ASSERT(!client);
|
||||
client = c;
|
||||
resource = client->createResource(m_interface, version, id);
|
||||
if (!resource) {
|
||||
return;
|
||||
}
|
||||
wl_resource_set_implementation(resource, m_interfaceImplementation, this, unbind);
|
||||
}
|
||||
|
||||
void Resource::Private::unbind(wl_resource *r)
|
||||
{
|
||||
Private *p = cast<Private>(r);
|
||||
Q_EMIT p->q->aboutToBeUnbound();
|
||||
p->resource = nullptr;
|
||||
Q_EMIT p->q->unbound();
|
||||
p->q->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
void Resource::Private::resourceDestroyedCallback(wl_client *client, wl_resource *resource)
|
||||
{
|
||||
Q_UNUSED(client)
|
||||
wl_resource_destroy(resource);
|
||||
}
|
||||
|
||||
Resource::Resource(Resource::Private *d, QObject *parent)
|
||||
: QObject(parent)
|
||||
, d(d)
|
||||
{
|
||||
}
|
||||
|
||||
Resource::~Resource() = default;
|
||||
|
||||
void Resource::create(ClientConnection *client, quint32 version, quint32 id)
|
||||
{
|
||||
d->create(client, version, id);
|
||||
}
|
||||
|
||||
ClientConnection *Resource::client()
|
||||
{
|
||||
return d->client;
|
||||
}
|
||||
|
||||
Global *Resource::global()
|
||||
{
|
||||
return d->global;
|
||||
}
|
||||
|
||||
wl_resource *Resource::resource()
|
||||
{
|
||||
return d->resource;
|
||||
}
|
||||
|
||||
wl_resource *Resource::parentResource() const
|
||||
{
|
||||
return d->parentResource;
|
||||
}
|
||||
|
||||
quint32 Resource::id() const
|
||||
{
|
||||
if (!d->resource) {
|
||||
return 0;
|
||||
}
|
||||
return wl_resource_get_id(d->resource);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <KWaylandServer/kwaylandserver_export.h>
|
||||
|
||||
struct wl_client;
|
||||
struct wl_resource;
|
||||
|
||||
namespace KWaylandServer
|
||||
{
|
||||
|
||||
class ClientConnection;
|
||||
class Global;
|
||||
|
||||
/**
|
||||
* @brief Represents a bound Resource.
|
||||
*
|
||||
* A Resource normally gets created by a @link Global @endlink.
|
||||
*
|
||||
* The Resource is a base class for all specific resources and provides
|
||||
* access to various common aspects.
|
||||
*/
|
||||
class KWAYLANDSERVER_EXPORT Resource : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
virtual ~Resource();
|
||||
void create(ClientConnection *client, quint32 version, quint32 id);
|
||||
|
||||
/**
|
||||
* @returns the native wl_resource this Resource was created for.
|
||||
*/
|
||||
wl_resource *resource();
|
||||
/**
|
||||
* @returns The ClientConnection for which the Resource was created.
|
||||
*/
|
||||
ClientConnection *client();
|
||||
/**
|
||||
* @returns The Global which created the Resource.
|
||||
*/
|
||||
Global *global();
|
||||
/**
|
||||
* @returns the native parent wl_resource, e.g. the wl_resource bound on the Global
|
||||
*/
|
||||
wl_resource *parentResource() const;
|
||||
/**
|
||||
* @returns The id of this Resource if it is created, otherwise @c 0.
|
||||
*
|
||||
* This is a convenient wrapper for wl_resource_get_id.
|
||||
*/
|
||||
quint32 id() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* This signal is emitted when the client unbound this Resource.
|
||||
* The Resource will be deleted in the next event cycle after this event.
|
||||
*/
|
||||
void unbound();
|
||||
/**
|
||||
* This signal is emitted when the client is in the process of unbinding the Resource.
|
||||
* In opposite to @link{unbound} the @link{resource} is still valid and allows to perform
|
||||
* cleanup tasks. Example: send a keyboard leave for the Surface which is in the process of
|
||||
* getting destroyed.
|
||||
*
|
||||
* @see unbound
|
||||
*/
|
||||
void aboutToBeUnbound();
|
||||
|
||||
protected:
|
||||
class Private;
|
||||
explicit Resource(Private *d, QObject *parent = nullptr);
|
||||
QScopedPointer<Private> d;
|
||||
|
||||
};
|
||||
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
/*
|
||||
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "resource.h"
|
||||
#include <wayland-server.h>
|
||||
#include <type_traits>
|
||||
|
||||
namespace KWaylandServer
|
||||
{
|
||||
|
||||
class Resource::Private
|
||||
{
|
||||
public:
|
||||
virtual ~Private();
|
||||
void create(ClientConnection *client, quint32 version, quint32 id);
|
||||
|
||||
wl_resource *parentResource = nullptr;
|
||||
wl_resource *resource = nullptr;
|
||||
ClientConnection *client = nullptr;
|
||||
Global *global;
|
||||
|
||||
template <typename ResourceDerived>
|
||||
static ResourceDerived *get(wl_resource *native) {
|
||||
static_assert(std::is_base_of<Resource, ResourceDerived>::value,
|
||||
"ResourceDerived must be derived from Resource");
|
||||
if (!native) {
|
||||
return nullptr;
|
||||
}
|
||||
auto it = std::find_if(s_allResources.constBegin(), s_allResources.constEnd(),
|
||||
[native](Private *p) {
|
||||
return p->resource == native;
|
||||
}
|
||||
);
|
||||
if (it == s_allResources.constEnd()) {
|
||||
return nullptr;
|
||||
}
|
||||
return reinterpret_cast<ResourceDerived*>((*it)->q);
|
||||
}
|
||||
template <typename ResourceDerived>
|
||||
static ResourceDerived *get(quint32 id, const ClientConnection *c) {
|
||||
static_assert(std::is_base_of<Resource, ResourceDerived>::value,
|
||||
"ResourceDerived must be derived from Resource");
|
||||
auto it = std::find_if(s_allResources.constBegin(), s_allResources.constEnd(),
|
||||
[id, c](Private *p) {
|
||||
return c == p->client && p->resource && wl_resource_get_id(p->resource) == id;
|
||||
}
|
||||
);
|
||||
if (it == s_allResources.constEnd()) {
|
||||
return nullptr;
|
||||
}
|
||||
return reinterpret_cast<ResourceDerived*>((*it)->q);
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit Private(Resource *q, Global *g, wl_resource *parentResource, const wl_interface *interface, const void *implementation);
|
||||
|
||||
template <typename Derived>
|
||||
static Derived *cast(wl_resource *r) {
|
||||
static_assert(std::is_base_of<Private, Derived>::value,
|
||||
"Derived must be derived from Resource::Private");
|
||||
return r ? reinterpret_cast<Derived*>(wl_resource_get_user_data(r)) : nullptr;
|
||||
}
|
||||
static void unbind(wl_resource *resource);
|
||||
static void resourceDestroyedCallback(wl_client *client, wl_resource *resource);
|
||||
|
||||
Resource *q;
|
||||
static QList<Private*> s_allResources;
|
||||
|
||||
private:
|
||||
const wl_interface *const m_interface;
|
||||
const void *const m_interfaceImplementation;
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in a new issue