From 97c40bf5bf0fb5b924e16061286a29b979d0ff4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Fri, 9 Jun 2023 17:09:41 +0200 Subject: [PATCH] wasm: expose windows before delivering updates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't show a blank frame on app startup. The wasm update request system supports two types of update requests: Expose and UpdateRequest. It can happen that both types of request are made for a single window, in which case the current code prefers UpdateRequest, since those must be delivered in order to keep QWindow in a consistent state. However, if the window is visible but not yet exposed then delivering the update request will not make the window paint anything, and we end up with a blank frame. Ideally this should be handled elsewhere and QWindow::requestUpdate() should not be called for non-exposed windows, but in the case does happen then sending an expose here allows us to recover. Change-Id: Ib53050c33ad1769ea9b9ad678896af15f87a7ecb (cherry picked from commit 4c18ebbc1c0bddca4b19a585d2d3a5dafdefc4a3) Reviewed-by: MikoĊ‚aj Boc --- src/plugins/platforms/wasm/qwasmcompositor.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/wasm/qwasmcompositor.cpp b/src/plugins/platforms/wasm/qwasmcompositor.cpp index 5deba235486..92e31507388 100644 --- a/src/plugins/platforms/wasm/qwasmcompositor.cpp +++ b/src/plugins/platforms/wasm/qwasmcompositor.cpp @@ -172,13 +172,18 @@ void QWasmCompositor::deliverUpdateRequests() void QWasmCompositor::deliverUpdateRequest(QWasmWindow *window, UpdateRequestDeliveryType updateType) { - // update by deliverUpdateRequest and expose event accordingly. + // Update by deliverUpdateRequest and expose event according to requested update + // type. If the window has not yet been exposed then we must expose it first regardless + // of update type. The deliverUpdateRequest must still be sent in this case in order + // to maintain correct window update state. + QWindow *qwindow = window->window(); + QRect updateRect(QPoint(0, 0), qwindow->geometry().size()); if (updateType == UpdateRequestDelivery) { + if (qwindow->isExposed() == false) + QWindowSystemInterface::handleExposeEvent(qwindow, updateRect); window->deliverUpdateRequest(); } else { - QWindow *qwindow = window->window(); - QWindowSystemInterface::handleExposeEvent( - qwindow, QRect(QPoint(0, 0), qwindow->geometry().size())); + QWindowSystemInterface::handleExposeEvent(qwindow, updateRect); } }