summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-05-07 15:18:46 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-08 18:46:56 +0200
commit1ca3a574117bdd8e67381b178a823e7d695f4bfd (patch)
treea569ed9d732a88c16739d77938c4b32954f3cb54
parent9648528ad6fbd66eeaae3189173a7d7b47b935ce (diff)
Fix double clicks needing three presses in QWebEngineView
Since Qt 5.3 QWidget has the same behavior as Qt 4 where it will replace a second MouseButtonPress event with a MouseButtonDblClick instead of sending both. Fix the issue by moving the MouseButtonDblClick ignore code up to the QtQuick code, assume that upper layers will not send MouseButtonDblClick events, and re-replace the MouseButtonDblClick event with a MouseButtonPress in the QtWidgets code. Change-Id: I529dad2de538f486b00eb900ea6d2ed849a3b1f0 Reviewed-by: Andras Becsi <andras.becsi@digia.com>
-rw-r--r--src/core/render_widget_host_view_qt.cpp7
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quick.cpp5
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quick.h1
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp15
4 files changed, 15 insertions, 13 deletions
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index fa3fe231..f02729cd 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -694,7 +694,6 @@ void RenderWidgetHostViewQt::notifyResize()
bool RenderWidgetHostViewQt::forwardEvent(QEvent *event)
{
switch (event->type()) {
- case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonPress:
Focus(); // Fall through.
case QEvent::MouseButtonRelease:
@@ -869,12 +868,8 @@ bool RenderWidgetHostViewQt::IsPopup() const
void RenderWidgetHostViewQt::handleMouseEvent(QMouseEvent* event)
{
- int eventType = event->type();
- if (eventType == QEvent::MouseButtonDblClick)
- return;
-
blink::WebMouseEvent webEvent = WebEventFactory::toWebMouseEvent(event, dpiScale());
- if (eventType == QMouseEvent::MouseButtonPress) {
+ if (event->type() == QMouseEvent::MouseButtonPress) {
if (event->button() != m_clickHelper.lastPressButton
|| (event->timestamp() - m_clickHelper.lastPressTimestamp > static_cast<ulong>(qGuiApp->styleHints()->mouseDoubleClickInterval()))
|| (event->pos() - m_clickHelper.lastPressPosition).manhattanLength() > qGuiApp->styleHints()->startDragDistance())
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp
index 4dc9031a..8d7f298e 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp
+++ b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp
@@ -172,11 +172,6 @@ void RenderWidgetHostViewQtDelegateQuick::mouseReleaseEvent(QMouseEvent *event)
m_client->forwardEvent(event);
}
-void RenderWidgetHostViewQtDelegateQuick::mouseDoubleClickEvent(QMouseEvent *event)
-{
- m_client->forwardEvent(event);
-}
-
void RenderWidgetHostViewQtDelegateQuick::keyPressEvent(QKeyEvent *event)
{
m_client->forwardEvent(event);
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.h b/src/webengine/render_widget_host_view_qt_delegate_quick.h
index 71a2de01..2efb2d09 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quick.h
+++ b/src/webengine/render_widget_host_view_qt_delegate_quick.h
@@ -74,7 +74,6 @@ protected:
virtual void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
virtual void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
virtual void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- virtual void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
virtual void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
virtual void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
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 6c3f1cb1..46f531e5 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
@@ -178,7 +178,20 @@ void RenderWidgetHostViewQtDelegateWidget::resizeEvent(QResizeEvent *resizeEvent
bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event)
{
- if (!m_client->forwardEvent(event))
+ bool handled = false;
+ 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
+ // where we can simply ignore the DblClick event.
+ QMouseEvent *dblClick = static_cast<QMouseEvent *>(event);
+ QMouseEvent press(QEvent::MouseButtonPress, dblClick->localPos(), dblClick->windowPos(), dblClick->screenPos(),
+ dblClick->button(), dblClick->buttons(), dblClick->modifiers());
+ press.setTimestamp(dblClick->timestamp());
+ handled = m_client->forwardEvent(&press);
+ } else
+ handled = m_client->forwardEvent(event);
+
+ if (!handled)
return QOpenGLWidget::event(event);
return true;
}