From ff54ccc82fdba26cf16b9a64b387e3b428fb3038 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 Pick-to: 6.2 5.15 Change-Id: Ic8fe5bee933b5e0fbc8f5ba6234363a0a625648d Reviewed-by: Allan Sandfeld Jensen --- src/core/render_widget_host_view_qt_delegate_client.cpp | 3 ++- src/core/web_event_factory.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/core/render_widget_host_view_qt_delegate_client.cpp b/src/core/render_widget_host_view_qt_delegate_client.cpp index 01691fd8b..d28e789ee 100644 --- a/src/core/render_widget_host_view_qt_delegate_client.cpp +++ b/src/core/render_widget_host_view_qt_delegate_client.cpp @@ -717,7 +717,8 @@ void RenderWidgetHostViewQtDelegateClient::handleGestureEvent(QNativeGestureEven { const Qt::NativeGestureType type = event->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) { auto *hostDelegate = m_rwhv->host()->delegate(); if (hostDelegate && hostDelegate->GetInputEventRouter()) { auto webEvent = WebEventFactory::toWebGestureEvent(event); diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp index b82877bac..d7dceb30c 100644 --- a/src/core/web_event_factory.cpp +++ b/src/core/web_event_factory.cpp @@ -1542,7 +1542,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