KWayland

datadevicemanager.cpp
1 /*
2  SPDX-FileCopyrightText: 2014 Martin Gräßlin <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 #include "datadevicemanager.h"
7 #include "datadevice.h"
8 #include "datasource.h"
9 #include "event_queue.h"
10 #include "seat.h"
11 #include "wayland_pointer_p.h"
12 
13 #include <wayland-client-protocol.h>
14 
15 namespace KWayland
16 {
17 namespace Client
18 {
19 class Q_DECL_HIDDEN DataDeviceManager::Private
20 {
21 public:
22  WaylandPointer<wl_data_device_manager, wl_data_device_manager_destroy> manager;
23  EventQueue *queue = nullptr;
24 };
25 
27  : QObject(parent)
28  , d(new Private)
29 {
30 }
31 
32 DataDeviceManager::~DataDeviceManager()
33 {
34  release();
35 }
36 
38 {
39  d->manager.release();
40 }
41 
43 {
44  d->manager.destroy();
45 }
46 
48 {
49  return d->manager.isValid();
50 }
51 
52 void DataDeviceManager::setup(wl_data_device_manager *manager)
53 {
54  Q_ASSERT(manager);
55  Q_ASSERT(!d->manager.isValid());
56  d->manager.setup(manager);
57 }
58 
60 {
61  return d->queue;
62 }
63 
65 {
66  d->queue = queue;
67 }
68 
69 DataSource *DataDeviceManager::createDataSource(QObject *parent)
70 {
71  Q_ASSERT(isValid());
72  DataSource *s = new DataSource(parent);
73  auto w = wl_data_device_manager_create_data_source(d->manager);
74  if (d->queue) {
75  d->queue->addProxy(w);
76  }
77  s->setup(w);
78  return s;
79 }
80 
81 DataDevice *DataDeviceManager::getDataDevice(Seat *seat, QObject *parent)
82 {
83  Q_ASSERT(isValid());
84  Q_ASSERT(seat);
85  DataDevice *device = new DataDevice(parent);
86  auto w = wl_data_device_manager_get_data_device(d->manager, *seat);
87  if (d->queue) {
88  d->queue->addProxy(w);
89  }
90  device->setup(w);
91  return device;
92 }
93 
94 DataDeviceManager::operator wl_data_device_manager *() const
95 {
96  return d->manager;
97 }
98 
99 DataDeviceManager::operator wl_data_device_manager *()
100 {
101  return d->manager;
102 }
103 
104 }
105 }
void destroy()
Destroys the data held by this DataDeviceManager.
void release()
Releases the wl_data_device_manager interface.
Wrapper class for wl_event_queue interface.
Definition: event_queue.h:54
Wrapper for the wl_data_source interface.
Definition: datasource.h:31
void setup(wl_data_device_manager *manager)
Setup this DataDeviceManager to manage the manager.
DataDeviceManager(QObject *parent=nullptr)
Creates a new Compositor.
void setEventQueue(EventQueue *queue)
Sets the queue to use for creating a DataSource.
void setup(wl_data_source *dataSource)
Setup this DataSource to manage the dataSource.
Definition: datasource.cpp:148
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Feb 8 2023 03:59:21 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.