summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm/qwasmeventtranslator.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Revert "wasm: Specify event targets by CSS selectors; Support emsdk >= 1.39.5"v5.14.2Morten Johan Sørvig2020-03-271-12/+13
| | | | | | | | | | | This reverts commit c6da278271a2a3627b7a9933776cbdffc5bd2f23. This was a 5.15-only change which should not go into 5.14 since it raises the minimum supported emsdk version. Task-number: QTBUG-83098 Change-Id: I9e15952803f9dfff89b5b4e9caeff5c03dabca27 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: futureproof EmscriptenMouseEventLorn Potter2020-02-181-2/+2
| | | | | | | | | | Future versions of emscripten will remove the timestamp, so we need to replace this with the current timestamp See https://github.com/emscripten-core/emscripten/commit/a7f058a1e6e4b72b4446a3b36f8e96f9f8f41f2d#diff-9a5d68085dc7db2938b37a2b7b05c1f5 Change-Id: I8379d1adee1df1084461fddb1dd2e71684de9657 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-13/+12
| | | | | | | | | | | | | | | 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>
* wasm: fix redundant string conversions between wasm and JavaScriptAlexandra Cherdantseva2020-01-221-2/+4
| | | | | | | | | | | | | | | Avoid redundant conversions from UTF16 to UTF8 to UTF16 with help of new class QWasmString static methods: + QWasmString::fromQString to convert QString to js string using js Module.UTF16ToString + QWasmString::toQString to convert js string to QString using js Module.stringToUTF16 Fixed document.getElementById calls for cavasId with unicode characters. Change-Id: I3fc55bfeb6aeda75fa3acd85d22cea667b542f38 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: do not get canvas as property of js global objectAlexandra Cherdantseva2020-01-131-5/+7
| | | | | | | | | You cannot be sure that property with specified key in a global object is really a canvas. Should use `document.getElementById`. Change-Id: Ife55adaad5517aed64122b0c9bff32489cf19a2f Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-07-271-13/+13
|\ | | | | | | Change-Id: Ic6cfe08dbda1dc92b969e67063f805df63ba0fcf
| * wasm: fix international dead keysLorn Potter2019-07-231-13/+13
| | | | | | | | | | | | | | | | | | | | Emscripten has changed the key code to include the string 'Digit' on numerals. We use this to detect and translate any Dead keys that may be pressed. Fixes: QTBUG-77041 Change-Id: I054e98a6cf66390b1154f25fe385e5b12840851f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* | QWasmEventTranslator: return Key_unknown, not 0x00, when a key isn't foundMarc Mutz2019-07-171-1/+1
| | | | | | | | | | | | | | | | | | This matches what translateDeadKey() returns for unhandled keys, and processKeyboard() checks for when replacing qtKey with the result of translateDeadKey(). Change-Id: I1500576b7b31047a7a35633a15cd6975b77d842d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* | QWasmEventTranslator: replace five QHash with constexpr C arraysMarc Mutz2019-07-161-5/+59
|/ | | | | | | | | | | | | The mapping is static, but a dynamic (even mutable) container was used. Fix by using C tables and liner scan, which will be just as fast or faster than a hash lookup, for the maximum of six entries of each table. Change-Id: I899d5b1428dc82cf58862f238595a266aef8279f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: handle mouse events even when not over a windowLorn Potter2019-05-301-4/+7
| | | | | | | | | | | | | | | | | If the mouse button is held and mouse moves from over the window, that window would never register the button up event, and cause issue like being able to move a dialog around by simply moving the mouse around. Change-Id: I1363ac9c9f4113a79bf6863668ba74b90b1cea4a Fixes: QTBUG-75951 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: install one browser window resize handlerMorten Johan Sørvig2019-05-141-18/+0
| | | | | | | | | | 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: remove qDebugMorten Johan Sørvig2019-05-071-2/+0
| | | | | Change-Id: Ic9812421b2a79a33bb138f448fe132dab141b724 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: use requestActive instead of activateLorn Potter2019-05-021-5/+2
| | | | | | Task-number: QTBUG-74868 Change-Id: Ibbbac1ece66c8978440a282bf6949a82fb64d216 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: don't propagate touchLorn Potter2019-04-241-1/+1
| | | | | | Task-number: QTBUG-75263 Change-Id: I099f76114f876b3d6d81df3efb94db126db6a806 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: improve event coordinate handlingMorten Johan Sørvig2019-04-041-26/+32
| | | | | | | | | | | | | | | targetX and targetY are canvas-local coordinates, while Qt generally works with window-local and global coordinates. Add coordinate mapping calls where needed and make sure we pass correct coordinate types to Qt. This starts mattering when we have canvases which are not located at (0, 0). Change-Id: I28563310ca17d0cc5535317cff99fcd82d3723db Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: Use common “qt” prefix for exported functionsMorten Johan Sørvig2019-03-261-3/+3
| | | | | | | | Prevent namespace collisions and make sure Qt functions are grouped together. Change-Id: I217188ee93e4300e273d10a79d6014179fc5a1ef Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: fix touchpoint handlingLorn Potter2019-03-151-23/+46
| | | | | | | | | | | | emscripten sends a touchstart event for every touch point when a new touch point happens, so this makes them moved or stationary if already known. This allows QtQuick PinchArea to work. Task-number: QTBUG-72214 Change-Id: I8e7c0cd2d78b07cfeae21491846cc31092359050 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: support rendering to multiple canvasesMorten Johan Sørvig2019-03-081-15/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-18/+45
| | | | | | | | This allows for multi canvas use Task-number: QTBUG-64079 Change-Id: I69c998aa4c2869bb5b7f14ba65bb63284365ad70 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: improve clipboard fallback pathMorten Johan Sørvig2019-03-041-0/+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: fix clipboard useLorn Potter2019-02-271-7/+21
| | | | | | | Change 5242126a inadvertantly removed clipboard functionality Change-Id: Ie15e08470dd51d1c166063bbd443fd04416b2786 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: activateWindow when neededLorn Potter2019-02-271-1/+4
| | | | | | Task-number: QTBUG-74066 Change-Id: I6babab888de118c8c881fd8a18a90049563d7a23 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: improve key handlingLorn Potter2019-02-181-141/+403
| | | | | | | | | Allow for extended non English keys Task-number: QTBUG-68189 Task-number: QTBUG-69392 Change-Id: I12187ebc1250a5c29022cd2d3ad3a77eb45c06a8 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: add clipboard supportLorn Potter2019-02-151-3/+20
| | | | | | | | | | | | | | | | | | | 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>
* wasm: remove EM_ASM calls in wasm platform pluginLorn Potter2019-02-131-16/+17
| | | | | | Change-Id: I8453836b6730d18eaaa4ffe1fb9cb3933079ebee Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: send mouse release to proper windowLorn Potter2018-12-161-11/+16
| | | | | | | | | | | | | | | | | When the mouse is released, it gets the current window to send the event to from the pointer position. If the release happens out of the browser viewport, that window is null and the release event essentially gets ignored. This change keeps the last known QWindow object to send the event to until the release. Also replace hardcoded emscripten events with enum names. Task-number: QTBUG-71948 Change-Id: I354d14479a43489f210cca31d6b9e0f65d083bb0 Fixes: QTBUG-71948 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: use maintainTimers instead of processEvents for touch callbackLorn Potter2018-10-251-1/+1
| | | | | Change-Id: If39cdeedef60a47c0ba1afbab6adf1668bf5d0d6 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: fix wheel scroll logicLorn Potter2018-10-201-2/+5
| | | | | | | Task-number: QTBUG-71180 Fixes: QTBUG-71180 Change-Id: If442da096b847fdf69f3b24615e99c2ca988fb79 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: use config for natural scroll on safariLorn Potter2018-10-011-0/+29
| | | | | Change-Id: Idc2ee096144194e3f0d9ca165a578ff9745ef13d Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: make maximized and fullscreen windows not draggableLorn Potter2018-09-281-14/+18
| | | | | | | | Also make fullscreen windows not have a titlebar Task-number: QTBUG-69318 Change-Id: I017fc40fecb9f46d6540ffb72a71c9b62097a368 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* WebAssembly for QtBaseMorten Johan Sørvig2018-08-301-0/+522
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>