summaryrefslogtreecommitdiffstats
path: root/src/client/qwaylanddnd.cpp
diff options
context:
space:
mode:
authorDavid Edmundson <davidedmundson@kde.org>2021-02-16 09:51:47 +0000
committerDavid Edmundson <davidedmundson@kde.org>2021-12-09 09:32:59 +0000
commit283a2d61d03315495a52d82f356e7cb5292f4bb4 (patch)
treecce3d266ab3f30192eda772881b91356a3c26068 /src/client/qwaylanddnd.cpp
parent34a8147f22ecba79f35616386da47e446bd1eed7 (diff)
Client: Implement DataDeviceV3
DataDeviceV2 fixes a leak of DataDevice resources. DataDeviceV3 brings multiple improvements: Action negotiation. The source announces which actions are supported, the target then announces which subset of those action the target supports and a preferred action. After negotiation both the source and target are notified of which action is to be performed. Drag sources are now notified when contents are dropped and when a client has finished with the drag and drop operation. A good test is the draggableicons example in QtBase. Change-Id: I55e9759ca5a2e4218d02d863144a64ade53ef764 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/client/qwaylanddnd.cpp')
-rw-r--r--src/client/qwaylanddnd.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/client/qwaylanddnd.cpp b/src/client/qwaylanddnd.cpp
index 6535aa16b..97ee5b2ed 100644
--- a/src/client/qwaylanddnd.cpp
+++ b/src/client/qwaylanddnd.cpp
@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
{
QBasicDrag::startDrag();
QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
- if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
+ if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
icon->addAttachOffset(-drag()->hotSpot());
} else {
// Cancelling immediately does not work, since the event loop for QDrag::exec is started
@@ -103,31 +103,31 @@ void QWaylandDrag::endDrag()
m_display->currentInputDevice()->handleEndDrag();
}
-void QWaylandDrag::updateTarget(const QString &mimeType)
+void QWaylandDrag::setResponse(bool accepted)
{
- setCanDrop(!mimeType.isEmpty());
-
- if (canDrop()) {
- updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
- } else {
- updateCursor(Qt::IgnoreAction);
- }
+ // This method is used for old DataDevices where the drag action is not communicated
+ Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
+ setResponse(QPlatformDropQtResponse(accepted, action));
}
-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
+void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
{
setCanDrop(response.isAccepted());
if (canDrop()) {
- updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+ updateCursor(response.acceptedAction());
} else {
updateCursor(Qt::IgnoreAction);
}
}
-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
+void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
{
setExecutedDropAction(response.acceptedAction());
+}
+
+void QWaylandDrag::finishDrag()
+{
QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
eventFilter(shapedPixmapWindow(), &event);
}