wasm: deregister event handlers

Pick-to: 5.15
Change-Id: I453b87497c7ed93b92bf9f4c59ab1c8bd1d7712e
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
Lorn Potter 2020-08-21 12:53:55 +10:00
parent 86e90aa346
commit aed0f34786
2 changed files with 22 additions and 0 deletions

View File

@ -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();

View File

@ -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);