KWaylandServer

datadevicemanager_interface.cpp
1 /*
2  SPDX-FileCopyrightText: 2014 Martin Gräßlin <[email protected]>
3  SPDX-FileCopyrightText: 2020 David Edmundson <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6 */
7 #include "datadevicemanager_interface.h"
8 #include "datasource_interface.h"
9 #include "display.h"
10 #include "seat_interface_p.h"
11 // Wayland
12 #include <qwayland-server-wayland.h>
13 
14 namespace KWaylandServer
15 {
16 static const quint32 s_version = 3;
17 
18 class DataDeviceManagerInterfacePrivate : public QtWaylandServer::wl_data_device_manager
19 {
20 public:
21  DataDeviceManagerInterfacePrivate(DataDeviceManagerInterface *q, Display *d);
22 
23  DataDeviceManagerInterface *q;
24 
25 private:
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 
29 protected:
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 
34 DataDeviceManagerInterfacePrivate::DataDeviceManagerInterfacePrivate(DataDeviceManagerInterface *q, Display *d)
35  : QtWaylandServer::wl_data_device_manager(*d, s_version)
36  , q(q)
37 {
38 }
39 
40 void DataDeviceManagerInterfacePrivate::data_device_manager_create_data_source(Resource *resource, uint32_t id)
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(q, data_source_resource);
48  Q_EMIT q->dataSourceCreated(dataSource);
49 }
50 
51 void DataDeviceManagerInterfacePrivate::data_device_manager_get_data_device(Resource *resource, uint32_t id, wl_resource *seat)
52 {
53  SeatInterface *s = SeatInterface::get(seat);
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 
68 DataDeviceManagerInterface::DataDeviceManagerInterface(Display *display, QObject *parent)
69  : QObject(parent)
70  , d(new DataDeviceManagerInterfacePrivate(this, display))
71 {
72 }
73 
74 DataDeviceManagerInterface::~DataDeviceManagerInterface() = default;
75 
76 }
QObject * parent() const const
Q_EMITQ_EMIT
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 23 2021 23:08:27 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.