summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm/qwasmeventtranslator.cpp
diff options
context:
space:
mode:
authorMikolaj Boc <mikolaj.boc@qt.io>2022-07-14 15:56:38 +0200
committerMikolaj Boc <mikolaj.boc@qt.io>2022-07-15 20:57:01 +0200
commitec58600cc923d6b7de5266e20e27d377fcc1540a (patch)
tree4d4789dfd495f8ed88b0f5b021a96761d6b49ac3 /src/plugins/platforms/wasm/qwasmeventtranslator.cpp
parentbabb4ec4a69b64bdf89823058daae0dd64cca0f0 (diff)
Refactor code focused around QWasmCompositor::processMouse
Refactoring of the logic around QWasmCompositor::processMouse has been performed for readability and easier modification, in preparation for further fixes for event delivery and handling in windows. There should be no logic changes, just cleaner code. Change groups: Members of QWasmCompositor have been prefixed by m_ for easier discerning of stateful and stateless variables in functions. Variables renamed to more descriptive, e.g. window2->targetWindow, globalPoint->targetPointInScreenCoords. Magic numbers eliminated, e.g. mouseEvent->button == 0 is now button == Qt::MouseButton::LeftButton. Some common condition checks have been wrapped into single constants, e.g. !(htmlWindow->m_windowState & Qt::WindowFullScreen) && !(htmlWindow->m_windowState & Qt::WindowMaximized) == isTargetWindowResizable Some nested if-conditions were collapsed. Some unnecessary checks have been moved to outer if conditions (e.g. for draggedWindow in EMSCRIPTEN_EVENT_MOUSEMOVE, since the code would crash anyway because only some parts are guarded against it being nullptr). Consts introduced so that variables are only used for one purpose. Made QWasmEventTranslator::translateMouseButton constexpr Made QWasmWindow::isPointOnTitle behave correctly when the window has no title bar so that no flag probing is needed prior to calling it. Made QWasmCursor::setOverrideWasmCursor accept a const ref - having it accept pointer suggested it might dangle. Change-Id: I8910622fddad764ee86eb0260b5ad23c7ee7f97a Reviewed-by: David Skoland <david.skoland@qt.io>
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmeventtranslator.cpp')
-rw-r--r--src/plugins/platforms/wasm/qwasmeventtranslator.cpp12
1 files changed, 0 insertions, 12 deletions
diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp
index 8f9050ba5d..6f13009aef 100644
--- a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp
+++ b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp
@@ -238,18 +238,6 @@ Qt::Key QWasmEventTranslator::translateEmscriptKey(const EmscriptenKeyboardEvent
return qtKey;
}
-Qt::MouseButton QWasmEventTranslator::translateMouseButton(unsigned short button)
-{
- if (button == 0)
- return Qt::LeftButton;
- else if (button == 1)
- return Qt::MiddleButton;
- else if (button == 2)
- return Qt::RightButton;
-
- return Qt::NoButton;
-}
-
struct KeyMapping { Qt::Key from, to; };
constexpr KeyMapping tildeKeyTable[] = { // ~