From 69ad72b05ce391c114b5e97fdd6a262b9f5ac0cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Fri, 13 May 2022 10:52:51 +0200 Subject: [PATCH] wasm: use correct geometry when drawing window decorations We were drawing window decorations at an incorrect location in cases where the QScreen was not at (0,0) (i.e. at an offset on the web page). Window content was placed correctly. Correct canvas geometry can be fond by offsetting window geometry by the negative screen position. Implement this for drawWindowDecorations(), and also simplify the existing code in drawWindowContent(). Change-Id: I1347d325a58dae5e2bb950b93902123f64199ee8 Reviewed-by: Lorn Potter Reviewed-by: David Skoland --- src/plugins/platforms/wasm/qwasmcompositor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/wasm/qwasmcompositor.cpp b/src/plugins/platforms/wasm/qwasmcompositor.cpp index ad4d249e5e6..9f6e686ac4f 100644 --- a/src/plugins/platforms/wasm/qwasmcompositor.cpp +++ b/src/plugins/platforms/wasm/qwasmcompositor.cpp @@ -326,8 +326,7 @@ void QWasmCompositor::drawWindowContent(QOpenGLTextureBlitter *blitter, QWasmScr return; QOpenGLTexture const *texture = backingStore->getUpdatedTexture(); - QPoint windowCanvasPosition = window->geometry().topLeft() - screen->geometry().topLeft(); - QRect windowCanvasGeometry = QRect(windowCanvasPosition, window->geometry().size()); + QRect windowCanvasGeometry = window->geometry().translated(-screen->geometry().topLeft()); blit(blitter, screen, texture, windowCanvasGeometry); } @@ -585,7 +584,8 @@ void QWasmCompositor::drawWindowDecorations(QOpenGLTextureBlitter *blitter, QWas glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, image.width(), image.height(), GL_RGBA, GL_UNSIGNED_BYTE, image.constScanLine(0)); - blit(blitter, screen, &texture, QRect(window->windowFrameGeometry().topLeft(), QSize(width, height))); + QRect windowCanvasGeometry = window->windowFrameGeometry().translated(-screen->geometry().topLeft()); + blit(blitter, screen, &texture, windowCanvasGeometry); } void QWasmCompositor::drawFrameWindow(QWasmFrameOptions options, QPainter *painter)