From 03b3df668088d0750af6a59410ee4d0d00ba88ae Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Wed, 6 Oct 2021 09:38:04 +0200 Subject: Fix pinch gesture Pinch gesture on a touchpad is expected to zoom-in and zoom-out. It has been broken since the pinch gestures are routed because for routing the event target has to be found. The event target is only tried to be found on a pinch begin gesture. As a fix, handle Qt::BeginNativeGesture and Qt::EndNativeGesture events too. Fixes: QTBUG-96930 Change-Id: Ic8fe5bee933b5e0fbc8f5ba6234363a0a625648d Reviewed-by: Allan Sandfeld Jensen (cherry picked from commit ff54ccc82fdba26cf16b9a64b387e3b428fb3038) --- src/core/render_widget_host_view_qt.cpp | 3 ++- src/core/web_event_factory.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index bee3c4ca4..b6cac85ce 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -1662,7 +1662,8 @@ void RenderWidgetHostViewQt::handleGestureEvent(QNativeGestureEvent *ev) { const Qt::NativeGestureType type = ev->gestureType(); // These are the only supported gestures by Chromium so far. - if (type == Qt::ZoomNativeGesture || type == Qt::SmartZoomNativeGesture) { + if (type == Qt::ZoomNativeGesture || type == Qt::SmartZoomNativeGesture + || type == Qt::BeginNativeGesture || type == Qt::EndNativeGesture) { if (host()->delegate() && host()->delegate()->GetInputEventRouter()) { auto webEvent = WebEventFactory::toWebGestureEvent(ev); host()->delegate()->GetInputEventRouter()->RouteGestureEvent(this, &webEvent, ui::LatencyInfo()); diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp index dcfa3dc39..b6ca70294 100644 --- a/src/core/web_event_factory.cpp +++ b/src/core/web_event_factory.cpp @@ -1540,7 +1540,13 @@ WebGestureEvent WebEventFactory::toWebGestureEvent(QNativeGestureEvent *ev) webKitEvent.data.tap.tap_count = 1; break; case Qt::BeginNativeGesture: + webKitEvent.SetType(WebInputEvent::Type::kGesturePinchBegin); + webKitEvent.SetNeedsWheelEvent(true); + break; case Qt::EndNativeGesture: + webKitEvent.SetType(WebInputEvent::Type::kGesturePinchEnd); + webKitEvent.SetNeedsWheelEvent(true); + break; case Qt::RotateNativeGesture: case Qt::PanNativeGesture: case Qt::SwipeNativeGesture: -- cgit v1.2.3