From 400355fa5170244ceea571f50ec61b29426ebd0a Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Thu, 5 May 2022 13:52:32 +0200 Subject: Fix touch input for widget's delegate for html popup Earlier fix cf8bc1899a introduced the logic, where all system synthesized mouse events are ignored. But after c56169f7a1 this is undesired since for widget with Qt::Popup flag touch input is ignored by QWidgetWindow, and input is expected to be delivered to popup as synthesized mouse event (either synthesized by Qt or for capabable devices by system). So allow system synthesized mouse events to let through for popup. Synthesis by Qt is suppress automatically for accepted touch event, it's only system event are still delivered unconditionally, so still ignore them for widgets impl. Global ignore in core is not needed, since QQuickWidget ignores system synthesized events unconditionally. Fixes: QTBUG-79254 Change-Id: Ie8f55eb8b9c2677d8a98381effb3cb31d9388ac7 Reviewed-by: Qt CI Bot Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Martin Negyokru (cherry picked from commit 1f6495af6331f5504de9d3f7e43f5202345c7a8c) Reviewed-by: Michal Klocek --- src/core/render_widget_host_view_qt.cpp | 6 ------ .../render_widget_host_view_qt_delegate_widget.cpp | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index b6cac85ce..7acef2b15 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -1378,12 +1378,6 @@ void RenderWidgetHostViewQt::handleMouseEvent(QMouseEvent* event) if (event->type() == QEvent::MouseButtonRelease) m_mouseButtonPressed--; - // Don't forward mouse events synthesized by the system, which are caused by genuine touch - // events. Chromium would then process for e.g. a mouse click handler twice, once due to the - // system synthesized mouse event, and another time due to a touch-to-gesture-to-mouse - // transformation done by Chromium. - if (event->source() == Qt::MouseEventSynthesizedBySystem) - return; handlePointerEvent(event); } diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp index 5124eabed..354c6df9f 100644 --- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp +++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp @@ -448,6 +448,26 @@ bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event) break; } + switch (event->type()) { + case QEvent::MouseButtonPress: + case QEvent::MouseButtonRelease: + case QEvent::MouseButtonDblClick: + case QEvent::MouseMove: + // Don't forward mouse events synthesized by the system, which are caused by genuine touch + // events. Chromium would then process for e.g. a mouse click handler twice, once due to the + // system synthesized mouse event, and another time due to a touch-to-gesture-to-mouse + // transformation done by Chromium. + // Only allow them for popup type, since QWidgetWindow will ignore them for Qt::Popup flag, + // which is expected to get input through synthesized mouse events (either by system or Qt) + if (!m_isPopup && static_cast(event)->source() == Qt::MouseEventSynthesizedBySystem) { + Q_ASSERT(!windowFlags().testFlag(Qt::Popup)); + return true; + } + break; + default: + break; + } + if (event->type() == QEvent::MouseButtonDblClick) { // QWidget keeps the Qt4 behavior where the DblClick event would replace the Press event. // QtQuick is different by sending both the Press and DblClick events for the second press -- cgit v1.2.1