From a66c73d95e6bb865d1cdae072dc140c7bb6ed6e2 Mon Sep 17 00:00:00 2001 From: Juha Vuolle Date: Thu, 10 Apr 2025 14:02:16 +0300 Subject: [PATCH] Allow configuring WASM without draganddrop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pick-to: 6.9 6.8 Fixes: QTBUG-135874 Change-Id: I84459af06d34682ca3bed1e2e1dab773c77bbcae Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/wasm/CMakeLists.txt | 6 +++++- src/plugins/platforms/wasm/qwasmintegration.cpp | 6 ++++++ src/plugins/platforms/wasm/qwasmwindow.cpp | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/wasm/CMakeLists.txt b/src/plugins/platforms/wasm/CMakeLists.txt index 7b2d79ce587..b00684a1378 100644 --- a/src/plugins/platforms/wasm/CMakeLists.txt +++ b/src/plugins/platforms/wasm/CMakeLists.txt @@ -33,7 +33,6 @@ qt_internal_add_plugin(QWasmIntegrationPlugin qwasmwindownonclientarea.cpp qwasmwindownonclientarea.h qwasminputcontext.cpp qwasminputcontext.h qwasmwindowstack.cpp qwasmwindowstack.h - qwasmdrag.cpp qwasmdrag.h DEFINES QT_EGL_NO_X11 QT_NO_FOREACH @@ -67,6 +66,11 @@ qt_internal_extend_target(QWasmIntegrationPlugin CONDITION QT_FEATURE_clipboard qwasmclipboard.cpp qwasmclipboard.h ) +qt_internal_extend_target(QWasmIntegrationPlugin CONDITION QT_FEATURE_draganddrop + SOURCES + qwasmdrag.cpp qwasmdrag.h +) + qt_internal_extend_target(QWasmIntegrationPlugin CONDITION QT_FEATURE_opengl SOURCES qwasmbackingstore.cpp qwasmbackingstore.h diff --git a/src/plugins/platforms/wasm/qwasmintegration.cpp b/src/plugins/platforms/wasm/qwasmintegration.cpp index 08092f2cccc..7b4b0421204 100644 --- a/src/plugins/platforms/wasm/qwasmintegration.cpp +++ b/src/plugins/platforms/wasm/qwasmintegration.cpp @@ -16,7 +16,9 @@ #include "qwasmwindow.h" #include "qwasmbackingstore.h" #include "qwasmfontdatabase.h" +#if QT_CONFIG(draganddrop) #include "qwasmdrag.h" +#endif #include #include @@ -31,7 +33,9 @@ // this is where EGL headers are pulled in, make sure it is last #include "qwasmscreen.h" +#if QT_CONFIG(draganddrop) #include +#endif QT_BEGIN_NAMESPACE @@ -148,7 +152,9 @@ QWasmIntegration::QWasmIntegration() visualViewport.call("addEventListener", val("resize"), val::module_property("qtResizeAllScreens")); } +#if QT_CONFIG(draganddrop) m_drag = std::make_unique(); +#endif } QWasmIntegration::~QWasmIntegration() diff --git a/src/plugins/platforms/wasm/qwasmwindow.cpp b/src/plugins/platforms/wasm/qwasmwindow.cpp index d0cc773cfed..e3e5f064811 100644 --- a/src/plugins/platforms/wasm/qwasmwindow.cpp +++ b/src/plugins/platforms/wasm/qwasmwindow.cpp @@ -23,7 +23,9 @@ #include "qwasmevent.h" #include "qwasmeventdispatcher.h" #include "qwasmaccessibility.h" +#if QT_CONFIG(draganddrop) #include "qwasmdrag.h" +#endif #include #include @@ -143,6 +145,7 @@ void QWasmWindow::registerEventHandlers() [this](emscripten::val event) { this->handlePointerEnterLeaveEvent(PointerEvent(EventType::PointerLeave, event)); } ); +#if QT_CONFIG(draganddrop) m_window.call("setAttribute", emscripten::val("draggable"), emscripten::val("true")); m_dragStartCallback = QWasmEventHandler(m_window, "dragstart", [this](emscripten::val event) { @@ -174,6 +177,7 @@ void QWasmWindow::registerEventHandlers() QWasmDrag::instance()->onNativeDragLeave(&dragEvent); } ); +#endif // QT_CONFIG(draganddrop) m_wheelEventCallback = QWasmEventHandler(m_window, "wheel", [this](emscripten::val event) { this->handleWheelEvent(event); });