Blame SOURCES/0039-Client-Implement-DataDeviceV3.patch

429548
From 2044603ebb5ae70c785d50968ac620b842c2b14e Mon Sep 17 00:00:00 2001
429548
From: David Edmundson <davidedmundson@kde.org>
429548
Date: Tue, 16 Feb 2021 09:51:47 +0000
429548
Subject: [PATCH 39/41] Client: Implement DataDeviceV3
429548
429548
DataDeviceV2 fixes a leak of DataDevice resources.
429548
429548
DataDeviceV3 brings multiple improvements:
429548
429548
Action negotiation. The source announces which actions are supported,
429548
the target then announces which subset of those action the target
429548
supports and a preferred action. After negotiation both the source and
429548
target are notified of which action is to be performed.
429548
429548
Drag sources are now notified when contents are dropped and when a
429548
client has finished with the drag and drop operation.
429548
429548
A good test is the draggableicons example in QtBase.
429548
429548
Change-Id: I55e9759ca5a2e4218d02d863144a64ade53ef764
429548
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
429548
(cherry picked from commit 283a2d61d03315495a52d82f356e7cb5292f4bb4)
429548
---
429548
 src/client/qwaylanddatadevice.cpp             | 84 ++++++++++++++-----
429548
 src/client/qwaylanddatadevice_p.h             |  8 +-
429548
 src/client/qwaylanddatadevicemanager.cpp      |  4 +-
429548
 src/client/qwaylanddatadevicemanager_p.h      |  2 +-
429548
 src/client/qwaylanddataoffer.cpp              | 25 ++++++
429548
 src/client/qwaylanddataoffer_p.h              |  4 +
429548
 src/client/qwaylanddatasource.cpp             | 27 +++++-
429548
 src/client/qwaylanddatasource_p.h             | 10 ++-
429548
 src/client/qwaylanddisplay.cpp                |  2 +-
429548
 src/client/qwaylanddnd.cpp                    | 24 +++---
429548
 src/client/qwaylanddnd_p.h                    |  7 +-
429548
 .../client/datadevicev1/tst_datadevicev1.cpp  |  2 +-
429548
 12 files changed, 153 insertions(+), 46 deletions(-)
429548
429548
diff --git a/src/client/qwaylanddatadevice.cpp b/src/client/qwaylanddatadevice.cpp
429548
index bbd2d568..fbb5aa91 100644
429548
--- a/src/client/qwaylanddatadevice.cpp
429548
+++ b/src/client/qwaylanddatadevice.cpp
429548
@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
429548
 
429548
 QWaylandDataDevice::~QWaylandDataDevice()
429548
 {
429548
+    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
429548
+        release();
429548
 }
429548
 
429548
 QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
429548
@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
429548
     return m_dragOffer.data();
429548
 }
429548
 
429548
-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
429548
+bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
429548
 {
429548
     auto *seat = m_display->currentInputDevice();
429548
     auto *origin = seat->pointerFocus();
429548
@@ -123,8 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
429548
     }
429548
 
429548
     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
429548
+
429548
+    if (wl_data_device_get_version(object()) >= 3)
429548
+        m_dragSource->set_actions(dropActionsToWl(supportedActions));
429548
+
429548
     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
429548
-    connect(m_dragSource.data(), &QWaylandDataSource::targetChanged, this, &QWaylandDataDevice::dragSourceTargetChanged);
429548
+    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
429548
+            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
429548
+            // in old versions drop action is not set, so we guess
429548
+            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
429548
+                drag->setResponse(accepted);
429548
+            } else {
429548
+                QPlatformDropQtResponse response(accepted, action);
429548
+                drag->setResponse(response);
429548
+            }
429548
+    });
429548
+    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
429548
+        QPlatformDropQtResponse response(accepted, action);
429548
+        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
429548
+    });
429548
+    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
429548
+        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
429548
+    });
429548
 
429548
     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
429548
     return true;
429548
@@ -153,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
429548
         supportedActions = drag->supportedActions();
429548
     } else if (m_dragOffer) {
429548
         dragData = m_dragOffer->mimeData();
429548
-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
429548
+        supportedActions = m_dragOffer->supportedActions();
429548
     } else {
429548
         return;
429548
     }
429548
@@ -163,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
429548
                                                                           QGuiApplication::keyboardModifiers());
429548
 
429548
     if (drag) {
429548
-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
429548
+        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
429548
+        drag->setDropResponse(response);
429548
+        drag->finishDrag();
429548
+    } else if (m_dragOffer) {
429548
+        m_dragOffer->finish();
429548
     }
429548
 }
429548
 
429548
@@ -187,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
429548
         supportedActions = drag->supportedActions();
429548
     } else if (m_dragOffer) {
429548
         dragData = m_dragOffer->mimeData();
429548
-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
429548
+        supportedActions = m_dragOffer->supportedActions();
429548
     }
429548
 
429548
     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
429548
@@ -198,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
429548
         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
429548
     }
429548
 
429548
-    if (response.isAccepted()) {
429548
-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
429548
-    } else {
429548
-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
429548
-    }
429548
+    sendResponse(supportedActions, response);
429548
 }
429548
 
429548
 void QWaylandDataDevice::data_device_leave()
429548
@@ -236,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
429548
         supportedActions = drag->supportedActions();
429548
     } else {
429548
         dragData = m_dragOffer->mimeData();
429548
-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
429548
+        supportedActions = m_dragOffer->supportedActions();
429548
     }
429548
 
429548
-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
429548
+    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
429548
                                                                           QGuiApplication::mouseButtons(),
429548
                                                                           QGuiApplication::keyboardModifiers());
429548
 
429548
@@ -247,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
429548
         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
429548
     }
429548
 
429548
-    if (response.isAccepted()) {
429548
-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
429548
-    } else {
429548
-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
429548
-    }
429548
+    sendResponse(supportedActions, response);
429548
 }
429548
 #endif // QT_CONFIG(draganddrop)
429548
 
429548
@@ -281,11 +299,6 @@ void QWaylandDataDevice::dragSourceCancelled()
429548
     m_dragSource.reset();
429548
 }
429548
 
429548
-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
429548
-{
429548
-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
429548
-}
429548
-
429548
 QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
429548
 {
429548
     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
429548
@@ -298,6 +311,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
429548
     }
429548
     return pnt;
429548
 }
429548
+
429548
+void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
429548
+{
429548
+    if (response.isAccepted()) {
429548
+        if (wl_data_device_get_version(object()) >= 3)
429548
+            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
429548
+
429548
+        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
429548
+    } else {
429548
+        m_dragOffer->accept(m_enterSerial, QString());
429548
+    }
429548
+}
429548
+
429548
+int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
429548
+{
429548
+
429548
+    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
429548
+    if (actions & Qt::CopyAction)
429548
+        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
429548
+    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
429548
+        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
429548
+
429548
+    // wayland does not support LinkAction at the time of writing
429548
+    return wlActions;
429548
+}
429548
+
429548
+
429548
 #endif // QT_CONFIG(draganddrop)
429548
 
429548
 }
429548
diff --git a/src/client/qwaylanddatadevice_p.h b/src/client/qwaylanddatadevice_p.h
429548
index 16c3ad28..801dcc2c 100644
429548
--- a/src/client/qwaylanddatadevice_p.h
429548
+++ b/src/client/qwaylanddatadevice_p.h
429548
@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
429548
 QT_BEGIN_NAMESPACE
429548
 
429548
 class QMimeData;
429548
+class QPlatformDragQtResponse;
429548
 class QWindow;
429548
 
429548
 namespace QtWaylandClient {
429548
@@ -89,7 +90,7 @@ public:
429548
 
429548
 #if QT_CONFIG(draganddrop)
429548
     QWaylandDataOffer *dragOffer() const;
429548
-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
429548
+    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
429548
     void cancelDrag();
429548
 #endif
429548
 
429548
@@ -109,13 +110,16 @@ private Q_SLOTS:
429548
 
429548
 #if QT_CONFIG(draganddrop)
429548
     void dragSourceCancelled();
429548
-    void dragSourceTargetChanged(const QString &mimeType);
429548
 #endif
429548
 
429548
 private:
429548
 #if QT_CONFIG(draganddrop)
429548
     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
429548
 #endif
429548
+    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
429548
+
429548
+    static int dropActionsToWl(Qt::DropActions dropActions);
429548
+
429548
 
429548
     QWaylandDisplay *m_display = nullptr;
429548
     QWaylandInputDevice *m_inputDevice = nullptr;
429548
diff --git a/src/client/qwaylanddatadevicemanager.cpp b/src/client/qwaylanddatadevicemanager.cpp
429548
index 35d67307..6dc4f77f 100644
429548
--- a/src/client/qwaylanddatadevicemanager.cpp
429548
+++ b/src/client/qwaylanddatadevicemanager.cpp
429548
@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
429548
 
429548
 namespace QtWaylandClient {
429548
 
429548
-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
429548
-    : wl_data_device_manager(display->wl_registry(), id, 1)
429548
+QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
429548
+    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
429548
     , m_display(display)
429548
 {
429548
     // Create transfer devices for all input devices.
429548
diff --git a/src/client/qwaylanddatadevicemanager_p.h b/src/client/qwaylanddatadevicemanager_p.h
429548
index bd05c0fb..510d9be4 100644
429548
--- a/src/client/qwaylanddatadevicemanager_p.h
429548
+++ b/src/client/qwaylanddatadevicemanager_p.h
429548
@@ -68,7 +68,7 @@ class QWaylandInputDevice;
429548
 class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
429548
 {
429548
 public:
429548
-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
429548
+    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
429548
     ~QWaylandDataDeviceManager() override;
429548
 
429548
     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
429548
diff --git a/src/client/qwaylanddataoffer.cpp b/src/client/qwaylanddataoffer.cpp
429548
index 2297e8a1..c9e158cc 100644
429548
--- a/src/client/qwaylanddataoffer.cpp
429548
+++ b/src/client/qwaylanddataoffer.cpp
429548
@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
429548
     return m_mimeData.data();
429548
 }
429548
 
429548
+Qt::DropActions QWaylandDataOffer::supportedActions() const
429548
+{
429548
+    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
429548
+        return Qt::MoveAction | Qt::CopyAction;
429548
+    }
429548
+
429548
+    return m_supportedActions;
429548
+}
429548
+
429548
 void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
429548
 {
429548
     receive(mimeType, fd);
429548
@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
429548
     m_mimeData->appendFormat(mime_type);
429548
 }
429548
 
429548
+void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
429548
+{
429548
+    Q_UNUSED(dnd_action);
429548
+    // This is the compositor telling the drag target what action it should perform
429548
+    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
429548
+}
429548
+
429548
+void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
429548
+{
429548
+    m_supportedActions = Qt::DropActions();
429548
+    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
429548
+        m_supportedActions |= Qt::MoveAction;
429548
+    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
429548
+        m_supportedActions |= Qt::CopyAction;
429548
+}
429548
+
429548
 QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
429548
     : m_dataOffer(dataOffer)
429548
 {
429548
diff --git a/src/client/qwaylanddataoffer_p.h b/src/client/qwaylanddataoffer_p.h
429548
index 9cf1483c..6f667398 100644
429548
--- a/src/client/qwaylanddataoffer_p.h
429548
+++ b/src/client/qwaylanddataoffer_p.h
429548
@@ -82,6 +82,7 @@ public:
429548
     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
429548
     ~QWaylandDataOffer() override;
429548
     QMimeData *mimeData() override;
429548
+    Qt::DropActions supportedActions() const;
429548
 
429548
     QString firstFormat() const;
429548
 
429548
@@ -89,10 +90,13 @@ public:
429548
 
429548
 protected:
429548
     void data_offer_offer(const QString &mime_type) override;
429548
+    void data_offer_source_actions(uint32_t source_actions) override;
429548
+    void data_offer_action(uint32_t dnd_action) override;
429548
 
429548
 private:
429548
     QWaylandDisplay *m_display = nullptr;
429548
     QScopedPointer<QWaylandMimeData> m_mimeData;
429548
+    Qt::DropActions m_supportedActions;
429548
 };
429548
 
429548
 
429548
diff --git a/src/client/qwaylanddatasource.cpp b/src/client/qwaylanddatasource.cpp
429548
index f45122fb..5599cbd4 100644
429548
--- a/src/client/qwaylanddatasource.cpp
429548
+++ b/src/client/qwaylanddatasource.cpp
429548
@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
429548
 
429548
 void QWaylandDataSource::data_source_target(const QString &mime_type)
429548
 {
429548
-    Q_EMIT targetChanged(mime_type);
429548
+    m_accepted = !mime_type.isEmpty();
429548
+    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
429548
+}
429548
+
429548
+void QWaylandDataSource::data_source_action(uint32_t action)
429548
+{
429548
+    Qt::DropAction qtAction = Qt::IgnoreAction;
429548
+
429548
+    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
429548
+        qtAction = Qt::MoveAction;
429548
+    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
429548
+        qtAction = Qt::CopyAction;
429548
+
429548
+    m_dropAction = qtAction;
429548
+    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
429548
+}
429548
+
429548
+void QWaylandDataSource::data_source_dnd_finished()
429548
+{
429548
+    Q_EMIT finished();
429548
+}
429548
+
429548
+void QWaylandDataSource::data_source_dnd_drop_performed()
429548
+{
429548
+
429548
+    Q_EMIT dndDropped(m_accepted, m_dropAction);
429548
 }
429548
 
429548
 }
429548
diff --git a/src/client/qwaylanddatasource_p.h b/src/client/qwaylanddatasource_p.h
429548
index 25afff79..96f07bc3 100644
429548
--- a/src/client/qwaylanddatasource_p.h
429548
+++ b/src/client/qwaylanddatasource_p.h
429548
@@ -77,17 +77,25 @@ public:
429548
     QMimeData *mimeData() const;
429548
 
429548
 Q_SIGNALS:
429548
-    void targetChanged(const QString &mime_type);
429548
     void cancelled();
429548
+    void finished();
429548
+
429548
+    void dndResponseUpdated(bool accepted, Qt::DropAction action);
429548
+    void dndDropped(bool accepted, Qt::DropAction action);
429548
 
429548
 protected:
429548
     void data_source_cancelled() override;
429548
     void data_source_send(const QString &mime_type, int32_t fd) override;
429548
     void data_source_target(const QString &mime_type) override;
429548
+    void data_source_dnd_drop_performed() override;
429548
+    void data_source_dnd_finished() override;
429548
+    void data_source_action(uint32_t action) override;
429548
 
429548
 private:
429548
     QWaylandDisplay *m_display = nullptr;
429548
     QMimeData *m_mime_data = nullptr;
429548
+    bool m_accepted = false;
429548
+    Qt::DropAction m_dropAction = Qt::IgnoreAction;
429548
 };
429548
 
429548
 }
429548
diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp
429548
index 9f595af3..ea344c61 100644
429548
--- a/src/client/qwaylanddisplay.cpp
429548
+++ b/src/client/qwaylanddisplay.cpp
429548
@@ -354,7 +354,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
429548
         mInputDevices.append(inputDevice);
429548
 #if QT_CONFIG(wayland_datadevice)
429548
     } else if (interface == QStringLiteral("wl_data_device_manager")) {
429548
-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
429548
+        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
429548
 #endif
429548
     } else if (interface == QStringLiteral("qt_surface_extension")) {
429548
         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
429548
diff --git a/src/client/qwaylanddnd.cpp b/src/client/qwaylanddnd.cpp
429548
index 6535aa16..97ee5b2e 100644
429548
--- a/src/client/qwaylanddnd.cpp
429548
+++ b/src/client/qwaylanddnd.cpp
429548
@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
429548
 {
429548
     QBasicDrag::startDrag();
429548
     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
429548
-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
429548
+    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
429548
         icon->addAttachOffset(-drag()->hotSpot());
429548
     } else {
429548
         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
429548
@@ -103,31 +103,31 @@ void QWaylandDrag::endDrag()
429548
     m_display->currentInputDevice()->handleEndDrag();
429548
 }
429548
 
429548
-void QWaylandDrag::updateTarget(const QString &mimeType)
429548
+void QWaylandDrag::setResponse(bool accepted)
429548
 {
429548
-    setCanDrop(!mimeType.isEmpty());
429548
-
429548
-    if (canDrop()) {
429548
-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
429548
-    } else {
429548
-        updateCursor(Qt::IgnoreAction);
429548
-    }
429548
+    // This method is used for old DataDevices where the drag action is not communicated
429548
+    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
429548
+    setResponse(QPlatformDropQtResponse(accepted, action));
429548
 }
429548
 
429548
-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
429548
+void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
429548
 {
429548
     setCanDrop(response.isAccepted());
429548
 
429548
     if (canDrop()) {
429548
-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
429548
+        updateCursor(response.acceptedAction());
429548
     } else {
429548
         updateCursor(Qt::IgnoreAction);
429548
     }
429548
 }
429548
 
429548
-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
429548
+void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
429548
 {
429548
     setExecutedDropAction(response.acceptedAction());
429548
+}
429548
+
429548
+void QWaylandDrag::finishDrag()
429548
+{
429548
     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
429548
     eventFilter(shapedPixmapWindow(), &event);
429548
 }
429548
diff --git a/src/client/qwaylanddnd_p.h b/src/client/qwaylanddnd_p.h
429548
index 474fe2ab..747f0190 100644
429548
--- a/src/client/qwaylanddnd_p.h
429548
+++ b/src/client/qwaylanddnd_p.h
429548
@@ -71,9 +71,10 @@ public:
429548
     QWaylandDrag(QWaylandDisplay *display);
429548
     ~QWaylandDrag() override;
429548
 
429548
-    void updateTarget(const QString &mimeType);
429548
-    void setResponse(const QPlatformDragQtResponse &response);
429548
-    void finishDrag(const QPlatformDropQtResponse &response);
429548
+    void setResponse(bool accepted);
429548
+    void setResponse(const QPlatformDropQtResponse &response);
429548
+    void setDropResponse(const QPlatformDropQtResponse &response);
429548
+    void finishDrag();
429548
 
429548
 protected:
429548
     void startDrag() override;
429548
diff --git a/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
429548
index 1568b3b9..067410d0 100644
429548
--- a/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
429548
+++ b/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
429548
@@ -35,7 +35,7 @@
429548
 
429548
 using namespace MockCompositor;
429548
 
429548
-constexpr int dataDeviceVersion = 1;
429548
+constexpr int dataDeviceVersion = 3;
429548
 
429548
 class DataDeviceCompositor : public DefaultCompositor {
429548
 public:
429548
-- 
429548
2.34.1
429548