KWin
Loading...
Searching...
No Matches
datadevicemanager.cpp
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
3 SPDX-FileCopyrightText: 2020 David Edmundson <davidedmundson@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6*/
7#include "datadevicemanager.h"
8#include "datasource.h"
9#include "display.h"
10#include "seat_p.h"
11// Wayland
12#include <qwayland-server-wayland.h>
13
14namespace KWin
15{
16static const quint32 s_version = 3;
17
18class DataDeviceManagerInterfacePrivate : public QtWaylandServer::wl_data_device_manager
19{
20public:
22
24
25private:
26 void createDataSource(wl_client *client, wl_resource *resource, uint32_t id);
27 void getDataDevice(wl_client *client, wl_resource *resource, uint32_t id, wl_resource *seat);
28
29protected:
30 void data_device_manager_create_data_source(Resource *resource, uint32_t id) override;
31 void data_device_manager_get_data_device(Resource *resource, uint32_t id, wl_resource *seat) override;
32};
33
35 : QtWaylandServer::wl_data_device_manager(*d, s_version)
36 , q(q)
37{
38}
39
41{
42 wl_resource *data_source_resource = wl_resource_create(resource->client(), &wl_data_source_interface, resource->version(), id);
43 if (!data_source_resource) {
44 wl_resource_post_no_memory(resource->handle);
45 return;
46 }
47 DataSourceInterface *dataSource = new DataSourceInterface(data_source_resource);
48 Q_EMIT q->dataSourceCreated(dataSource);
49}
50
51void DataDeviceManagerInterfacePrivate::data_device_manager_get_data_device(Resource *resource, uint32_t id, wl_resource *seat)
52{
54 Q_ASSERT(s);
55 if (!s) {
56 return;
57 }
58
59 wl_resource *data_device_resource = wl_resource_create(resource->client(), &wl_data_device_interface, resource->version(), id);
60 if (!data_device_resource) {
61 wl_resource_post_no_memory(resource->handle);
62 return;
63 }
64 DataDeviceInterface *dataDevice = new DataDeviceInterface(s, data_device_resource);
65 Q_EMIT q->dataDeviceCreated(dataDevice);
66}
67
69 : QObject(parent)
70 , d(new DataDeviceManagerInterfacePrivate(this, display))
71{
72}
73
75
76}
77
78#include "moc_datadevicemanager.cpp"
DataDeviceInterface allows clients to share data by copy-and-paste and drag-and-drop.
Definition datadevice.h:80
Represents the Global for wl_data_device_manager interface.
DataDeviceManagerInterface(Display *display, QObject *parent=nullptr)
void dataDeviceCreated(KWin::DataDeviceInterface *)
void dataSourceCreated(KWin::DataSourceInterface *)
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
DataDeviceManagerInterfacePrivate(DataDeviceManagerInterface *q, Display *d)
Represents the Resource for the wl_data_source interface.
Definition datasource.h:23
Class holding the Wayland server display loop.
Definition display.h:34
Represents a Seat on the Wayland Display.
Definition seat.h:134
static SeatInterface * get(wl_resource *native)
Definition seat.cpp:429