diff options
author | Lorn Potter <lorn.potter@gmail.com> | 2021-12-16 12:54:31 +1000 |
---|---|---|
committer | Lorn Potter <lorn.potter@gmail.com> | 2022-01-12 11:41:10 +1000 |
commit | 8f7bebb611958fe937c5bd38947f75620cfb94a8 (patch) | |
tree | c127f2c383b1693aa9eeef70806593fb2e9eaa14 /src/plugins/platforms/wasm/qwasmcursor.cpp | |
parent | 66a183298a8ff3d51da02f25ffe5eeea0ea76862 (diff) |
wasm: ensure cursor reverts after window resize
This partially reverts 97be0cca174a3b92c24062c557bf4df34db23f7b
but without the crash
We temporarily override the wasm cursor while leaving the
application/window cursor alone to mimic what desktop application
behavior is like.
Pick-to: 6.3
Fixes: QTBUG-99111
Change-Id: I23df48b2eaa82830593f1753ec23d14fe375b70c
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmcursor.cpp')
-rw-r--r-- | src/plugins/platforms/wasm/qwasmcursor.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/plugins/platforms/wasm/qwasmcursor.cpp b/src/plugins/platforms/wasm/qwasmcursor.cpp index 4b4bb61071..a9336bdc8f 100644 --- a/src/plugins/platforms/wasm/qwasmcursor.cpp +++ b/src/plugins/platforms/wasm/qwasmcursor.cpp @@ -47,7 +47,6 @@ void QWasmCursor::changeCursor(QCursor *windowCursor, QWindow *window) if (!screen) return; - QByteArray htmlCursorName; if (windowCursor) { // Bitmap and custom cursors are not implemented (will fall back to "auto") @@ -60,10 +59,7 @@ void QWasmCursor::changeCursor(QCursor *windowCursor, QWindow *window) if (htmlCursorName.isEmpty()) htmlCursorName = "default"; - // Set cursor on the canvas - val canvas = QWasmScreen::get(screen)->canvas(); - val canvasStyle = canvas["style"]; - canvasStyle.set("cursor", val(htmlCursorName.constData())); + setWasmCursor(screen, htmlCursorName); } QByteArray QWasmCursor::cursorShapeToHtml(Qt::CursorShape shape) @@ -143,3 +139,23 @@ QByteArray QWasmCursor::cursorShapeToHtml(Qt::CursorShape shape) return cursorName; } + +void QWasmCursor::setWasmCursor(QScreen *screen, const QByteArray &name) +{ + // Set cursor on the canvas + val canvas = QWasmScreen::get(screen)->canvas(); + val canvasStyle = canvas["style"]; + canvasStyle.set("cursor", val(name.constData())); +} + +void QWasmCursor::setOverrideWasmCursor(QCursor *windowCursor, QScreen *screen) +{ + QWasmCursor *wCursor = static_cast<QWasmCursor *>(QWasmScreen::get(screen)->cursor()); + wCursor->setWasmCursor(screen, wCursor->cursorShapeToHtml(windowCursor->shape())); +} + +void QWasmCursor::clearOverrideWasmCursor(QScreen *screen) +{ + QWasmCursor *wCursor = static_cast<QWasmCursor *>(QWasmScreen::get(screen)->cursor()); + wCursor->setWasmCursor(screen, wCursor->htmlCursorName); +} |