summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm/qwasmintegration.cpp
Commit message (Collapse)AuthorAgeFilesLines
* wasm: Make sure we can add screen after releaseRequestUpdateHold has been calledEven Oscar Andersen2024-03-051-2/+5
| | | | | | | | | | | | | | Before this fix, such screens would not render due to requestUpdateHold is initialized to true and never reset. The fix is to change the requestUpdateHold member to be a static variable, so that it can be read by screens added after requestUpdateHold has been called. Also, add a test that would fail without this fix Change-Id: Idf2ac916766a03480272cd550f9d1ab7fc5c5158 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Add QT_IM_MODULES env to allows specify multi IM keyJiDe Zhang2024-03-051-4/+4
| | | | | | | | | | | | | | | | | Like as QT_QPA_PLATFORM, supports specifying multiple keys, and can perform fallback operations to prioritize the use of a certain plug-in. This is useful when using Wayland and XWayland applications at the same time. For an example, we can set "QT_IM_MODULES=wayland;fcitx", and the wayland application will use the wayland input context plugin, the xwayland application will use fcitx, which can't be done without adding a new environment variable, if we specify "QT_IM_MODULE=wayland", the XWayland applications may not be able to use the input method. Fixes: QTBUG-120202 Change-Id: Iac408af241963147747a2fe685f1e27bf9d9ee64 Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: David Edmundson <davidedmundson@kde.org>
* wasm: fix onLoaded delay functionalityMorten Sørvig2024-02-081-0/+7
| | | | | | | | | | | | | | | | | | | | | | | 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: Handle stylus events by generating QTabletEventsShawn Rutledge2023-12-281-0/+2
| | | | | | | Pick-to: 6.6 6.7 Fixes: QTBUG-120327 Change-Id: I37a92b9850385712b638c30f9a43028d8134f416 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: add QWasmDrag back to handle drag/dropLorn Potter2023-12-211-1/+3
| | | | | | | 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-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* wasm: rename JsString -> EcmaStringMorten Sørvig2023-08-301-1/+1
| | | | | | | | | | | | | QString::fromJsString -> QString::fromEcmaString() QString::toJsString() -> QString::toEcmaString() For API naming compatibility with QByteArray::fromEcmaUin8Array() Pick-to: 6.6 Change-Id: If6e2121e31e630d6728ed24e41d14b763f395aaa Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io> Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Remove the unix dispatcher from WASM buildsMikolaj Boc2023-08-221-3/+0
| | | | | | | Unix dispatcher is not used and - as such - redundant on WASM. Change-Id: Ia8789ef783b06ce9cfba2ce9d67159db2355b594 Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
* Modernize the qtloaderMikolaj Boc2023-06-051-17/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* wasm: build with -no-feature-accessibilityMorten Sørvig2023-05-021-4/+8
| | | | | | | | | Add #ifdefs around the accessibility implementation. Fixes: QTBUG-111509 Pick-to: 6.5 Change-Id: I9a600781b4bf9545f046efa75f962cc40fe196a6 Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
* wasm: Don't grab menu bar item shortcuts on MacMikolaj Boc2023-02-081-4/+13
| | | | | | | | | | | | | | | | | | On Mac there's no concept of menu bar alt+key shortcuts. Therefore we cannot expect users on Mac, even when in a web application, to be familiar with those. Additionally, alt+key combinations yield special characters on Mac so that is the behavior we should support in WASM apps on Mac. To disable the menu bar item shortcuts, a new platform style hint UnderlineShortcut was created. Shortcut grabbing was disabled exactly the same as on regular Mac builds, i.e. through qt_set_sequence_auto_mnemonic. Task-number: QTBUG-76587 Change-Id: Ice6ed123c01e46b58d6d2c3e639813161b5a9a40 Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Transfer the key handling logic to QWasmWindowMikolaj Boc2023-02-071-3/+4
| | | | | | | | | | | | | Also, use the embind approach as the rest of the events do, and introduce a KeyEvent class which simplifies and streamlines event support. The event translator has been given a more specific function of just handling the dead keys. Rest of the translation functionality is coded directly in KeyEvent for more encapsulation. Change-Id: I11b0262fc42fe920206ecc6de0d434b9d9ab9998 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: set contenteditable on canvasMorten Sørvig2023-02-031-1/+0
| | | | | | | | | | | | | | | We don't want to make the top-level screen contenteditable, since that interferes with accessibility. Instead, make the canvas contenteditable and install clipboard event handlers there. Also move follow-up settings which counters some of the effects contenteditable (outline: none and inputmode: none), and move aria-hidden. Pick-to: 6.5 Change-Id: Ibe73d8d097acd948ba8920c781a2003db0a14f3d Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Quasi-support for offscreen surface on WASMMikolaj Boc2023-01-301-1/+1
| | | | | | | | | | | | | | | | | | Since context sharing is not currently supported with WebGL, offscreen contexts have a limited usability on Qt for WASM. If a context is shared, use the same underlaying WebGL context so that the two can actually share resources. This is not full-blown context sharing by any means but it makes e.g. the Open GL widget work as the readback texture for it is 'shared' between the virtual Qt contexts. If no sharing is desired, we use an OffscreenCanvas and actually create a separate WebGL context. Fixes: QTBUG-107558 Pick-to: 6.5 Change-Id: If57e44739ddb57c167d5f8881a74d8dee52531f6 Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
* Handle the drop event in the wasm window elementMikolaj Boc2023-01-201-6/+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-3/+8
| | | | | | | | | | | | | | | | | | 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>
* Add QString<->emscripten::val conversion functionsMikolaj Boc2023-01-131-3/+4
| | | | | | | | Following the QRect, add functions converting the QString to native emscripten::val and back: fromJsString, toJsString Change-Id: I2d0625ede3bbf7249e2e91b8de298b5b91df8ba2 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Remove the OpenGL compile guards around QWasmBackingStoreMikolaj Boc2022-11-301-7/+1
| | | | | | | | This is no longer needed as OpenGL is no longer necessary for the backing store on WASM. Change-Id: I3eaa8094558947da2d1cc5526533f9f3fc8afeab Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Fix typo in QWasmOffscre*e*nSurfaceMikolaj Boc2022-11-291-1/+1
| | | | | Change-Id: I34a84e11c7e2eb37e2f66d7c96fd1c2bdd77a351 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Use the browser compositor for drawing windows on WASMMikolaj Boc2022-11-261-37/+23
| | | | | | | | | | | | | | | | Make the browser compositor draw the window non-client area (using css + html). Get rid of OpenGL usage in non-OpenGL windows and use canvas 2d context instead to blit the texture (QImage). Also, as part of the change, remove the deprecated canvas element support in QScreen. Fixes: QTBUG-107116 Fixes: QTBUG-107219 Change-Id: I65f0d91831c806315685ca681ac0e416673f5cd5 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Aleksandr Reviakin <aleksandr.reviakin@qt.io> Reviewed-by: David Skoland <david.skoland@qt.io>
* wasm: unblock virtual keybaordLorn Potter2022-11-131-1/+1
| | | | | | | | | | | QtVirtualKeyboard can be used for non touch apps as well. We were not taking this into consideration and only allowing touch devices to access it. Pick-to: 6.4 Change-Id: I17fcb360b6655ace4fba7447eb85561ba75338a5 Reviewed-by: David Skoland <david.skoland@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Remove dead code & cull public API in WASM compositorMikolaj Boc2022-10-051-0/+1
| | | | | | | | | | | | | | - Remove the manual destroy methods - destructor should handle destruction - Remove the unused enum QWasmStateFlag - Make public API private where possible - Adjust handleTouch->processTouch to keep consistency with other process methods - Remove dead fields in compositor - Don't keep a dead screen entry in m_screens in qwasmintegration Change-Id: I98caf4dbdda5ebd25c4a9c22a40140c7ed1d7aa7 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Improve window dragging on WASMMikolaj Boc2022-07-251-16/+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-1/+12
| | | | | | | | | | | 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>
* wasm: Fix up namespacing in wasm platform pluginLorn Potter2022-06-181-1/+3
| | | | | | Pick-to: 6.4 Change-Id: I2fdbb6688b252743578dfcd58f9259eb5ac3cca8 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Fix typos in docs and commentsKai Köhne2022-06-151-1/+1
| | | | | | | | | Found by codespell Pick-to: 6.4 Change-Id: Ie3e301a23830c773a2e9aff487c702a223d246eb Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* 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: always call destroy() before deleting a screenMorten Sørvig2022-05-121-5/+3
| | | | | | | | | | | | | | | | | | | QWasmCompositor currently has the requirement that destroying it requires freeing a GL texture, which requires a valid GL context, which requires a valid screen, in order to get to the native context on the canvas. For this reason QWasmScreen has a destroy() function which is called before deleting the QScreen and QPlatformScreen. Make sure we call destroy() also when deleting all screens in the QWasmIntegration destructor. Move the common logic into a new deleteScreen() function which replaces destroy(). Change-Id: I628f13c868808db539effff9b29ecbefac23abc9 Reviewed-by: Aleksandr Reviakin <aleksandr.reviakin@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: David Skoland <david.skoland@qt.io>
* wasm: add support for drag into browser windowLorn Potter2022-05-101-1/+10
| | | | | | | | | 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>
* Plugins: use _L1 for for creating Latin-1 string literalsSona Kurazyan2022-05-041-2/+4
| | | | | | | | | As a drive-by, fix qsizetype -> int narrowing conversion warnings for the touched lines. Task-number: QTBUG-98434 Change-Id: I7fadd3cf27ad099028d70f05956303e3af62c0f5 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* wasm: rename “canvas” API to “container”Morten Johan Sørvig2022-04-011-25/+25
| | | | | | | | | | We now accept using div element as the root element for application content, instead of a canvas. Rename API and variables accordingly, where “container” covers both the div and canvas cases. Change-Id: Ibc2e096bcd5ca7e08609da348c53a404a4955c94 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* wasm: Support non-canvas container elementsMorten Johan Sørvig2022-03-311-12/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Support specifying that Qt should use a div element as the root container, in which case canvas management is moved to Qt C++ code. This enables us to take ownership of the canvas and its configuration. In addition, it allows creating child elements for the Qt container (canvas element children have a special role are as fallback elements displayed in case the browser can’t show the canvas) Remove support for reading Module.canvas, which was deprecated in Qt 5. Add support for reading Module.qtContainerElements, which can be either a canvas element (legacy) or a div element (preferred). Deprecate qtCanvasElements and print warning on usage. Change QWasmScreen to accept either a canvas or any html element. In the latter case, create the canvas and configure it as required by Qt. Change-Id: I57df8fb5772b2bfbba081af3f572b8b0e7d51897 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Compose render-to-texture widgets through QRhiLaszlo Agocs2022-03-111-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QPlatformTextureList holds a QRhiTexture instead of GLuint. A QPlatformBackingStore now optionally can own a QRhi and a QRhiSwapChain for the associated window. Non-GL rendering must use this QRhi everywhere, whereas GL (QOpenGLWidget) can choose to still rely on resource sharing between contexts. A widget tells that it wants QRhi and the desired configuration in a new virtual function in QWidgetPrivate returning a QPlatformBackingStoreRhiConfig. This is evaluated (among a top-level's all children) upon create() before creating the repaint manager and the QWidgetWindow. In QOpenGLWidget what do request is obvious: it will request an OpenGL-based QRhi. QQuickWidget (or a potential future QRhiWidget) will be more interesting: it needs to honor the standard Qt Quick env.vars. and QQuickWindow APIs (or, in whatever way the user configured the QRhiWidget), and so will set up the config struct accordingly. In addition, the rhiconfig and surface type is (re)evaluated when (re)parenting a widget to a new tlw. If needed, this will now trigger a destroy - create on the tlw. This should be be safe to do in setParent. When multiple child widgets report an enabled rhiconfig, the first one (the first child encountered) wins. So e.g. attempting to have a QOpenGLWidget and a Vulkan-based QQuickWidget in the same top-level window will fail one of the widgets (it likely won't render). RasterGLSurface is no longer used by widgets. Rather, the appropriate surface type is chosen. The rhi support in the backingstore is usable without widgets as well. To make rhiFlush() functional, one needs to call setRhiConfig() after creating the QBackingStore. (like QWidget does to top-level windows) Most of the QT_NO_OPENGL ifdefs are eliminated all over the place. Everything with QRhi is unconditional code at compile time, except the actual initialization. Having to plumb the widget tlw's shareContext (or, now, the QRhi) through QWindowPrivate is no longer needed. The old approach does not scale: to implement composeAndFlush (now rhiFlush) we need more than just a QRhi object, and this way we no longer pollute everything starting from the widget level (QWidget's topextra -> QWidgetWindow -> QWindowPrivate) just to send data around. The BackingStoreOpenGLSupport interface and the QtGui - QtOpenGL split is all gone. Instead, there is a QBackingStoreDefaultCompositor in QtGui which is what the default implementations of composeAndFlush and toTexture call. (overriding composeAndFlush and co. f.ex. in eglfs should continue working mostly as-is, apart from adapting to the texture list changes and getting the native OpenGL texture id out of the QRhiTexture) As QQuickWidget is way too complicated to just port as-is, an rhi manual test (rhiwidget) is introduced as a first step, in ordewr to exercise a simple, custom render-to-texture widget that does something using a (not necessarily OpenGL-backed) QRhi and acts as fully functional QWidget (modeled after QOpenGLWidget). This can also form the foundation of a potential future QRhiWidget. It is also possible to force the QRhi-based flushing always, regardless of the presence of render-to-texture widgets. To exercise this, set the env.var. QT_WIDGETS_RHI=1. This picks a platform-specific default, and can be overridden with QT_WIDGETS_RHI_BACKEND. (in sync with Qt Quick) This can eventually be extended to query the platform plugin as well to check if the platform plugin prefers to always do flushes with a 3D API. QOpenGLWidget should work like before from the user's perspective, while internally it has to do some things differently to play nice and prevent regressions with the new rendering architecture. To exercise this better, the qopenglwidget example gets a new tab-based view (that could perhaps replace the example's main window later on?). The openglwidget manual test is made compatible with Qt 6, and gets a counterpart in form of the dockedopenglwidget manual test, which is a modified version of the cube example that features dock widgets. This is relevant in particular because render-to-texture widgets within a QDockWidget has its own specific quirks, with logic taking this into account, hence testing is essential. For existing applications there are two important consequences with this patch in place: - Once the rhi-based composition is enabled, it stays active for the lifetime of the top-level window. - Dynamically creating and parenting the first render-to-texture widget to an already created tlw will destroy and recreate the tlw (and the underlying window). The visible effects of this depend on the platform. (e.g. the window may disappear and reappear on some, whereas with other windowing systems it is not noticeable at all - this is not really different from similar situtions with reparenting or when moving windows between screens, so should be acceptable in practice) - On iOS raster windows are flushed with Metal (and rhi) from now on (previously this was through OpenGL by making flush() call composeAndFlush(). Change-Id: Id05bd0f7a26fa845f8b7ad8eedda3b0e78ab7a4e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* wasm: fix native keyboard on iOSLorn Potter2022-03-051-0/+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-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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/+5
| | | | | | | | | | | | | | | | | | | | | 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>
* Make sure Qt::Popup is treated like a dialogDavid Skoland2021-10-181-2/+2
| | | | | | | | | | | According to the documentation, Qt::Popup should have a proper frame with a title bar. To honor this, two functions had to be slightly altered. Change-Id: I4bbc18e6b7fbec5702fad6e22ef2226c09dea15a Fixes: QTBUG-94768 Pick-to: 5.15 6.2 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: Fix source code comment typosJonas Kvinge2021-10-121-1/+1
| | | | | Change-Id: I9b2b76c01880c7bb515fdc1a6c4ef1f0bcf6be95 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: do not quit() on beforeunload()Morten Sørvig2021-06-231-14/+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>
* wasm: remove event listenersMorten Sørvig2021-06-221-1/+9
| | | | | | | | | | Remove event listeners on shutdown. For emscripten event callbacks this can be done by passing nullptr as the callback, for DOM event listeners use the “removeEventListener” API. Change-Id: I5a32a6a8feb906082db5ef3d0a0cd7ecb3b54292 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: factor visual viewport scale into dprMorten Johan Sørvig2020-08-051-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | By default, mobile browsers create a (layout) viewport much wider than the visual viewport in order to be compatible with web pages created with desktop browsers in mind. This means that the default view is zoomed out. This zoom is not reflected in window.devicePixelRatio, and Qt ends up setting the canvas render size to be larger than actually needed. The window.visualViewport.scale property reflects this “mobile” zoom level: add it as a devicePixelRatio factor. (The value will be less than 1 when zoomed out). User pinch-to-zoom may change the zoom level and resize the visual viewport; install a resize handler as well. For now we limit the devicePixelRatio value in order to avoid creating gigantic backing store images - this is something we can revisit later on. Pick-to: 5.15 Task-number: QTBUG-85662 Change-Id: I96db6121fe17a6c213216e04e4724efc93a9b66a Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Move the UNIX event dispatchers into QtGuiFriedemann Kleint2020-06-101-1/+1
| | | | | | Task-number: QTBUG-83255 Change-Id: I7d32eb1ec01784c9ed6bf5fc4913ffc5b3a34a49 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Move QPlatformBackingStoreOpenGLSupport handling out of platform pluginsTor Arne Vestbø2020-05-291-1/+0
| | | | | | | | Allows them to not depend on QtOpenGL just to provide the default backing store OpenGL support backend. Change-Id: I90d6d9247ce76848d9d03e2d512fb736c81488d3 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Move QtPlatformCompositorSupport into QtOpenGLTor Arne Vestbø2020-05-281-1/+1
| | | | | | Task-number: QTBUG-83255 Change-Id: Id9ea654db8efb00b487d53aea03d7f23a7ab1a54 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devLars Knoll2020-02-281-0/+5
|\ | | | | | | Change-Id: I469b0501cc65fc5ce4d797a69ae89405cc69c7f8
| * Merge remote-tracking branch 'origin/5.14' into 5.15Lars Knoll2020-02-271-0/+5
| |\ | | | | | | | | | Change-Id: I4212d070d5752275085e754b96f0392113604dba
| | * wasm: fix texture leak when window is destroyed in a different contextAlexandra Cherdantseva2020-02-271-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Specify event targets by CSS selectors; Support emsdk >= 1.39.5Morten Johan Sørvig2020-02-181-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR is now on by default, which means that functions like emscripten_set_keydown_callback() now expects CSS selectors (e.g. "#canvas_id" instead of "canvas_id"). In addition, Module.canvas is no more. Add a deprecation warning in case someone is setting it and expects Qt to use it. (qtloader.js sets qtCanvasElements instead). This bumps the minimum supported emsdk version to 1.39.5. Change-Id: I38abb2a191076ea04581c29552657ee3e0b87dbc Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* | | Merge remote-tracking branch 'origin/5.15' into devLiang Qi2020-02-131-31/+38
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/widgets/graphicsview/boxes/scene.h src/corelib/Qt5CoreMacros.cmake src/corelib/Qt6CoreMacros.cmake src/network/ssl/qsslsocket.cpp src/network/ssl/qsslsocket.h src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp src/testlib/CMakeLists.txt src/testlib/.prev_CMakeLists.txt tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp Disabled building manual tests with CMake for now, because qmake doesn't do it, and it confuses people. Done-With: Alexandru Croitor <alexandru.croitor@qt.io> Done-With: Volker Hilsheimer <volker.hilsheimer@qt.io> Change-Id: I865ae347bd01f4e59f16d007b66d175a52f1f152
| * | wasm: store and pass canvases as emscripten::valMorten Johan Sørvig2020-02-121-26/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>