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 
20 class Q_DECL_HIDDEN DataDeviceManager::Private
21 {
22 public:
23  WaylandPointer<wl_data_device_manager, wl_data_device_manager_destroy> manager;
24  EventQueue *queue = nullptr;
25 };
26 
28  : QObject(parent)
29  , d(new Private)
30 {
31 }
32 
33 DataDeviceManager::~DataDeviceManager()
34 {
35  release();
36 }
37 
39 {
40  d->manager.release();
41 }
42 
44 {
45  d->manager.destroy();
46 }
47 
49 {
50  return d->manager.isValid();
51 }
52 
53 void DataDeviceManager::setup(wl_data_device_manager *manager)
54 {
55  Q_ASSERT(manager);
56  Q_ASSERT(!d->manager.isValid());
57  d->manager.setup(manager);
58 }
59 
61 {
62  return d->queue;
63 }
64 
66 {
67  d->queue = queue;
68 }
69 
70 DataSource *DataDeviceManager::createDataSource(QObject *parent)
71 {
72  Q_ASSERT(isValid());
73  DataSource *s = new DataSource(parent);
74  auto w = wl_data_device_manager_create_data_source(d->manager);
75  if (d->queue) {
76  d->queue->addProxy(w);
77  }
78  s->setup(w);
79  return s;
80 }
81 
82 DataDevice *DataDeviceManager::getDataDevice(Seat *seat, QObject *parent)
83 {
84  Q_ASSERT(isValid());
85  Q_ASSERT(seat);
86  DataDevice *device = new DataDevice(parent);
87  auto w = wl_data_device_manager_get_data_device(d->manager, *seat);
88  if (d->queue) {
89  d->queue->addProxy(w);
90  }
91  device->setup(w);
92  return device;
93 }
94 
95 DataDeviceManager::operator wl_data_device_manager*() const
96 {
97  return d->manager;
98 }
99 
100 DataDeviceManager::operator wl_data_device_manager*()
101 {
102  return d->manager;
103 }
104 
105 }
106 }
void destroy()
Destroys the data held by this DataDeviceManager.
DataDevice allows clients to share data by copy-and-paste and drag-and-drop.
Definition: datadevice.h:32
void setup(wl_data_device_manager *manager)
Setup this DataDeviceManager to manage the manager.
Wrapper for the wl_data_source interface.
Definition: datasource.h:33
void setup(wl_data_device *dataDevice)
Setup this DataDevice to manage the dataDevice.
Definition: datadevice.cpp:184
Wrapper class for wl_event_queue interface.
Definition: event_queue.h:55
Wrapper for the wl_seat interface.
Definition: seat.h:52
void release()
Releases the wl_data_device_manager interface.
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:155
QObject * parent() const const
DataDeviceManager(QObject *parent=nullptr)
Creates a new Compositor.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Aug 13 2020 22:50:19 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.