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// Qt-Security score:critical reason:network-protocol
4
6
9#include "qwaylandsurface_p.h"
11
12#if QT_CONFIG(draganddrop)
13#include "qwaylanddrag.h"
14#endif
15#include "qwaylandview.h"
16#include <QtWaylandCompositor/QWaylandClient>
17#include <QtWaylandCompositor/private/qwaylandcompositor_p.h>
18#include <QtWaylandCompositor/private/qwaylandseat_p.h>
19#include <QtWaylandCompositor/private/qwaylandpointer_p.h>
20
21#include <QtCore/QPointF>
22#include <QDebug>
23
25
26namespace QtWayland {
27
28DataDevice::DataDevice(QWaylandSeat *seat)
30 , m_seat(seat)
31{
32}
33
34void DataDevice::setFocus(QWaylandClient *focusClient)
35{
36 if (!focusClient)
37 return;
38
39 Resource *resource = resourceMap().value(focusClient->client());
40
41 if (!resource)
42 return;
43
44 if (m_selectionSource) {
45 DataOffer *offer = new DataOffer(m_selectionSource, resource);
46 send_selection(resource->handle, offer->resource()->handle);
47 }
48}
49
51{
52 if (m_selectionSource == source)
53 m_selectionSource = nullptr;
54
55 if (m_dragDataSource == source)
56 m_dragDataSource = nullptr;
57}
58
59#if QT_CONFIG(draganddrop)
61{
64 m_dragFocus = nullptr;
65 m_dragFocusResource = nullptr;
66 }
67
68 if (!focus)
69 return;
70
72 return;
73
75
76 if (!resource)
77 return;
78
80
82
83 if (m_dragDataSource && !offer)
84 return;
85
86 if (offer) {
90 }
91
94}
95
97{
98 return m_dragIcon;
99}
100
102{
103 return m_dragOrigin;
104}
105
107{
108 if (target != m_dragFocus)
111 return;
112 uint time = m_compositor->currentTimeMsecs(); //### should be serial
115}
116
117void DataDevice::drop()
118{
121 setDragFocus(nullptr, QPoint());
122 } else if (m_dragDataSource) {
124 }
125 m_dragOrigin = nullptr;
126 setDragIcon(nullptr);
127}
128
130{
131 setDragFocus(nullptr, QPoint());
132}
133
135{
145
147 //### need to verify that we have an implicit grab with this serial
148}
149
151{
152 if (icon == m_dragIcon)
153 return;
156}
157#endif // QT_CONFIG(draganddrop)
158
159void DataDevice::data_device_set_selection(Resource *, struct ::wl_resource *source, uint32_t serial)
160{
161 Q_UNUSED(serial);
162
163 DataSource *dataSource = source ? DataSource::fromResource(source) : nullptr;
164
165 if (m_selectionSource)
166 m_selectionSource->cancel();
167
168 m_selectionSource = dataSource;
169 QWaylandCompositorPrivate::get(m_compositor)->dataDeviceManager()->setCurrentSelectionSource(m_selectionSource);
170 if (m_selectionSource)
171 m_selectionSource->setDevice(this);
172
173 QWaylandClient *focusClient = m_seat->keyboard()->focusClient();
174 Resource *resource = focusClient ? resourceMap().value(focusClient->client()) : 0;
175
176 if (resource && m_selectionSource) {
177 DataOffer *offer = new DataOffer(m_selectionSource, resource);
178 send_selection(resource->handle, offer->resource()->handle);
179 } else if (resource) {
180 send_selection(resource->handle, nullptr);
181 }
182}
183
184
185}
186
187QT_END_NAMESPACE
DataDevice(QWaylandSeat *seat)
void sourceDestroyed(DataSource *source)
void setFocus(QWaylandClient *client)
void setDevice(DataDevice *device)
Combined button and popup list for selecting options.