wasm: use QWasmWindow::fromWindow()

Make it test for null QWindow and handle(), use it
instead of C-style casting handle().

Change-Id: I7ffb1ef5d3d3c09c8ae44ec0141e93530a04abe6
Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
This commit is contained in:
Morten Sørvig 2025-02-25 16:03:13 +01:00
parent bdc9665494
commit 83b6139149
3 changed files with 6 additions and 4 deletions

View File

@ -327,8 +327,8 @@ void QWasmInputContext::updateInputElement()
m_inputElement.set("value", "");
m_inputElement.call<void>("blur");
if (focusWindow && focusWindow->handle())
((QWasmWindow *)(focusWindow->handle()))->focus();
if (QWasmWindow *wasmwindow = QWasmWindow::fromWindow(focusWindow))
wasmwindow->focus();
return;
}

View File

@ -211,8 +211,10 @@ QSurfaceFormat QWasmWindow::format() const
return window()->requestedFormat();
}
QWasmWindow *QWasmWindow::fromWindow(QWindow *window)
QWasmWindow *QWasmWindow::fromWindow(const QWindow *window)
{
if (!window ||!window->handle())
return nullptr;
return static_cast<QWasmWindow *>(window->handle());
}

View File

@ -45,7 +45,7 @@ public:
QWasmBackingStore *backingStore, WId nativeHandle);
~QWasmWindow() final;
static QWasmWindow *fromWindow(QWindow *window);
static QWasmWindow *fromWindow(const QWindow *window);
QSurfaceFormat format() const override;
void registerEventHandlers();