summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm/qwasmintegration.h
Commit message (Collapse)AuthorAgeFilesLines
* wasm: fix onLoaded delay functionalityMorten Sørvig2024-02-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | onLoaded and the initial expose/paint should be sequenced such that onLoaded is fired first, followed by the expose. This makes sure that we don't spend any time on painting frames before Qt is completely initialized. Add a "requestUpdateHold" mode to QWasmCompositor (initially on) which disables requestUpdate calls, as well as releaseRequestUpdateHold() which enables requestUpdate calls again. This is a one-way transition; the mode can't be enabled again. This amends commit f2e22774 which implemented the concept of startup tasks, where onLoaded can be delayed until for instance font loading has been completed. After this commit the expose event and initial commit will be delayed as well. Change-Id: Icc784306726174fbabe8785d54485860e968745a Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
* wasm: add QWasmDrag back to handle drag/dropLorn Potter2023-12-211-2/+2
| | | | | | | Change-Id: I7c577e6b13db9f5c51e5691baaf6417b956a5ff4 Done-with: Mikolaj.Boc@qt.io Pick-to: 6.7 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: add config API for controlling local font loadingMorten Sørvig2023-12-181-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | This makes Qt read the following config options at startup: - qt.requestLocalFontsPermission - qt.localFontFamiliesCollection - qt.extraLocalFontFamilies And adds the following instance function - qtLoadLocalFontFamilies These can be used to control which local fonts Qt will use, and also if Qt should ask for local fonts permission on startup. Also register a startup task for font loading. Font loading completes asynchronously at some point after the initial startup, and this way we can prevent showing the application until the requested fonts are available. Change-Id: I2b353c8b9c1a4976dddeb447d1f867aa2adf7588 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Modernize the qtloaderMikolaj Boc2023-06-051-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | This is a minimal version of qtloader. The load function accepts the same arguments as emscripten runtime with a few additions: - qt.environment - qt.onExit - qt.containerElements - qt.fontDpi - qt.onLoaded - qt.entryFunction State handling has been removed in favor of making the load async (assume loading when the promise is live). Public APIs getting crashed status, exit text and code have been refactored into the new qt.onExit event fed to load. No need for keeping the state in the loader. The loader is integration-tested. A test module with test APIs has been created as a test harness. The runtime APIs exposed by Qt (font dpi and screen API) are handled by the qtloader seamlessly. Change-Id: Iaee65702667da0349a475feae6b83244d966d98d Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Handle the drop event in the wasm window elementMikolaj Boc2023-01-201-4/+0
| | | | | | | | | | | | | | Drop events are now handled in the wasm window element, which allows the browser to select the drop target automatically. This also fixes the case where drop data transfer finishes reading when a window has already been closed and destroyed - the cancellation flag is now owned by window so it gets invalidated as soon as window is gone. The code has also been structured with a new DragEvent passthrough. Fixes: QTBUG-109581 Change-Id: Ie3eb7446e2181fd540517f39397e8b35f111d009 Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
* Streamline reading of js DataTransfer objectMikolaj Boc2023-01-181-8/+10
| | | | | | | | | | | | | | | | | | qwasmclipboard.cpp and qwasmdrag.cpp had the same logic that read the js DataTransfer object implemented twice with small differences. Use a single implementation in both. This also introduces a clearer memory ownership model in the reader code, and fixes a potential race condition by introducing a cancellation flag. Removed the useless QWasmDrag type which was in essence a SimpleDrag and made the m_drag in QWasmIntegration a smart pointer. Fixes: QTBUG-109626 Pick-to: 6.5 Change-Id: I5b76dd3b70ab2e5a8364d9a136c970ee8d4fae9c Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Improve window dragging on WASMMikolaj Boc2022-07-251-10/+0
| | | | | | | | | | | | | Window dragging has been considerably improved by replacing the mouse events by pointer events and placing a pointer lock on WASM canvas, so that off-browser window events are delivered to us. Translation of the drag origin has been limited to inside the canvas, so that a window cannot be dragged so far that it becomes offscreen and is unreachable. Change-Id: Id177c630a6466f04464a513371d6b97d3a098b6a Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: begin work on accessibility backendMorten Sørvig2022-07-061-0/+6
| | | | | | | | | | | Implement a11y support by adding html elements of the appropriate type and/or with the appropriate ARIA attribute behind the canvas. Also add a simple manual-test. Change-Id: I2898fb038c1d326135a1341cdee323bc964420bb Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Use SPDX license identifiersLucie Gérard2022-05-161-28/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* wasm: add support for drag into browser windowLorn Potter2022-05-101-0/+13
| | | | | | | | | Drag and drop into the browser will work. Drag and drop out of the browser will not. Fixes: QTBUG-102242 Change-Id: Id9981ab6f9514535e1409bec18068790833a67a6 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: fix native keyboard on iOSLorn Potter2022-03-051-1/+2
| | | | | | | | | Apple added iPhonePlatform to navigator properties and so use that Fixes: QTBUG-101441 Change-Id: I5a0f27fc18dfa224b6373c5d809cf884d51c880a Pick-to: 6.3 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: enable mobile native keyboardingLorn Potter2022-03-031-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | This works on iOS and Android, and Windows with touchscreen. On Android, we need to listen to the input event of a hidden text element and synthesize Qt keyboard events from that in order to get input events into Qt. On Windows, we need to be more creative about bringing the native virtual keyboard up. Because the entire canvas is contenteditable, we need to specify the inputmode is set to 'none', otherwise the v keyboard pops up when user clicks anywhere on the canvas. Therefore we set a hidden element as contenteditable, which pops up keyboard when Qt needs it for editable widgets. On Android, this is the same element that is used to proxy the keyboard input. [ChangeLog][wasm] Add support for native mobile keyboard Done-with: Morten Johan Sørvig <morten.sorvig@qt.io> Fixes: QTBUG-83064 Fixes: QTBUG-88803 Change-Id: I769fe344fc10c17971bd1c0a603501040fe82653 Reviewed-by: David Skoland <david.skoland@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Move input event logic into QWasmCompositorDavid Skoland2022-01-171-0/+1
| | | | | | | | | | | | | | | | | | | | | Move the window logic and state out of QWasmEventTranslator and into QWasmCompositor. The reasoning for this change is that the state of the windowing system was split between QWasmCompositor (eg. window stack) and QWasmEventTranslator (eg. dragged and pressed windows). This change moves the input handling and state to QWasmCompositor and demotes QWasmEventTranslator to a helper class. In this model, QWC acts as a proper window system / display server and can leverage multiple helper classes which are "owned" by the QWC. Here is a quick diagram illustrating the proposed general architecture around WASM window handling and its difference from typical OSes: https://i.imgur.com/vcBwUPf.png Change-Id: Idca617992b8e1b431e5c71d46b5db61597c99e75 Pick-to: 6.3 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: do not quit() on beforeunload()Morten Sørvig2021-06-231-1/+0
| | | | | | | | | | | | | | | | | | | | | This is the wrong event: exiting the app here it is not compatible with the back/forward cache for instance. See the the MDN docs for the “Window: unload” event. Instead, make the Qt default be that we assume the app process will live “forever” until the browser terminates it, much like modern process handling on e.g. iOS. We may want to come back to app lifecycle handling at a later point. This might require changes to application code: implementing main() in such that it supports clean shutdowns and auditing showdown code to make sure it is web-compatible. Change-Id: I0f32026a3af76c9cc79e3aab31e8aaed7b8f8023 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Use QList instead of QVector in pluginsJarek Kobus2020-07-061-1/+1
| | | | | | Task-number: QTBUG-84469 Change-Id: Ic86f4a3000592a1c9ae62e4a83f4fe39832a6b24 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Merge remote-tracking branch 'origin/5.14' into 5.15Lars Knoll2020-02-271-0/+1
|\ | | | | | | Change-Id: I4212d070d5752275085e754b96f0392113604dba
| * wasm: fix texture leak when window is destroyed in a different contextAlexandra Cherdantseva2020-02-271-0/+1
| | | | | | | | | | | | | | | | | | | | Reproduce: Show first window in first canvas; Show second window in second canvas; After screens are rendered destroy first window in first canvas Change-Id: Ifbeb4824c1fdedecf24d5d20e58613d15c066420 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* | wasm: store and pass canvases as emscripten::valMorten Johan Sørvig2020-02-121-5/+5
|/ | | | | | | | | | | | | | | | | | | | Store and pass canvases as emscripten::val instead of a QString containing the element id. This simplifies code which interacts with the canvas using the emscripten::val API, by removing the need to look up with getElementById. The Emscripten C event API does not accept emscripten::val, and using the element id is still needed here. emscripten::val does not provide a hash key suitable for use with QHash, but does provide an equality-compare in the form of val::equals(). Change the canvas->screen mapping code to use a QVector instead of a QHash. Change-Id: I1dbdbbc8fb06bb869031f1500e83ae2d64780a7f Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Merge remote-tracking branch 'origin/5.13.0' into 5.13Liang Qi2019-06-111-0/+2
|\ | | | | | | | | | | | | | | Conflicts: src/plugins/platforms/wasm/qwasmintegration.cpp src/plugins/platforms/wasm/qwasmintegration.h Change-Id: Idf4c7936513fb1f21daa8f6105b8545f13447bb8
| * wasm: add QWasmOffscreenSurfaceMorten Johan Sørvig2019-05-141-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This no-op implementation is sufficient to support OpenGL cleanup use cases, where the OpenGL context needs to be made current at times where we don't have a window available. A specific requirement on WebAssembly is that the context is tied to one specific screen; which is an extra requirement on QWasmOffscreenSurface, compared to the other platforms. Task-number: QTBUG-75463 Change-Id: Ie3658cb235bf342be66f19dfe981e3a56a90e1b6 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
| * wasm: install one browser window resize handlerMorten Johan Sørvig2019-05-141-0/+1
| | | | | | | | | | | | | | | | | | | | Install one browser window resize handler instead of per-canvas resize handlers, which avoids having to uninstall on QScreen destruction. Task-number: QTBUG-75463 Change-Id: I8345262a906ed735f8e9e146f1e963f515cf0d25 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* | wasm: add Qt Virtual Keyboard supportDongmei Wang2019-05-161-0/+5
| | | | | | | | | | Change-Id: I454ab677cad25b50ba7b03ef2c4b6046e1227ce8 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* | wasm: support setting the font DPI from JSMorten Johan Sørvig2019-05-131-0/+2
|/ | | | | | | | | | | | | | | 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: implement QDesktopServices::openUrl()Morten Johan Sørvig2019-04-021-1/+3
| | | | | | | Call window.open(url, ”_blank”) for a new tab. Change-Id: I227904f905262c7aedd086203ed816b53f66359c Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: make windows fullscreen by defaultMorten Johan Sørvig2019-04-011-0/+1
| | | | | | | | | | | | | (fullscreen as in use the entire canvas area, without showing window decorations) This is a better default for Qt on the web where window decorations are not common. We also avoid the “window close” trap, where there is no way to re-open a closed main window. Change-Id: Ie0fbf6ada3f49244bee765ea882acb473809e715 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: add resizeCanvasElement() API to qtloader.jsMorten Johan Sørvig2019-04-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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-4/+3
| | | | | | | | | | | | | 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-7/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: make wasm platform target a specific canvas instead of defaultLorn Potter2019-03-081-2/+1
| | | | | | | | This allows for multi canvas use Task-number: QTBUG-64079 Change-Id: I69c998aa4c2869bb5b7f14ba65bb63284365ad70 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: add clipboard supportLorn Potter2019-02-151-1/+7
| | | | | | | | | | | | | | | | | | | This feature uses the js Clipboard API and is supported only in Chrome, as Firefox only supports reading the clipboard in browser extensions. It also requires https or localhost access, otherwise access to the clipboard is blocked by chrome. Chrome users will be able to copy/paste text to and from the system clipbaord. Other browsers will be able to use the clipboard from within the same application. Currently only supports text and html. Task-number: QTBUG-64638 Change-Id: Ie6de9d10812b776519bd6115593b433fe77059fe Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* WebAssembly for QtBaseMorten Johan Sørvig2018-08-301-0/+92
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>