127 wl_resource_post_error(dataSource->
resource(), QtWaylandServer::wl_data_source::error_invalid_source,
"Data source is for drag and drop");
132 wl_resource_post_error(resource->handle, QtWaylandServer::wl_data_source::error_invalid_source,
"Data source is for drag and drop");
206 d->drag.surface =
nullptr;
208 disconnect(d->drag.posConnection);
209 d->drag.posConnection = QMetaObject::Connection();
210 disconnect(d->drag.destroyConnection);
211 d->drag.destroyConnection = QMetaObject::Connection();
213 if (d->seat->dragSource()->selectedDndAction() != DataDeviceManagerInterface::DnDAction::Ask) {
214 disconnect(d->drag.sourceActionConnection);
215 d->drag.sourceActionConnection = QMetaObject::Connection();
216 disconnect(d->drag.targetActionConnection);
217 d->drag.targetActionConnection = QMetaObject::Connection();
242 if (d->drag.surface == surface) {
246 if (d->drag.surface) {
247 if (d->drag.surface->resource()) {
250 if (d->drag.posConnection) {
251 disconnect(d->drag.posConnection);
252 d->drag.posConnection = QMetaObject::Connection();
254 disconnect(d->drag.destroyConnection);
255 d->drag.destroyConnection = QMetaObject::Connection();
256 d->drag.surface =
nullptr;
257 if (d->drag.sourceActionConnection) {
258 disconnect(d->drag.sourceActionConnection);
259 d->drag.sourceActionConnection = QMetaObject::Connection();
261 if (d->drag.targetActionConnection) {
262 disconnect(d->drag.targetActionConnection);
263 d->drag.targetActionConnection = QMetaObject::Connection();
267 auto dragSource = d->seat->dragSource();
268 if (!surface || !dragSource) {
269 if (
auto s = dragSource) {
270 s->dndAction(DataDeviceManagerInterface::DnDAction::None);
276 dragSource->accept(QString());
279 d->drag.surface = surface;
280 if (d->seat->isDragPointer()) {
282 const QPointF pos = d->seat->dragSurfaceTransformation().map(d->seat->pointerPos());
283 d->send_motion(d->seat->timestamp().count(), wl_fixed_from_double(pos.x()), wl_fixed_from_double(pos.y()));
285 }
else if (d->seat->isDragTouch()) {
295 d->drag.posConnection = connect(d->seat, &
SeatInterface::touchMoved,
this, [
this](qint32
id, quint32 serial,
const QPointF &globalPosition) {
296 if (serial != d->drag.serial) {
300 const QPointF pos = d->seat->dragSurfaceTransformation().map(globalPosition);
301 d->send_motion(d->seat->timestamp().count(), wl_fixed_from_double(pos.x()), wl_fixed_from_double(pos.y()));
304 d->drag.destroyConnection = connect(d->drag.surface, &QObject::destroyed,
this, [
this] {
306 if (d->drag.posConnection) {
307 disconnect(d->drag.posConnection);
313 if (d->seat->isDragPointer()) {
314 pos = d->seat->dragSurfaceTransformation().map(d->seat->pointerPos());
315 }
else if (d->seat->isDragTouch()) {
316 pos = d->seat->dragSurfaceTransformation().map(d->seat->firstTouchPointPosition());
318 d->send_enter(serial, surface->resource(), wl_fixed_from_double(pos.x()), wl_fixed_from_double(pos.y()), offer ? offer->
resource() :
nullptr);
320 auto matchOffers = [dragSource, offer] {
321 const DataDeviceManagerInterface::DnDAction action = chooseDndAction(dragSource, offer);
323 dragSource->dndAction(action);
325 d->drag.targetActionConnection = connect(offer, &DataOfferInterface::dragAndDropActionsChanged, dragSource, matchOffers);
326 d->drag.sourceActionConnection = connect(dragSource, &AbstractDataSource::supportedDragAndDropActionsChanged, dragSource, matchOffers);