summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@theqtcompany.com>2015-12-21 17:08:57 +0100
committerAlexandru Croitor <alexandru.croitor@theqtcompany.com>2015-12-22 13:50:23 +0000
commit659490b7dd2c6092e85a1724a23ebb79f6e081d9 (patch)
treea753cbb3d59b91741ead3bb09f9e6f2f5df26de4 /src
parent7c5f2a9393a3fc77c0c5b2406332d57a37325183 (diff)
Fix MouseMove event handling when opening a new tab with middle click.
When opening a new tab by middle clicking on a link in a web page, two MouseMove events are sent to Chromium consecutively, without getting proper acknowledgment events, which causes further move events not to be handled properly. Fix consists in preventing the second move event from being sent. Change-Id: Ia0a64698476226e472faa53f75b51dfb6ed477c9 Task-number: QTBUG-50031 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/render_widget_host_view_qt.cpp4
-rw-r--r--src/core/web_contents_adapter_client.h1
-rw-r--r--src/webengine/api/qquickwebengineview.cpp5
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h1
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp22
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h2
6 files changed, 35 insertions, 0 deletions
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 7c5ed64e7..e4770cc72 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -747,6 +747,10 @@ bool RenderWidgetHostViewQt::forwardEvent(QEvent *event)
Focus(); // Fall through.
case QEvent::MouseButtonRelease:
case QEvent::MouseMove:
+ // Skip second MouseMove event when a window is being adopted, so that Chromium
+ // can properly handle further move events.
+ if (m_adapterClient->isBeingAdopted())
+ return false;
handleMouseEvent(static_cast<QMouseEvent*>(event));
break;
case QEvent::KeyPress:
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index 3ed3ab9ab..5d9e034c5 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -159,6 +159,7 @@ public:
virtual void focusContainer() = 0;
virtual void unhandledKeyEvent(QKeyEvent *event) = 0;
virtual void adoptNewWindow(WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect & initialGeometry) = 0;
+ virtual bool isBeingAdopted() = 0;
virtual void close() = 0;
virtual bool contextMenuRequested(const WebEngineContextMenuData&) = 0;
virtual void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) = 0;
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index c323f486b..bb66d3db4 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -421,6 +421,11 @@ void QQuickWebEngineViewPrivate::adoptNewWindow(WebContentsAdapter *newWebConten
Q_EMIT q->newViewRequested(&request);
}
+bool QQuickWebEngineViewPrivate::isBeingAdopted()
+{
+ return false;
+}
+
void QQuickWebEngineViewPrivate::close()
{
// Not implemented yet.
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index 60aa0d9f4..83a0ea744 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -141,6 +141,7 @@ public:
virtual void focusContainer() Q_DECL_OVERRIDE;
virtual void unhandledKeyEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
virtual void adoptNewWindow(QtWebEngineCore::WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &) Q_DECL_OVERRIDE;
+ virtual bool isBeingAdopted() Q_DECL_OVERRIDE;
virtual void close() Q_DECL_OVERRIDE;
virtual void requestFullScreen(bool) Q_DECL_OVERRIDE;
virtual bool isFullScreen() const Q_DECL_OVERRIDE;
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index bb8babd7a..61feec244 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -185,6 +185,7 @@ QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile)
, view(0)
, isLoading(false)
, scriptCollection(new QWebEngineScriptCollectionPrivate(browserContextAdapter()->userScriptController(), adapter.data()))
+ , m_isBeingAdopted(false)
{
memset(actions, 0, sizeof(actions));
}
@@ -298,7 +299,20 @@ void QWebEnginePagePrivate::adoptNewWindow(WebContentsAdapter *newWebContents, W
{
Q_Q(QWebEnginePage);
Q_UNUSED(userGesture);
+
QWebEnginePage *newPage = q->createWindow(toWindowType(disposition));
+
+ // Mark the new page as being in the process of being adopted, so that a second mouse move event
+ // sent by newWebContents->initialize() gets filtered in RenderWidgetHostViewQt::forwardEvent.
+ // The first mouse move event is being sent by q->createWindow(). This is necessary because
+ // Chromium does not get a mouse move acknowledgment message between the two events, and
+ // InputRouterImpl::ProcessMouseAck is not executed, thus all subsequent mouse move events
+ // get coalesced together, and don't get processed at all.
+ // The mouse move events are actually sent as a result of show() being called on
+ // RenderWidgetHostViewQtDelegateWidget, both when creating the window and when initialize is
+ // called.
+ newPage->d_func()->m_isBeingAdopted = true;
+
// Overwrite the new page's WebContents with ours.
if (newPage && newPage->d_func() != this) {
newPage->d_func()->adapter = newWebContents;
@@ -306,6 +320,14 @@ void QWebEnginePagePrivate::adoptNewWindow(WebContentsAdapter *newWebContents, W
if (!initialGeometry.isEmpty())
emit newPage->geometryChangeRequested(initialGeometry);
}
+
+ // Page has finished the adoption process.
+ newPage->d_func()->m_isBeingAdopted = false;
+}
+
+bool QWebEnginePagePrivate::isBeingAdopted()
+{
+ return m_isBeingAdopted;
}
void QWebEnginePagePrivate::close()
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index 0fcd05d3c..55c722f4c 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -136,6 +136,7 @@ public:
virtual void focusContainer() Q_DECL_OVERRIDE;
virtual void unhandledKeyEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
virtual void adoptNewWindow(QtWebEngineCore::WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &initialGeometry) Q_DECL_OVERRIDE;
+ virtual bool isBeingAdopted() Q_DECL_OVERRIDE;
virtual void close() Q_DECL_OVERRIDE;
virtual bool contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &data) Q_DECL_OVERRIDE;
virtual void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) Q_DECL_OVERRIDE;
@@ -181,6 +182,7 @@ public:
QtWebEngineCore::WebEngineContextMenuData m_menuData;
bool isLoading;
QWebEngineScriptCollection scriptCollection;
+ bool m_isBeingAdopted;
mutable CallbackDirectory m_callbacks;
mutable QAction *actions[QWebEnginePage::WebActionCount];