2020-03-15 15:19:28 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
2020-06-25 15:27:52 +00:00
|
|
|
SPDX-FileCopyrightText: 2020 David Edmundson <davidedmundson@kde.org>
|
2014-11-04 14:10:22 +00:00
|
|
|
|
2020-03-15 15:19:28 +00:00
|
|
|
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
|
|
|
*/
|
2014-11-04 14:10:22 +00:00
|
|
|
#include "datadevicemanager_interface.h"
|
2017-11-26 15:31:57 +00:00
|
|
|
#include "datasource_interface.h"
|
2014-11-13 14:07:31 +00:00
|
|
|
#include "global_p.h"
|
2014-11-04 14:10:22 +00:00
|
|
|
#include "display.h"
|
2014-11-27 12:38:24 +00:00
|
|
|
#include "seat_interface_p.h"
|
2014-11-04 14:10:22 +00:00
|
|
|
// Wayland
|
2020-06-25 15:27:52 +00:00
|
|
|
#include <qwayland-server-wayland.h>
|
2014-11-04 14:10:22 +00:00
|
|
|
|
2020-04-29 14:56:38 +00:00
|
|
|
namespace KWaylandServer
|
2014-11-04 14:10:22 +00:00
|
|
|
{
|
|
|
|
|
2020-06-25 15:27:52 +00:00
|
|
|
static const quint32 s_version = 3;
|
|
|
|
|
|
|
|
class DataDeviceManagerInterfacePrivate : public QtWaylandServer::wl_data_device_manager
|
2014-11-04 14:10:22 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-06-25 15:27:52 +00:00
|
|
|
DataDeviceManagerInterfacePrivate(DataDeviceManagerInterface *q, Display *d);
|
2014-11-04 14:10:22 +00:00
|
|
|
|
2020-06-25 15:27:52 +00:00
|
|
|
DataDeviceManagerInterface *q;
|
2014-11-04 14:10:22 +00:00
|
|
|
private:
|
|
|
|
void createDataSource(wl_client *client, wl_resource *resource, uint32_t id);
|
2014-11-06 09:02:49 +00:00
|
|
|
void getDataDevice(wl_client *client, wl_resource *resource, uint32_t id, wl_resource *seat);
|
2014-11-04 14:10:22 +00:00
|
|
|
|
2020-06-25 15:27:52 +00:00
|
|
|
protected:
|
|
|
|
void data_device_manager_create_data_source(Resource *resource, uint32_t id) override;
|
|
|
|
void data_device_manager_get_data_device(Resource *resource, uint32_t id, wl_resource *seat) override;
|
2014-11-04 14:10:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-06-25 15:27:52 +00:00
|
|
|
DataDeviceManagerInterfacePrivate::DataDeviceManagerInterfacePrivate(DataDeviceManagerInterface *q, Display *d)
|
|
|
|
: QtWaylandServer::wl_data_device_manager(*d, s_version)
|
2014-11-04 14:10:22 +00:00
|
|
|
, q(q)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-06-25 15:27:52 +00:00
|
|
|
void DataDeviceManagerInterfacePrivate::data_device_manager_create_data_source(Resource *resource, uint32_t id)
|
2014-11-04 14:10:22 +00:00
|
|
|
{
|
2020-06-25 15:27:52 +00:00
|
|
|
wl_resource *data_source_resource = wl_resource_create(resource->client(), &wl_data_source_interface, resource->version(), id);
|
|
|
|
if (!data_source_resource) {
|
|
|
|
wl_resource_post_no_memory(resource->handle);
|
2014-11-04 14:10:22 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-06-25 15:27:52 +00:00
|
|
|
DataSourceInterface *dataSource = new DataSourceInterface(q, data_source_resource);
|
2014-11-04 14:10:22 +00:00
|
|
|
emit q->dataSourceCreated(dataSource);
|
|
|
|
}
|
|
|
|
|
2020-06-25 15:27:52 +00:00
|
|
|
void DataDeviceManagerInterfacePrivate::data_device_manager_get_data_device(Resource *resource, uint32_t id, wl_resource *seat)
|
2014-11-06 09:02:49 +00:00
|
|
|
{
|
2014-11-27 12:38:24 +00:00
|
|
|
SeatInterface *s = SeatInterface::get(seat);
|
|
|
|
Q_ASSERT(s);
|
2020-06-25 15:27:52 +00:00
|
|
|
if (!s) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_resource *data_device_resource = wl_resource_create(resource->client(), &wl_data_device_interface, resource->version(), id);
|
|
|
|
if (!data_device_resource) {
|
|
|
|
wl_resource_post_no_memory(resource->handle);
|
2014-11-06 09:02:49 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-06-25 15:27:52 +00:00
|
|
|
DataDeviceInterface *dataDevice = new DataDeviceInterface(s, data_device_resource);
|
2014-11-06 09:02:49 +00:00
|
|
|
emit q->dataDeviceCreated(dataDevice);
|
2014-11-04 14:10:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DataDeviceManagerInterface::DataDeviceManagerInterface(Display *display, QObject *parent)
|
2020-06-25 15:27:52 +00:00
|
|
|
: QObject(parent)
|
|
|
|
, d(new DataDeviceManagerInterfacePrivate(this, display))
|
2014-11-04 14:10:22 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-11-13 14:07:31 +00:00
|
|
|
DataDeviceManagerInterface::~DataDeviceManagerInterface() = default;
|
2014-11-04 14:10:22 +00:00
|
|
|
|
|
|
|
}
|