Revert "wasm: Specify event targets by CSS selectors; Support emsdk >= 1.39.5"

This reverts commit c6da278271.

This was a 5.15-only change which should not go into 5.14
since it raises the minimum supported emsdk version.

Task-number: QTBUG-83098
Change-Id: I9e15952803f9dfff89b5b4e9caeff5c03dabca27
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
Morten Johan Sørvig 2020-03-27 10:49:31 +01:00
parent bd78753d62
commit 3a6d8df521
4 changed files with 20 additions and 21 deletions

View File

@ -339,7 +339,8 @@ QWasmEventTranslator::QWasmEventTranslator(QWasmScreen *screen)
void QWasmEventTranslator::initEventHandlers()
{
QByteArray canvasSelector = "#" + screen()->canvasId().toUtf8();
QByteArray _canvasId = screen()->canvasId().toUtf8();
const char *canvasId = _canvasId.constData();
// The Platform Detect: expand coverage and move as needed
enum Platform {
@ -363,21 +364,21 @@ void QWasmEventTranslator::initEventHandlers()
}
}
emscripten_set_keydown_callback(canvasSelector.constData(), (void *)this, 1, &keyboard_cb);
emscripten_set_keyup_callback(canvasSelector.constData(), (void *)this, 1, &keyboard_cb);
emscripten_set_keydown_callback(canvasId, (void *)this, 1, &keyboard_cb);
emscripten_set_keyup_callback(canvasId, (void *)this, 1, &keyboard_cb);
emscripten_set_mousedown_callback(canvasSelector.constData(), (void *)this, 1, &mouse_cb);
emscripten_set_mouseup_callback(canvasSelector.constData(), (void *)this, 1, &mouse_cb);
emscripten_set_mousemove_callback(canvasSelector.constData(), (void *)this, 1, &mouse_cb);
emscripten_set_mousedown_callback(canvasId, (void *)this, 1, &mouse_cb);
emscripten_set_mouseup_callback(canvasId, (void *)this, 1, &mouse_cb);
emscripten_set_mousemove_callback(canvasId, (void *)this, 1, &mouse_cb);
emscripten_set_focus_callback(canvasSelector.constData(), (void *)this, 1, &focus_cb);
emscripten_set_focus_callback(canvasId, (void *)this, 1, &focus_cb);
emscripten_set_wheel_callback(canvasSelector.constData(), (void *)this, 1, &wheel_cb);
emscripten_set_wheel_callback(canvasId, (void *)this, 1, &wheel_cb);
emscripten_set_touchstart_callback(canvasSelector.constData(), (void *)this, 1, &touchCallback);
emscripten_set_touchend_callback(canvasSelector.constData(), (void *)this, 1, &touchCallback);
emscripten_set_touchmove_callback(canvasSelector.constData(), (void *)this, 1, &touchCallback);
emscripten_set_touchcancel_callback(canvasSelector.constData(), (void *)this, 1, &touchCallback);
emscripten_set_touchstart_callback(canvasId, (void *)this, 1, &touchCallback);
emscripten_set_touchend_callback(canvasId, (void *)this, 1, &touchCallback);
emscripten_set_touchmove_callback(canvasId, (void *)this, 1, &touchCallback);
emscripten_set_touchcancel_callback(canvasId, (void *)this, 1, &touchCallback);
}
template <typename Event>

View File

@ -108,8 +108,9 @@ QWasmIntegration::QWasmIntegration()
s_instance = this;
// We expect that qtloader.js has populated Module.qtCanvasElements with one or more canvases.
// Also check Module.canvas, which may be set if the emscripen or a custom loader is used.
emscripten::val qtCanvaseElements = val::module_property("qtCanvasElements");
emscripten::val canvas = val::module_property("canvas"); // TODO: remove for Qt 6.0
emscripten::val canvas = val::module_property("canvas");
if (!qtCanvaseElements.isUndefined()) {
int screenCount = qtCanvaseElements["length"].as<int>();
@ -118,9 +119,7 @@ QWasmIntegration::QWasmIntegration()
QString canvasId = QWasmString::toQString(canvas["id"]);
addScreen(canvasId);
}
} else if (!canvas.isUndefined()) {
qWarning() << "Module.canvas is deprecated. A future version of Qt will stop reading this property. "
<< "Instead, set Module.qtCanvasElements to be an array of canvas elements, or use qtloader.js.";
} else if (!canvas.isUndefined()){
QString canvasId = QWasmString::toQString(canvas["id"]);
addScreen(canvasId);
}
@ -140,7 +139,7 @@ QWasmIntegration::QWasmIntegration()
integration->resizeAllScreens();
return 0;
};
emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, nullptr, 1, onWindowResize);
emscripten_set_resize_callback(nullptr, nullptr, 1, onWindowResize);
}
QWasmIntegration::~QWasmIntegration()

View File

@ -106,8 +106,7 @@ EMSCRIPTEN_WEBGL_CONTEXT_HANDLE QWasmOpenGLContext::createEmscriptenContext(cons
attributes.depth = useDepthStencil;
attributes.stencil = useDepthStencil;
QByteArray convasSelector = "#" + canvasId.toUtf8();
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context(convasSelector.constData(), &attributes);
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context(canvasId.toUtf8().constData(), &attributes);
return context;
}

View File

@ -178,10 +178,10 @@ void QWasmScreen::updateQScreenAndCanvasRenderSize()
// Setting the render size to a value larger than the CSS size enables high-dpi
// rendering.
QByteArray canvasSelector = "#" + m_canvasId.toUtf8();
QByteArray canvasId = m_canvasId.toUtf8();
double css_width;
double css_height;
emscripten_get_element_css_size(canvasSelector.constData(), &css_width, &css_height);
emscripten_get_element_css_size(canvasId.constData(), &css_width, &css_height);
QSizeF cssSize(css_width, css_height);
QSizeF canvasSize = cssSize * devicePixelRatio();