summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/web_contents_adapter.cpp25
-rw-r--r--src/core/web_contents_adapter.h1
-rw-r--r--src/core/web_contents_adapter_p.h3
3 files changed, 29 insertions, 0 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 657a2eed3..ae13e226d 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -78,6 +78,7 @@
#include <QGuiApplication>
#include <QStringList>
#include <QStyleHints>
+#include <QTimer>
#include <QVariant>
#include <QtCore/qmimedata.h>
#include <QtGui/qaccessible.h>
@@ -322,6 +323,7 @@ WebContentsAdapterPrivate::WebContentsAdapterPrivate()
, currentDropData(nullptr)
, currentDropAction(Qt::IgnoreAction)
, inDragUpdateLoop(false)
+ , updateDragCursorMessagePollingTimer(new QTimer)
{
}
@@ -364,6 +366,7 @@ WebContentsAdapter::WebContentsAdapter(content::WebContents *webContents)
{
Q_D(WebContentsAdapter);
d->webContents.reset(webContents);
+ initUpdateDragCursorMessagePollingTimer();
}
WebContentsAdapter::~WebContentsAdapter()
@@ -1097,7 +1100,10 @@ Qt::DropAction WebContentsAdapter::updateDragPosition(QDragMoveEvent *e, const Q
base::RunLoop loop;
d->inDragUpdateLoop = true;
d->dragUpdateLoopQuitClosure = loop.QuitClosure();
+
+ d->updateDragCursorMessagePollingTimer->start();
loop.Run();
+ d->updateDragCursorMessagePollingTimer->stop();
return d->currentDropAction;
}
@@ -1134,6 +1140,25 @@ void WebContentsAdapter::leaveDrag()
rvh->DragTargetDragLeave();
}
+void WebContentsAdapter::initUpdateDragCursorMessagePollingTimer()
+{
+ Q_D(WebContentsAdapter);
+ // Poll for drag cursor updated message 60 times per second. In practice, the timer is fired
+ // at most twice, after which it is stopped.
+ d->updateDragCursorMessagePollingTimer->setInterval(16);
+ d->updateDragCursorMessagePollingTimer->setSingleShot(false);
+
+ QObject::connect(d->updateDragCursorMessagePollingTimer.data(), &QTimer::timeout, [](){
+ base::MessagePump::Delegate *delegate = base::MessageLoop::current();
+ DCHECK(delegate);
+
+ // Execute Chromium tasks if there are any present. Specifically we are interested to handle
+ // the RenderViewHostImpl::OnUpdateDragCursor message, that gets sent from the render
+ // process.
+ while (delegate->DoWork()) {}
+ });
+}
+
WebContentsAdapterClient::RenderProcessTerminationStatus
WebContentsAdapterClient::renderProcessExitStatus(int terminationStatus) {
auto status = WebContentsAdapterClient::RenderProcessTerminationStatus(-1);
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index ddb313c32..a985e49a0 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -163,6 +163,7 @@ public:
void finishDragUpdate();
void endDragging(const QPoint &clientPos, const QPoint &screenPos);
void leaveDrag();
+ void initUpdateDragCursorMessagePollingTimer();
// meant to be used within WebEngineCore only
content::WebContents *webContents() const;
diff --git a/src/core/web_contents_adapter_p.h b/src/core/web_contents_adapter_p.h
index 709cb8c2a..0170f20e2 100644
--- a/src/core/web_contents_adapter_p.h
+++ b/src/core/web_contents_adapter_p.h
@@ -55,7 +55,9 @@
#include "base/memory/scoped_ptr.h"
#include <QExplicitlySharedDataPointer>
+#include <QScopedPointer>
+QT_FORWARD_DECLARE_CLASS(QTimer)
QT_FORWARD_DECLARE_CLASS(QWebChannel)
class WebEngineContext;
@@ -93,6 +95,7 @@ public:
Qt::DropAction currentDropAction;
bool inDragUpdateLoop;
base::Closure dragUpdateLoopQuitClosure;
+ QScopedPointer<QTimer> updateDragCursorMessagePollingTimer;
};
} // namespace QtWebEngineCore