wasm: take canvas offset into account

This fixes issue with dialogs when the canvas is not at 0,0 in the
browser window

Change-Id: I14f6754746e064921635d6b3af3353bf3620ac44
Fixes: QTBUG-79160
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
Lorn Potter 2019-10-17 08:43:49 +10:00
parent a62a6b9b17
commit 26f9cb7ce5

View File

@ -186,8 +186,12 @@ void QWasmScreen::updateQScreenAndCanvasRenderSize()
canvas.set("width", canvasSize.width()); canvas.set("width", canvasSize.width());
canvas.set("height", canvasSize.height()); canvas.set("height", canvasSize.height());
QPoint offset;
offset.setX(emscripten::val::global(canvasId.constData())["offsetTop"].as<int>());
offset.setY(emscripten::val::global(canvasId.constData())["offsetLeft"].as<int>());
emscripten::val rect = canvas.call<emscripten::val>("getBoundingClientRect"); emscripten::val rect = canvas.call<emscripten::val>("getBoundingClientRect");
QPoint position(rect["left"].as<int>(), rect["top"].as<int>()); QPoint position(rect["left"].as<int>() - offset.x(), rect["top"].as<int>() - offset.y());
setGeometry(QRect(position, cssSize.toSize())); setGeometry(QRect(position, cssSize.toSize()));
m_compositor->redrawWindowContent(); m_compositor->redrawWindowContent();