summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm/qwasmcompositor.cpp
Commit message (Collapse)AuthorAgeFilesLines
* wasm: drive animations using requestAnimationFrameMorten Sørvig3 days1-34/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Drive QAbstractAnimaton-based animations using RAF. This has two main benefits: * The animation update rate automatically adapts to the screen refresh rate * The animation update happens in sync with the draw callback, instead of as an extra wakeup in between frames. Add QWasmAnimationDriver, which replaces QDefaultAnimationDriver for Q_OS_WASM. Add QWasmAnimationFrameMultiHandler. This class supports multiplexing multiple animation and draw callbacks to a single native requestAnimation call. It also orders the callbacks such that animation callbacks are called before draw callbacks. Make QWindow::requestUpdate() use the new multi-handler (via QWasmCompositor, as before) Fixes: QTBUG-133695 Change-Id: I0a3fda562a7ba2e8d659d707335d1ce116f71bd9 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
* wasm: improve asyncify supportMorten Sørvig2025-03-031-13/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rewrite the event dispatcher to use QWasmSuspendResumeControl for asyncify suspend/resume. This includes using the following helper classes which provides additional functionality on top of QWasmSuspendResumeControl. - QWasmTimer: manages native timers on the main thread - QWasmEventHandler and qstdweb::EventCallback: input events - QWasmAnimationFrameHandler: animation frame events Initialization differs slightly, depending on if QtGui and the QPA machinery is in use, or of the app is a QtCore only application. In the former case, QWasmSuspendResumeControl is created early by QWasmIntegration in order to support registering event handlers at startup, before the event dispatcher has been created. processEvents() now actually processes native events. This is done by running a suspend-resume loop until the native event queue has been exhausted. If WaitForMoreEvents is specified then processEvents() will, in addition, also suspend and wait for additional native events. Timers on secondary threads are now managed by modifying the wait condition timeout, instead of proxying timers to the main thread. In effect secondary threads will now sleep until the next timer should fire, and then wake up and process that timer. Change-Id: I20e8afb6b67c64a7c52dbd89e9c50ffadba39594 Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
* wams: disable delayed onload/first frame featuresMorten Sørvig2024-09-021-1/+1
| | | | | | | | | | | | | requestUpdateHold was not getting enabled properly in some cases, in particular when using a custom html file to load the application. The assert on g_mainThreadEnvetDispatcher is also asserting, with a following dereference of a null pointer. Pick-to: 6.8 Change-Id: Ibf77d90b84f8319a894e2df34a134d2e4265fe05 Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
* wasm: fix compile error due to EM_BOOL type changeMorten Sørvig2024-08-151-2/+2
| | | | | | | | | | | | | emsdk 3.1.62 changes the EM_BOOL type from int to bool. We were using int in two places in the wasm platform plugin. Use EM_BOOL instead to stay compatible with emsdk editions earlier and and later than 3.1.62 Pick-to: 6.8 6.7 Change-Id: I837e76f869225859643dd5a98a28a1eefb5f14a4 Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
* wasm: Fix handling of native windowsEven Oscar Andersen2024-06-131-10/+21
| | | | | | | | | | | | | | | There are two problems 1) internal (not toplevel) windows needs to have the frameLess attribute set. Without this attribute the window is not visible 2) The backingstore needs to use the correct window, if not the symptoms are that the display is not always correctly updated. Seen in the qtdoc/examples/demos/documentviewer demo Fixes: QTBUG-125856 Change-Id: I040d963c0c130214cc70a607090faa006c02f981 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: send DPR change event on window updateMorten Sørvig2024-03-081-1/+6
| | | | | | | | | | | | | | | | | Qt Gui expects that the platform sends DPR update notifications if the DPR value has changed, before sending expose/paint events or delivering update request events. The most straightforward implementation is to send the DPR update event unconditionally and let Qt Gui determine if the DPR value has changed, especially if the native platform does not provide DPR change events. Pick-to: 6.6 6.7 Change-Id: Ica7a24a458b3b01f1c7b2e1e09d342114dc71331 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: Make sure we can add screen after releaseRequestUpdateHold has been calledEven Oscar Andersen2024-03-051-4/+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>
* wasm: fix onLoaded delay functionalityMorten Sørvig2024-02-081-0/+16
| | | | | | | | | | | | | | | | | | | | | | | 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>
* Support child windows on WASMMikolaj Boc2023-06-151-94/+14
| | | | | | | | | | | | | | Setting parents for WASM platform windows is now supported. This means that windows now reside in a hierarchical window tree, with the screen and individual windows being nodes (QWasmWindowTreeNode), each maintaining their own child window stack. The divs backing windows are properly reparented in response to Qt window parent changes, so that the html structure reflects what is happening in Qt. Change-Id: I55c91d90caf58714342dcd747043967ebfdf96bb Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: expose windows before delivering updatesMorten Sørvig2023-06-121-4/+9
| | | | | | | | | | | | | | | | | | | | | | | Don't show a blank frame on app startup. The wasm update request system supports two types of update requests: Expose and UpdateRequest. It can happen that both types of request are made for a single window, in which case the current code prefers UpdateRequest, since those must be delivered in order to keep QWindow in a consistent state. However, if the window is visible but not yet exposed then delivering the update request will not make the window paint anything, and we end up with a blank frame. Ideally this should be handled elsewhere and QWindow::requestUpdate() should not be called for non-exposed windows, but in the case does happen then sending an expose here allows us to recover. Pick-to: 6.5 6.6 Change-Id: Ib53050c33ad1769ea9b9ad678896af15f87a7ecb Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Replace a duplicate symbolAmir Masoud Abdol2023-04-131-5/+1
| | | | | | | | | | | Removed the two identical functions and directly call the `static_cast` in their place. This is to resolve a build issue when doing unity build. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: I174b601e06c4acdea45cc66495c09aafba6f48f6 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Remove unused code in qwasmcompositorMikolaj Boc2023-03-311-41/+2
| | | | | | | | Some dead code was left after transferring event support to QWasmWindow. Remove it now. Change-Id: I40e15bc62bcbb6fff071f53c45223c8a2d12e348 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Remove the redundant QWasmCompositor::requestUpdateAllWindowsMikolaj Boc2023-03-281-31/+11
| | | | | | | | | | | | | | | | Now that the browser compositor is used for rendering windows, the method has become redundant, as windows that got resized during screen resize will schedule their updates directly with the compositor. This also fixes an assertion in QPlatformWindow::hasPendingUpdateRequest as no windows without pending update requests will now have update requests delivered. Also offers a significant speedup with multiple restored window setups. Fixes: QTBUG-112289 Change-Id: Ie5dff69c04d66c4aef8351adef0da8530daf7ab8 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Support always on top/bottom window flags on WASMMikolaj Boc2023-02-221-14/+37
| | | | | | | | | | | | | | | | | | The window stack will now upkeep three groups of windows, always on bottom (1), regular (2), always on top (3). Windows belonging to (3) will always appear on top of (2) and (1), and windows from (2) will always appear on top of (1). The first window created in the application gets the (1) status, which is in line with the root window mechanism used before. Activation has now been decoupled from the top position on the window stack as a window in (1) or (2) may be active, in spite of the top window belonging to a higher group. Fixes: QTBUG-110098 Change-Id: I51f4d2d47163fab26ce5ef28f7a4f23a522c7f91 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Transfer touch event handling to QWasmWindowMikolaj Boc2023-02-141-115/+0
| | | | | | | Fixes: QTBUG-103498 Change-Id: Iec8b5cfba75131e7ddf855e6b729291950888fd3 Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: Aleksandr Reviakin <aleksandr.reviakin@qt.io>
* Use floating point coords for mouse/wheel events on wasmMikolaj Boc2023-02-141-4/+3
| | | | | | | | | | Fractional mouse movements may be reported on hi-dpi. Floating point event fields help us perform correct calculations in line with the web platform. Change-Id: Ic0c457db408c2bf28179ffcfdb032cde64ca8bbd Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: Aleksandr Reviakin <aleksandr.reviakin@qt.io>
* wasm: fix multitouch processingLorn Potter2023-02-091-18/+26
| | | | | | | | | | Not all touch points are changed as per emscripten event, so we do not need to remove or add them to the touch event Fixes: QTBUG-110941 Pick-to: 6.5 Change-Id: I4799ef0c05750a36361836698eb83e5bf844ece8 Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
* Transfer the key handling logic to QWasmWindowMikolaj Boc2023-02-071-45/+2
| | | | | | | | | | | | | 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>
* Handle the wheel event in the wasm windowMikolaj Boc2023-01-221-76/+0
| | | | | | | | | | | Align the wheel event handling with other events - move the handler to wasm window and create a C++ wrapper class for the js wheel event. Fixes: QTBUG-109622 Change-Id: I915e502de7c0784ec9a6745a90ddcda062e91b2b Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Handle the drop event in the wasm window elementMikolaj Boc2023-01-201-8/+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>
* Return to the two-step destruction in compositorMikolaj Boc2023-01-021-1/+5
| | | | | | | | | The two-step destruction we used to employ is needed as destroying a screen which contains a window crashes. Pick-to: 6.5 Change-Id: I722828be5408a7f079d66e845eeee34ed19cbf34 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Handle the mouse events in the window itselfMikolaj Boc2022-12-221-185/+6
| | | | | | | | | | | | | It is now not the screen that handles all of the events and relays them to individual windows, but the window elements themselves. This allows us to get rid of manual window targeting logic and let the browser do its job. Fixes: QTBUG-107217 Pick-to: 6.5 Change-Id: I4dc5a74b1343f027f72c1da4623b99cd28bfbb38 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Move the window through the title bar element itselfMikolaj Boc2022-12-211-87/+3
| | | | | | | | | | | | | | | | | The compositor is redundant in the process of moving the window. Have the title bar react to move all by itself. Additionally, a clearer structure in the window was introduced. The non-client area has been extracted into a separate class, as was the icon store and free DOM functions used across files. Since it was now easy, made the window maximize/restore on double click on the title element. Fixes: QTBUG-107626 Pick-to: 6.5 Change-Id: Iba7f207e46806ae7162656965892ae5a48ac5ebe Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Set WASM platform default to synchronous window event handlingDavid Skoland2022-12-201-6/+8
| | | | | | | | | | | | Based on existing code, it appears that it's always preferred in wasm to use synchronous delivery (<QWindowSystemInterface::SynchronousDelivery>), however, we can simply define this as the default mode of operation, which will make these unnecessary. Change-Id: Ia4c78593333e314f91efb266268917317794e2f5 Pick-to: 6.5 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Fix the coordinate problems in wasm windowsMikolaj Boc2022-12-071-10/+16
| | | | | | | | | | | | | | | | | | | | | | The QWasmScreen's top left coordinate does not precisely translate to correct page coordinates, especially when fixed position is used and page margins are set. Also, this is wrong in complicated setups with e.g. multiple nested elements. Therefore, to get the correct coordinates in pointer event handlers, we have to assume the local coordinates of the screen, and translate those to the (possibly incorrect) coordinates that QWasmScreen thinks it has in page. It is another problem to fix the wrong coordinates QWasmScreen thinks it has in the page. This has been checked with complicated setups with screens in scroll containers, screens with fixed position, screens with relative position, with and without body margins etc. Change-Id: I749f2507fec7ae278b6f9d7d13ae288e65472dba Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* WASM compositor, clear last mouse target if it is the removed windowMikolaj Boc2022-12-061-0/+2
| | | | | | | | m_lastMouseTargetWindow pointer may be kept even though the window has been removed. This leads to memory access problems. Change-Id: Ie83b607bf5a815540605671dd1d1ad37288074c5 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Resize wasm windows using a div outlineMikolaj Boc2022-12-051-124/+8
| | | | | | | | | | | | | Introducing a div outline which handles the resize events by itself. Manual computations in wasm compositor are no longer needed. The outline reacts to setting css variables (border-width, resize-outline-width), it sets the correct cursors using css and always keeps the correct size. Fixes: QTBUG-107498 Change-Id: I6b0564632af5e17e464fe93a3dfa20820c624292 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Don't tie compositor's enabled state to last added windowMikolaj Boc2022-11-301-5/+11
| | | | | | | | | | | | Currently, the compositor gets enabled/disabled based on the last constructed window's surface type. This causes non-OpenGL windows not to be displayed if any OpenGL window is created last. The compositor should scan for any non-openGL windows on any change to the window set to decide if it needs to be disabled or not. Change-Id: I037470e39a3fbae50fd3a4e29cb6615130d7b114 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Use the browser compositor for drawing windows on WASMMikolaj Boc2022-11-261-298/+99
| | | | | | | | | | | | | | | | 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>
* Null-check for window when handling pointer eventsMikolaj Boc2022-11-171-2/+3
| | | | | | | | There might not be a window at the pointer event position on a WASM screen, especially when the main window is not fullscreen. Change-Id: I29aac8c410fdf2bf97cd1ed12433d87e18b4a354 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Remove dead code & cull public API in WASM compositorMikolaj Boc2022-10-051-10/+2
| | | | | | | | | | | | | | - 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>
* Add missing GL includes in WASM compositorMikolaj Boc2022-09-271-0/+3
| | | | | | | IDEs (vscode) have problems with missing includes. Change-Id: I2618aaaf79c81a2c3566682e13caf31133ece631 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Redirect resize from QSizeGrip to system resize in wasm compositorMikolaj Boc2022-09-201-0/+38
| | | | | | | | | | | Using two different resizing techniques (one in QSizeGrip, one in QWasmCompositor) leads to strange behavior while resizing wasm windows. Redirect the QSizeGrip's resize to wasm's compositor resize (which might be considered system resize) to avoid that. Change-Id: Idfc062643caac3ceee879bfb875d943aade28378 Reviewed-by: David Skoland <david.skoland@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: capture pointer unconditionally on PointerDown eventAleksandr Reviakin2022-09-191-3/+4
| | | | | | | | | | | | The pointer events weren't captured previously if, for example, mouse was pressed inside the window and released outside of the window. Pick-to: 6.4 Fixes: QTBUG-71948 Change-Id: Ie50e5c132fa03046f0c5b321c35a58cb9f34b67a Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Make the clipboard paste from the outside work correctlyMikolaj Boc2022-09-181-4/+13
| | | | | | | | | | During the previous refactoring, two exceptions that triggered native copy/paste events were omitted. Fixes: QTBUG-106668 Pick-to: 6.4.0 6.4 Change-Id: Ie61dd6a0c1d9d2fdd47bd94be055d0221feae25b Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Propagate the copy event correctly to Qt widgets on WASMMikolaj Boc2022-09-091-7/+2
| | | | | | | | | | The event should be propagated when the native clipboard is available. A recent regression caused it to be suppressed, which resulted in lack of copy/paste capabilities. Pick-to: 6.4 6.4.0 Change-Id: I030a31aa0951c3813ce1d38da9a6526010b3bfc8 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Take into account that pointer event's location is already globalMikolaj Boc2022-09-081-28/+22
| | | | | | | | | Therefore, no translation to screen coords is needed. Task-number: QTBUG-106031 Pick-to: 6.4 Change-Id: I0dbbc5e4df79d85f9c6ef47f09ea54f19b67d2d7 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Implement mouse capture on WASMMikolaj Boc2022-08-271-5/+19
| | | | | | | | | | | This fixes dock widget undocking - previously, without the capture, any widget that the mouse accidentally entered would get the event, resulting in re-docking problems, cursor issues etc. Fixes: QTBUG-105621 Pick-to: 6.4 Change-Id: Ia1f2c91578018f2ae9df903bc0730200ede17d32 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Move titlebar drawing routines to QWasmWindowMikolaj Boc2022-08-251-232/+1
| | | | | | | | | | | The title bar drawing routines belong in QWasmWindow, not in the compositor. This provides better encapsulation as many properties don't have to be leaked from QWasmWindow. Extensibility will also improve. Change-Id: If73dd4e87602f62bff0de92e1405f89e7a9f3b43 Pick-to: 6.4 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Use the qt type Qt::Edges instead of wasm-specificMikolaj Boc2022-08-241-15/+20
| | | | | | | | The types essentially do the same job - the one that is more general should be used, the other - removed, as it is redundant. Change-Id: Iec09d3311681abce1405fcf8c2cebfb72f3fd51c Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Resolve window focusing problems on WASMMikolaj Boc2022-08-241-15/+5
| | | | | | | | | | | | - Moved the modal window resolution to QWasmWindow::requestActivateWindow so that multiple async activation events are not issued in unpredictable patterns. - Request activation on added windows and on stack top in case of window removal Pick-to: 6.4 Change-Id: I6f02cf1b7e83abb7961caf311ffc83e91c8bf810 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Remove the dead drawShadePanel in qwasmcompositorMikolaj Boc2022-08-231-72/+0
| | | | | | | | The method is not used anywhere. Remove it to save tens of LOCs. Change-Id: Id853d12d238aa30eb197ab3fed7ccc24a2213e31 Pick-to: 6.4 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Do not invalidate the entire window on window move on WASMMikolaj Boc2022-08-201-0/+2
| | | | | | | | | | The invalidate on window move is redundant - the previous texture can be reused for the window. Just request another refresh on the compositor and don't update the window texture. Makes window moves smoother. Pick-to: 6.4 Change-Id: Ied2922a000d3c8e6143e64d029154d74bc4f3480 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Avoid image format conversion when drawing window nonclient areaMikolaj Boc2022-08-201-4/+11
| | | | | | | | | | This radically speeds up window resizing and dragging. Fixes: QTBUG-105709 Pick-to: 6.4 Change-Id: I844601a5b139d21024db0c373482af18f350d0eb Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Maintain the window z-order properly in wasm compositorMikolaj Boc2022-08-161-64/+56
| | | | | | | | | | | | | The old stack structure used to keep track of windows has been improved to conform to the actual windowing assumptions: there shall be one root window, which is always at the bottom. The first created window immediately becomes the root window. Should the root window be removed, all windows are non-root, i.e. any of them can become the top-level window Fixes: QTBUG-105094 Pick-to: 6.4 Change-Id: Ic553244fa9f5bc3ee590b702935e66cfc62d5f8f Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Deliver correct key code on key release on WASMMikolaj Boc2022-08-101-51/+16
| | | | | | | | | | | Changed the behavior in which key events are delivered to targets. Before the change, in case of a EMSCRIPTEN_EVENT_KEYUP event, the key code and text were not filled in correctly as they should. This resulted in wrong behavior when event targets expected these codes being available. Fixes: QTBUG-105213 Change-Id: Ie66b5d6d395d08af655fcb00f1f616ad43d6bea4 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Refactor QWasmEventTranslator for added readabilityMikolaj Boc2022-08-101-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | Change listing: - change names of abbreviated structures/variables (e.g. KeyTbl -> WebToQtKeyCodeMappings) - add constants for commonly used magic strings ("Dead", StringTerminator) - use common idioms for common tasks (find_if, std::optional) - use binary search as facilitated by the sorted array instead of a full search - this optimizes the code at no cost - remove dead code (double translateEmscriptKey in QWasmEventTranslator::getKey, remove sticky dead key support as it was write-only, remove the dead setIsMac and g_usePlatformMacSpecifics, remove the dead getWindowAt). - cull the public interface on QWasmEventTranslator as some functions are only used internally (translateEmscriptKey) - simplify / shorten functions by short-circuiting - modernize definitions (= default) - auto-format the changes using clang-format The file is now much easier to read and understand. Change-Id: I5ea2bdafd9b9abc009feeb5516ddd87fb0ca212e Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Modernize QWasmCompositor::windowAtMikolaj Boc2022-07-281-15/+7
| | | | | | | | Use a well-known idiom for finding a matching window in the window stack (std::find_if) Change-Id: I677ef6ad8ee88bbd9eee1405be592ec2527ca3b9 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Remove QWasmCompositedWindow as dead codeMikolaj Boc2022-07-281-55/+17
| | | | | | | | | | | No fields in QWasmCompositedWindow, apart from visible, are used for any computation. They were write-only. Remove the class entirely and create a hash of visibility state instead. Fixes for z-order will follow. Change-Id: Icb7ff1865d1f9a67c0fde43cfa331ca1242ebcaa Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Deliver non-client area mouse events to WASM windowsMikolaj Boc2022-07-271-25/+42
| | | | | | | | | | QWasmCompositor now delivers non-client area mouse events to windows as it should, which fixes a lot of issues with window manipulation. One of such issues is re-docking of dock widgets. Fixes: QTBUG-105092 Change-Id: I9de45b7e1b1a80b64387031eb0cc0b31a4be2571 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>