diff options
author | Lorn Potter <[email protected]> | 2023-10-11 09:45:55 +1000 |
---|---|---|
committer | Lorn Potter <[email protected]> | 2023-12-21 17:24:42 +1000 |
commit | e62fd1b7062af421cd289ff542514bd4332e1933 (patch) | |
tree | d8cea005075310fae8da6b5987aa06ed102482d5 /src/plugins/platforms/wasm/qwasmwindow.cpp | |
parent | 5af9c3d0e7e244009ffb4195ebcffb32101d8f04 (diff) |
wasm: add QWasmDrag back to handle drag/drop
Change-Id: I7c577e6b13db9f5c51e5691baaf6417b956a5ff4
Done-with: [email protected]
Pick-to: 6.7
Reviewed-by: Morten Johan Sørvig <[email protected]>
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmwindow.cpp')
-rw-r--r-- | src/plugins/platforms/wasm/qwasmwindow.cpp | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/src/plugins/platforms/wasm/qwasmwindow.cpp b/src/plugins/platforms/wasm/qwasmwindow.cpp index fa7eed14640..7a1ab876835 100644 --- a/src/plugins/platforms/wasm/qwasmwindow.cpp +++ b/src/plugins/platforms/wasm/qwasmwindow.cpp @@ -114,11 +114,6 @@ QWasmWindow::QWasmWindow(QWindow *w, QWasmDeadKeySupport *deadKeySupport, std::make_unique<qstdweb::EventCallback>(m_qtWindow, "pointerenter", pointerCallback); m_pointerLeaveCallback = std::make_unique<qstdweb::EventCallback>(m_qtWindow, "pointerleave", pointerCallback); - m_dropCallback = std::make_unique<qstdweb::EventCallback>( - m_qtWindow, "drop", [this](emscripten::val event) { - if (processDrop(*DragEvent::fromWeb(event, window()))) - event.call<void>("preventDefault"); - }); m_wheelEventCallback = std::make_unique<qstdweb::EventCallback>( m_qtWindow, "wheel", [this](emscripten::val event) { @@ -157,6 +152,11 @@ QSurfaceFormat QWasmWindow::format() const return window()->requestedFormat(); } +QWasmWindow *QWasmWindow::fromWindow(QWindow *window) +{ + return static_cast<QWasmWindow *>(window->handle()); +} + void QWasmWindow::onRestoreClicked() { window()->setWindowState(Qt::WindowNoState); @@ -535,24 +535,6 @@ bool QWasmWindow::processPointer(const PointerEvent &event) return false; } -bool QWasmWindow::processDrop(const DragEvent &event) -{ - dom::DataTransfer transfer(event.dataTransfer.webDataTransfer["clipboardData"]); - QMimeData *data = transfer.toMimeDataWithFile(); - // TODO handle file - QWindowSystemInterface::handleDrag(window(), data, - event.pointInPage.toPoint(), event.dropAction, - event.mouseButton, event.modifiers); - - QWindowSystemInterface::handleDrop(window(), data, - event.pointInPage.toPoint(), event.dropAction, - event.mouseButton, event.modifiers); - - QWindowSystemInterface::handleDrag(window(), nullptr, QPoint(), Qt::IgnoreAction, - {}, {}); - return true; -} - bool QWasmWindow::processWheel(const WheelEvent &event) { // Web scroll deltas are inverted from Qt deltas - negate. |