summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm
diff options
context:
space:
mode:
authorLorn Potter <lorn.potter@gmail.com>2020-08-21 12:53:55 +1000
committerLorn Potter <lorn.potter@gmail.com>2020-08-25 06:50:55 +1000
commitaed0f34786100c9e113d0bb31779b3a6a0d5ba33 (patch)
treeaa3a0754a08261658bcc7a1edc88a886e1b0c98d /src/plugins/platforms/wasm
parent86e90aa34643222701d7e9fc49e594c90f79218e (diff)
wasm: deregister event handlers
Pick-to: 5.15 Change-Id: I453b87497c7ed93b92bf9f4c59ab1c8bd1d7712e Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/platforms/wasm')
-rw-r--r--src/plugins/platforms/wasm/qwasmeventtranslator.cpp21
-rw-r--r--src/plugins/platforms/wasm/qwasmeventtranslator.h1
2 files changed, 22 insertions, 0 deletions
diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp
index 8c0d2e21e0..82dd00bb65 100644
--- a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp
+++ b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp
@@ -337,6 +337,27 @@ QWasmEventTranslator::QWasmEventTranslator(QWasmScreen *screen)
initEventHandlers();
}
+QWasmEventTranslator::~QWasmEventTranslator()
+{
+ // deregister event handlers
+ QByteArray canvasSelector = "#" + screen()->canvasId().toUtf8();
+ emscripten_set_keydown_callback(canvasSelector.constData(), 0, 0, NULL);
+ emscripten_set_keyup_callback(canvasSelector.constData(), 0, 0, NULL);
+
+ emscripten_set_mousedown_callback(canvasSelector.constData(), 0, 0, NULL);
+ emscripten_set_mouseup_callback(canvasSelector.constData(), 0, 0, NULL);
+ emscripten_set_mousemove_callback(canvasSelector.constData(), 0, 0, NULL);
+
+ emscripten_set_focus_callback(canvasSelector.constData(), 0, 0, NULL);
+
+ emscripten_set_wheel_callback(canvasSelector.constData(), 0, 0, NULL);
+
+ emscripten_set_touchstart_callback(canvasSelector.constData(), 0, 0, NULL);
+ emscripten_set_touchend_callback(canvasSelector.constData(), 0, 0, NULL);
+ emscripten_set_touchmove_callback(canvasSelector.constData(), 0, 0, NULL);
+ emscripten_set_touchcancel_callback(canvasSelector.constData(), 0, 0, NULL);
+}
+
void QWasmEventTranslator::initEventHandlers()
{
QByteArray canvasSelector = "#" + screen()->canvasId().toUtf8();
diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.h b/src/plugins/platforms/wasm/qwasmeventtranslator.h
index f6c95770e9..b02685bedd 100644
--- a/src/plugins/platforms/wasm/qwasmeventtranslator.h
+++ b/src/plugins/platforms/wasm/qwasmeventtranslator.h
@@ -49,6 +49,7 @@ class QWasmEventTranslator : public QObject
public:
explicit QWasmEventTranslator(QWasmScreen *screen);
+ ~QWasmEventTranslator();
static int keyboard_cb(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData);
static int mouse_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData);