summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm/qwasmdrag.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmdrag.cpp')
-rw-r--r--src/plugins/platforms/wasm/qwasmdrag.cpp34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/plugins/platforms/wasm/qwasmdrag.cpp b/src/plugins/platforms/wasm/qwasmdrag.cpp
index ecd95f5e338..6447d1e399f 100644
--- a/src/plugins/platforms/wasm/qwasmdrag.cpp
+++ b/src/plugins/platforms/wasm/qwasmdrag.cpp
@@ -94,15 +94,13 @@ Qt::DropAction QWasmDrag::drag(QDrag *drag)
return Qt::IgnoreAction;
Qt::DropAction dragResult = Qt::IgnoreAction;
- if (qstdweb::haveJspi()) {
+ if (qstdweb::haveAsyncify()) {
m_dragState = std::make_unique<DragState>(drag, window, [this]() { QSimpleDrag::cancelDrag(); });
- QSimpleDrag::drag(drag);
- dragResult = m_dragState->dropAction;
+ dragResult = QSimpleDrag::drag(drag);
m_dragState.reset();
- }
-
- if (dragResult == Qt::IgnoreAction)
+ } else {
dragResult = QBasicDrag::drag(drag);
+ }
return dragResult;
}
@@ -117,6 +115,7 @@ void QWasmDrag::onNativeDragStarted(DragEvent *event)
event->cancelDragStart();
return;
}
+ setExecutedDropAction(event->dropAction);
// We have our own window
if (shapedPixmapWindow())
@@ -145,8 +144,10 @@ void QWasmDrag::onNativeDragOver(DragEvent *event)
event->mouseButton, event->modifiers);
event->acceptDragOver();
if (dragResponse.isAccepted()) {
+ setExecutedDropAction(dragResponse.acceptedAction());
event->dataTransfer.setDropAction(dragResponse.acceptedAction());
} else {
+ setExecutedDropAction(Qt::DropAction::IgnoreAction);
event->dataTransfer.setDropAction(Qt::DropAction::IgnoreAction);
}
}
@@ -174,19 +175,22 @@ void QWasmDrag::onNativeDrop(DragEvent *event)
// files, but the browser expects that accepted state is set before any
// async calls.
event->acceptDrop();
+ setExecutedDropAction(event->dropAction);
+ std::shared_ptr<DragState> dragState = m_dragState;
- const auto dropCallback = [&m_dragState = m_dragState, wasmWindow, targetWindowPos,
+ const auto dropCallback = [dragState, wasmWindow, targetWindowPos,
actions, mouseButton, modifiers](QMimeData *mimeData) {
-
- auto dropResponse = std::make_shared<QPlatformDropQtResponse>(true, Qt::DropAction::CopyAction);
- *dropResponse = QWindowSystemInterface::handleDrop(wasmWindow->window(), mimeData,
+ if (mimeData) {
+ auto dropResponse = std::make_shared<QPlatformDropQtResponse>(true, Qt::DropAction::CopyAction);
+ *dropResponse = QWindowSystemInterface::handleDrop(wasmWindow->window(), mimeData,
targetWindowPos, actions,
mouseButton, modifiers);
- if (dropResponse->isAccepted())
- m_dragState->dropAction = dropResponse->acceptedAction();
+ if (dragState && dropResponse->isAccepted())
+ dragState->dropAction = dropResponse->acceptedAction();
- delete mimeData;
+ delete mimeData;
+ }
};
event->dataTransfer.toMimeDataWithFile(dropCallback);
@@ -196,6 +200,7 @@ void QWasmDrag::onNativeDragFinished(DragEvent *event)
{
event->webEvent.call<void>("preventDefault");
m_dragState->dropAction = event->dropAction;
+ setExecutedDropAction(event->dropAction);
m_dragState->quitEventLoopClosure();
}
@@ -211,6 +216,8 @@ void QWasmDrag::onNativeDragEnter(DragEvent *event)
if (m_dragState)
m_dragState->dropAction = event->dropAction;
+ setExecutedDropAction(event->dropAction);
+
QDrag *drag = new QDrag(this);
drag->setMimeData(new QMimeData());
drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction);
@@ -221,6 +228,7 @@ void QWasmDrag::onNativeDragLeave(DragEvent *event)
event->webEvent.call<void>("preventDefault");
if (m_dragState)
m_dragState->dropAction = event->dropAction;
+ setExecutedDropAction(event->dropAction);
event->dataTransfer.setDropAction(Qt::DropAction::IgnoreAction);
}