Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwldatadevice.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
5
8#include "qwaylandsurface_p.h"
10
11#if QT_CONFIG(draganddrop)
12#include "qwaylanddrag.h"
13#endif
14#include "qwaylandview.h"
15#include <QtWaylandCompositor/QWaylandClient>
16#include <QtWaylandCompositor/private/qwaylandcompositor_p.h>
17#include <QtWaylandCompositor/private/qwaylandseat_p.h>
18#include <QtWaylandCompositor/private/qwaylandpointer_p.h>
19
20#include <QtCore/QPointF>
21#include <QDebug>
22
24
25namespace QtWayland {
26
27DataDevice::DataDevice(QWaylandSeat *seat)
29 , m_seat(seat)
30{
31}
32
33void DataDevice::setFocus(QWaylandClient *focusClient)
34{
35 if (!focusClient)
36 return;
37
38 Resource *resource = resourceMap().value(focusClient->client());
39
40 if (!resource)
41 return;
42
43 if (m_selectionSource) {
44 DataOffer *offer = new DataOffer(m_selectionSource, resource);
45 send_selection(resource->handle, offer->resource()->handle);
46 }
47}
48
50{
51 if (m_selectionSource == source)
52 m_selectionSource = nullptr;
53
54 if (m_dragDataSource == source)
55 m_dragDataSource = nullptr;
56}
57
58#if QT_CONFIG(draganddrop)
60{
63 m_dragFocus = nullptr;
64 m_dragFocusResource = nullptr;
65 }
66
67 if (!focus)
68 return;
69
71 return;
72
74
75 if (!resource)
76 return;
77
79
81
82 if (m_dragDataSource && !offer)
83 return;
84
85 if (offer) {
89 }
90
93}
94
96{
97 return m_dragIcon;
98}
99
101{
102 return m_dragOrigin;
103}
104
106{
107 if (target != m_dragFocus)
110 return;
111 uint time = m_compositor->currentTimeMsecs(); //### should be serial
114}
115
116void DataDevice::drop()
117{
120 setDragFocus(nullptr, QPoint());
121 } else if (m_dragDataSource) {
123 }
124 m_dragOrigin = nullptr;
125 setDragIcon(nullptr);
126}
127
129{
130 setDragFocus(nullptr, QPoint());
131}
132
134{
144
146 //### need to verify that we have an implicit grab with this serial
147}
148
150{
151 if (icon == m_dragIcon)
152 return;
155}
156#endif // QT_CONFIG(draganddrop)
157
158void DataDevice::data_device_set_selection(Resource *, struct ::wl_resource *source, uint32_t serial)
159{
160 Q_UNUSED(serial);
161
162 DataSource *dataSource = source ? DataSource::fromResource(source) : nullptr;
163
164 if (m_selectionSource)
165 m_selectionSource->cancel();
166
167 m_selectionSource = dataSource;
168 QWaylandCompositorPrivate::get(m_compositor)->dataDeviceManager()->setCurrentSelectionSource(m_selectionSource);
169 if (m_selectionSource)
170 m_selectionSource->setDevice(this);
171
172 QWaylandClient *focusClient = m_seat->keyboard()->focusClient();
173 Resource *resource = focusClient ? resourceMap().value(focusClient->client()) : 0;
174
175 if (resource && m_selectionSource) {
176 DataOffer *offer = new DataOffer(m_selectionSource, resource);
177 send_selection(resource->handle, offer->resource()->handle);
178 } else if (resource) {
179 send_selection(resource->handle, nullptr);
180 }
181}
182
183
184}
185
186QT_END_NAMESPACE
DataDevice(QWaylandSeat *seat)
void sourceDestroyed(DataSource *source)
void setFocus(QWaylandClient *client)
void setDevice(DataDevice *device)