File indexing completed on 2024-11-10 04:57:25
0001 /* 0002 SPDX-FileCopyrightText: 2020 David Edmundson <davidedmundson@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #include "datacontroldevicemanager_v1.h" 0008 #include "datacontroldevice_v1.h" 0009 #include "datacontrolsource_v1.h" 0010 #include "display.h" 0011 #include "seat_p.h" 0012 // Wayland 0013 #include <qwayland-server-wlr-data-control-unstable-v1.h> 0014 0015 static const int s_version = 2; 0016 namespace KWin 0017 { 0018 class DataControlDeviceManagerV1InterfacePrivate : public QtWaylandServer::zwlr_data_control_manager_v1 0019 { 0020 public: 0021 DataControlDeviceManagerV1InterfacePrivate(DataControlDeviceManagerV1Interface *q, Display *d); 0022 0023 DataControlDeviceManagerV1Interface *q; 0024 0025 protected: 0026 void zwlr_data_control_manager_v1_create_data_source(Resource *resource, uint32_t id) override; 0027 void zwlr_data_control_manager_v1_get_data_device(Resource *resource, uint32_t id, wl_resource *seat) override; 0028 void zwlr_data_control_manager_v1_destroy(Resource *resource) override; 0029 }; 0030 0031 DataControlDeviceManagerV1InterfacePrivate::DataControlDeviceManagerV1InterfacePrivate(DataControlDeviceManagerV1Interface *q, Display *d) 0032 : QtWaylandServer::zwlr_data_control_manager_v1(*d, s_version) 0033 , q(q) 0034 { 0035 } 0036 0037 void DataControlDeviceManagerV1InterfacePrivate::zwlr_data_control_manager_v1_create_data_source(Resource *resource, uint32_t id) 0038 { 0039 wl_resource *data_source_resource = wl_resource_create(resource->client(), &zwlr_data_control_source_v1_interface, resource->version(), id); 0040 if (!data_source_resource) { 0041 wl_resource_post_no_memory(resource->handle); 0042 return; 0043 } 0044 DataControlSourceV1Interface *dataSource = new DataControlSourceV1Interface(q, data_source_resource); 0045 Q_EMIT q->dataSourceCreated(dataSource); 0046 } 0047 0048 void DataControlDeviceManagerV1InterfacePrivate::zwlr_data_control_manager_v1_get_data_device(Resource *resource, uint32_t id, wl_resource *seat) 0049 { 0050 SeatInterface *s = SeatInterface::get(seat); 0051 Q_ASSERT(s); 0052 if (!s) { 0053 return; 0054 } 0055 0056 wl_resource *data_device_resource = wl_resource_create(resource->client(), &zwlr_data_control_device_v1_interface, resource->version(), id); 0057 if (!data_device_resource) { 0058 wl_resource_post_no_memory(resource->handle); 0059 return; 0060 } 0061 DataControlDeviceV1Interface *dataDevice = new DataControlDeviceV1Interface(s, data_device_resource); 0062 Q_EMIT q->dataDeviceCreated(dataDevice); 0063 } 0064 0065 void DataControlDeviceManagerV1InterfacePrivate::zwlr_data_control_manager_v1_destroy(QtWaylandServer::zwlr_data_control_manager_v1::Resource *resource) 0066 { 0067 wl_resource_destroy(resource->handle); 0068 } 0069 0070 DataControlDeviceManagerV1Interface::DataControlDeviceManagerV1Interface(Display *display, QObject *parent) 0071 : QObject(parent) 0072 , d(new DataControlDeviceManagerV1InterfacePrivate(this, display)) 0073 { 0074 } 0075 0076 DataControlDeviceManagerV1Interface::~DataControlDeviceManagerV1Interface() = default; 0077 0078 } 0079 0080 #include "moc_datacontroldevicemanager_v1.cpp"