1 | // Copyright (C) 2016 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #include "qwaylanddatadevicemanager_p.h" |
5 | |
6 | #include "qwaylandinputdevice_p.h" |
7 | #include "qwaylanddatadevice_p.h" |
8 | #include "qwaylanddataoffer_p.h" |
9 | #include "qwaylanddisplay_p.h" |
10 | |
11 | #include <QtCore/QDebug> |
12 | |
13 | QT_BEGIN_NAMESPACE |
14 | |
15 | namespace QtWaylandClient { |
16 | |
17 | QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id) |
18 | : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3)) |
19 | , m_display(display) |
20 | { |
21 | // Create transfer devices for all input devices. |
22 | // ### This only works if we get the global before all devices and is surely wrong when hotplugging. |
23 | QList<QWaylandInputDevice *> inputDevices = m_display->inputDevices(); |
24 | for (int i = 0; i < inputDevices.size();i++) { |
25 | inputDevices.at(i)->setDataDevice(getDataDevice(inputDevice: inputDevices.at(i))); |
26 | } |
27 | } |
28 | |
29 | QWaylandDataDeviceManager::~QWaylandDataDeviceManager() |
30 | { |
31 | wl_data_device_manager_destroy(object()); |
32 | } |
33 | |
34 | QWaylandDataDevice *QWaylandDataDeviceManager::getDataDevice(QWaylandInputDevice *inputDevice) |
35 | { |
36 | return new QWaylandDataDevice(this, inputDevice); |
37 | } |
38 | |
39 | QWaylandDisplay *QWaylandDataDeviceManager::display() const |
40 | { |
41 | return m_display; |
42 | } |
43 | |
44 | } |
45 | |
46 | QT_END_NAMESPACE |
47 |