summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm/qtloader.js
Commit message (Collapse)AuthorAgeFilesLines
* wasm: support setting the font DPI from JSMorten Johan Sørvig2019-05-131-0/+14
| | | | | | | | | | | | | | | We have not really been able to determine what the default DPI should be, so make it configurable with API on qtloader.js: qtLoader.setFontDpi(72); Also lowers the default DPI to the standard value of 96 (down from Qt default 100). Task-number: QTBUG-75510 Change-Id: Ica1164c8d80bb06519233adebf2c9e400c0991ce Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* wasm: fix passing environmental variablesLorn Potter2019-05-061-1/+1
| | | | | | Task-number: QTBUG-75530 Change-Id: Ic0f0bd8ce863f55d737d96bbf9e5473466381c9b Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: hide canvas text caretMorten Johan Sørvig2019-04-041-0/+1
| | | | | | | | Another side effect of setting contenteditable on the canvas. Seen on Firefox. Change-Id: I789ba4d7e6fbbdbf14b66fe1ae57183ec04e04bb Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: add resizeCanvasElement() API to qtloader.jsMorten Johan Sørvig2019-04-011-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | HTMl does not have per-element resize events, which means Qt has not way of knowing that a canvas has been resized and that the canvas buffer size should be updated. Depending on the use case, the hosting JavaScript code that caused the canvas resize could also inform Qt that the canvas has been resized. Add API to do this, which calls the existing canvas/screen resize implementation. Other solutions taken/not taken: - browser window resize events: these are available, and we install an event handler in qwasmeventtranslator.cpp. - DOM mutation events: would detect changes to the the size attributes themselves, but not if the size indirectly changed, e.g. “width: 100%” depends on the parent width. Not implemented. Change-Id: Ib324bb30f523e9fceea68000b95bf857a1d36b6c Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: support adding and removing canvases at runtimeMorten Johan Sørvig2019-04-011-0/+20
| | | | | | | | | | | | | Add qtloader API: addCanvasElement() removeCanvasElement() These functions call the corresponding add/remove screen functions on QWasmIntegration. Task-number: QTBUG-64079 Change-Id: I537c11f3b5fb9240cca9b6313dd45f803d865ac6 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: support rendering to multiple canvasesMorten Johan Sørvig2019-03-081-23/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Qt (via the the qtloader.js API) now supports rendering to multiple canvases. The application sees each canvas as a QScreen. Make qtloader.js support multiple canvases: var qtloader = QtLoader({ canvasElements : [array-of-canvas], showCanvas: function() { // make canvas(es) visible }, }); The canvases were previously created/returned by showCanvas(), however this function is called after the Qt app has been started and adding screens that that point is too late. (This worked before since there was only one screen, and no need to connect each screen instance to specific canvas.) Remove QWasmScreen, QWasmCompositor, and QWasmEventTranslator singletons from QWasmIntegration. These are are now crated per-screen and are owned by the QWasmScreen. Task-number: QTBUG-64079 Change-Id: I24689929fd5bfb7ff0ba076f66937728fa4bc4e4 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: improve clipboard fallback pathMorten Johan Sørvig2019-03-041-1/+8
| | | | | | | | | | | | | | | | | | | | | | This improves handling of cut/copy/paste clipboard events, ands allows clipboard access via the common keyboard shortcuts. Make the canvas be eligible for clipboard events by setting the contenteditable attribute. Install clipboard event handlers directly on the canvas. Suppress Ctrl+X/C/V key event handling in the keyboard event handler in order to make the browser generate clipboard events. Send synthetic key events from the clipboard event handlers to make the app copy/paste to Qt’s clipboard at the correct time. Access the system clipboard data using event.clipboardData. Task-number: QTBUG-64638 Change-Id: I584b78ffa2b755b1b76e477b970255c6e5522f6a Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Wasm: enable thread supportMorten Johan Sørvig2019-02-071-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | configure.json: Make the “thread” feature be allowed for wasm but disabled by default. Change qmake.conf and wasm.prf to enable Emscripten pthreads mode: - Add USE_PTHREADS=1 linker flag - Add PTHREAD_POOL_SIZE linker flag with a default pool size (4). - Add TOTAL_MEMORY linker flag to set available memory (1GB) It is possible to override options such as PTHREAD_POOL_SIZE from the application .pro file using QMAKE_WASM_PTHREAD_POOL_SIZE To change TOTAL_MEMORY, use QMAKE_WASM_TOTAL_MEMORY Make qtloader.js work in pthreads mode: - The Module.instantiateWasm callback must provide the module in addition to the instance to Emscripten. - Set Module.mainScriptUrlOrBlob so that the pthreads web workers can access the main script Task-number: QTBUG-64625 Change-Id: I1ab5a559ec97c27c5fc24500ba5f863bcd275141 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* WebAssembly for QtBaseMorten Johan Sørvig2018-08-301-0/+516
This is the squashed diff from wip/webassembly to dev. Done-with: Peng Wu <peng.wu@intopalo.com> Done-with: Sami Enne <sami.enne@intopalo.com> Done-with: Morten Johan Sørvig <morten.sorvig@qt.io> Started-by: Andrew Knight <andrew.knight@intopalo.com> Change-Id: I6562433c0a38d6ec49ab675e0f104f2665f3392d Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>