KWaylandServer

datacontroldevicemanager_v1_interface.cpp
1 /*
2  SPDX-FileCopyrightText: 2020 David Edmundson <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 
7 #include "datacontroldevicemanager_v1_interface.h"
8 #include "datacontroldevice_v1_interface.h"
9 #include "datacontrolsource_v1_interface.h"
10 #include "display.h"
11 #include "seat_interface_p.h"
12 // Wayland
13 #include <qwayland-server-wlr-data-control-unstable-v1.h>
14 
15 static const int s_version = 2;
16 namespace KWaylandServer
17 {
18 class DataControlDeviceManagerV1InterfacePrivate : public QtWaylandServer::zwlr_data_control_manager_v1
19 {
20 public:
21  DataControlDeviceManagerV1InterfacePrivate(DataControlDeviceManagerV1Interface *q, Display *d);
22 
23  DataControlDeviceManagerV1Interface *q;
24 
25 protected:
26  void zwlr_data_control_manager_v1_create_data_source(Resource *resource, uint32_t id) override;
27  void zwlr_data_control_manager_v1_get_data_device(Resource *resource, uint32_t id, wl_resource *seat) override;
28  void zwlr_data_control_manager_v1_destroy(Resource *resource) override;
29 };
30 
31 DataControlDeviceManagerV1InterfacePrivate::DataControlDeviceManagerV1InterfacePrivate(DataControlDeviceManagerV1Interface *q, Display *d)
32  : QtWaylandServer::zwlr_data_control_manager_v1(*d, s_version)
33  , q(q)
34 {
35 }
36 
37 void DataControlDeviceManagerV1InterfacePrivate::zwlr_data_control_manager_v1_create_data_source(Resource *resource, uint32_t id)
38 {
39  wl_resource *data_source_resource = wl_resource_create(resource->client(), &zwlr_data_control_source_v1_interface, resource->version(), id);
40  if (!data_source_resource) {
41  wl_resource_post_no_memory(resource->handle);
42  return;
43  }
44  DataControlSourceV1Interface *dataSource = new DataControlSourceV1Interface(q, data_source_resource);
45  Q_EMIT q->dataSourceCreated(dataSource);
46 }
47 
48 void DataControlDeviceManagerV1InterfacePrivate::zwlr_data_control_manager_v1_get_data_device(Resource *resource, uint32_t id, wl_resource *seat)
49 {
50  SeatInterface *s = SeatInterface::get(seat);
51  Q_ASSERT(s);
52  if (!s) {
53  return;
54  }
55 
56  wl_resource *data_device_resource = wl_resource_create(resource->client(), &zwlr_data_control_device_v1_interface, resource->version(), id);
57  if (!data_device_resource) {
58  wl_resource_post_no_memory(resource->handle);
59  return;
60  }
61  DataControlDeviceV1Interface *dataDevice = new DataControlDeviceV1Interface(s, data_device_resource);
62  Q_EMIT q->dataDeviceCreated(dataDevice);
63 }
64 
65 void DataControlDeviceManagerV1InterfacePrivate::zwlr_data_control_manager_v1_destroy(QtWaylandServer::zwlr_data_control_manager_v1::Resource *resource)
66 {
67  wl_resource_destroy(resource->handle);
68 }
69 
70 DataControlDeviceManagerV1Interface::DataControlDeviceManagerV1Interface(Display *display, QObject *parent)
71  : QObject(parent)
72  , d(new DataControlDeviceManagerV1InterfacePrivate(this, display))
73 {
74 }
75 
76 DataControlDeviceManagerV1Interface::~DataControlDeviceManagerV1Interface() = default;
77 
78 }
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.