diff options
author | Kari Oikarinen <kari.oikarinen@qt.io> | 2020-01-15 19:10:05 +0200 |
---|---|---|
committer | Kari Oikarinen <kari.oikarinen@qt.io> | 2020-01-15 19:10:05 +0200 |
commit | 7876f261b38361dddce2a7526f2504197f4f8b46 (patch) | |
tree | de874755c280ccce2885b1bc8eb8d182815be6ca /src | |
parent | 713fd41a54e2a4af1e386d4f68a93c12e6999a2b (diff) | |
parent | 7222c89c0a7816b82bae7933d2217088c87aa8bf (diff) |
Merge 5.14 into 5.14.1
Change-Id: Ibc671c7a5ac4b070f3406c41598d071fd978e420
Diffstat (limited to 'src')
-rw-r--r-- | src/core/render_widget_host_view_qt.cpp | 47 | ||||
-rw-r--r-- | src/process/process.pro | 2 |
2 files changed, 31 insertions, 18 deletions
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 0adf8091f..901cbf0bd 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -1575,7 +1575,12 @@ void RenderWidgetHostViewQt::handleTouchEvent(QTouchEvent *ev) eventTimestamp += m_eventsToNowDelta; QList<QTouchEvent::TouchPoint> touchPoints = mapTouchPointIds(ev->touchPoints()); - { + // Make sure that ACTION_POINTER_DOWN is delivered before ACTION_MOVE, + // and ACTION_MOVE before ACTION_POINTER_UP. + std::sort(touchPoints.begin(), touchPoints.end(), compareTouchPoints); + + // Check first if the touch event should be routed to the selectionController + if (!touchPoints.isEmpty()) { ui::MotionEvent::Action action; switch (touchPoints[0].state()) { case Qt::TouchPointPressed: @@ -1594,6 +1599,23 @@ void RenderWidgetHostViewQt::handleTouchEvent(QTouchEvent *ev) MotionEventQt motionEvent(touchPoints, eventTimestamp, action, ev->modifiers(), 0); if (m_touchSelectionController->WillHandleTouchEvent(motionEvent)) { + m_previousTouchPoints = touchPoints; + ev->accept(); + return; + } + } else { + // An empty touchPoints always corresponds to a TouchCancel event. + // We can't forward touch cancellations without a previously processed touch event, + // as Chromium expects the previous touchPoints for Action::CANCEL. + // If both are empty that means the TouchCancel was sent without an ongoing touch, + // so there's nothing to cancel anyway. + touchPoints = m_previousTouchPoints; + if (touchPoints.isEmpty()) + return; + + MotionEventQt cancelEvent(touchPoints, eventTimestamp, ui::MotionEvent::Action::CANCEL, ev->modifiers()); + if (m_touchSelectionController->WillHandleTouchEvent(cancelEvent)) { + m_previousTouchPoints.clear(); ev->accept(); return; } @@ -1610,21 +1632,13 @@ void RenderWidgetHostViewQt::handleTouchEvent(QTouchEvent *ev) break; case QEvent::TouchCancel: { - // Don't process a TouchCancel event if no motion was started beforehand, or if there are - // no touch points in the current event or in the previously processed event. - if (!m_touchMotionStarted || (touchPoints.isEmpty() && m_previousTouchPoints.isEmpty())) { - clearPreviousTouchMotionState(); - return; + // Only process TouchCancel events received following a TouchBegin or TouchUpdate event + if (m_touchMotionStarted) { + MotionEventQt cancelEvent(touchPoints, eventTimestamp, ui::MotionEvent::Action::CANCEL, ev->modifiers()); + processMotionEvent(cancelEvent); } - // Use last saved touch points for the cancel event, to get rid of a QList assert, - // because Chromium expects a MotionEvent::ACTION_CANCEL instance to contain at least - // one touch point, whereas a QTouchCancel may not contain any touch points at all. - if (touchPoints.isEmpty()) - touchPoints = m_previousTouchPoints; clearPreviousTouchMotionState(); - MotionEventQt cancelEvent(touchPoints, eventTimestamp, ui::MotionEvent::Action::CANCEL, ev->modifiers()); - processMotionEvent(cancelEvent); return; } case QEvent::TouchEnd: @@ -1648,11 +1662,6 @@ void RenderWidgetHostViewQt::handleTouchEvent(QTouchEvent *ev) #endif } - // Make sure that ACTION_POINTER_DOWN is delivered before ACTION_MOVE, - // and ACTION_MOVE before ACTION_POINTER_UP. - std::sort(touchPoints.begin(), touchPoints.end(), compareTouchPoints); - - m_previousTouchPoints = touchPoints; for (int i = 0; i < touchPoints.size(); ++i) { ui::MotionEvent::Action action; switch (touchPoints[i].state()) { @@ -1679,6 +1688,8 @@ void RenderWidgetHostViewQt::handleTouchEvent(QTouchEvent *ev) MotionEventQt motionEvent(touchPoints, eventTimestamp, action, ev->modifiers(), i); processMotionEvent(motionEvent); } + + m_previousTouchPoints = touchPoints; } #if QT_CONFIG(tabletevent) diff --git a/src/process/process.pro b/src/process/process.pro index ecde20d04..e861af182 100644 --- a/src/process/process.pro +++ b/src/process/process.pro @@ -9,6 +9,8 @@ INCLUDEPATH += ../core SOURCES = main.cpp +CONFIG -= ltcg + # On windows we need to statically link to the windows sandbox code win32 { # The Chromium headers we include are not clean |