summaryrefslogtreecommitdiffstats
path: root/src/core/web_contents_adapter.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-01-30 12:56:35 +0100
committerLiang Qi <liang.qi@qt.io>2017-01-30 12:56:36 +0100
commiteccf02a09ee5866fc971b5ff9f36aef5874bd25c (patch)
tree4b8c49abbd15c91ed483e44e6708eedb716c8202 /src/core/web_contents_adapter.cpp
parentebc88886041fb1f38c22e2ef33b17ca1baff7bc8 (diff)
parent35c38346e65fe26c75bbe08c7002f645ea53fec1 (diff)
Merge remote-tracking branch 'origin/5.8' into dev
Diffstat (limited to 'src/core/web_contents_adapter.cpp')
-rw-r--r--src/core/web_contents_adapter.cpp66
1 files changed, 50 insertions, 16 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 3763770d9..0355290d0 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -1153,6 +1153,18 @@ static QMimeData *mimeDataFromDropData(const content::DropData &dropData)
return mimeData;
}
+static blink::WebDragOperationsMask toWeb(const Qt::DropActions action)
+{
+ int result = blink::WebDragOperationNone;
+ if (action & Qt::CopyAction)
+ result |= blink::WebDragOperationCopy;
+ if (action & Qt::LinkAction)
+ result |= blink::WebDragOperationLink;
+ if (action & Qt::MoveAction)
+ result |= blink::WebDragOperationMove;
+ return static_cast<blink::WebDragOperationsMask>(result);
+}
+
void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropData &dropData,
Qt::DropActions allowedActions, const QPixmap &pixmap,
const QPoint &offset)
@@ -1192,25 +1204,17 @@ void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropD
if (dValid) {
if (d->webContents) {
content::RenderViewHost *rvh = d->webContents->GetRenderViewHost();
- if (rvh)
+ if (rvh) {
+ rvh->DragSourceEndedAt(d->lastDragClientPos.x(), d->lastDragClientPos.y(),
+ d->lastDragScreenPos.x(), d->lastDragScreenPos.y(),
+ d->currentDropAction);
rvh->DragSourceSystemDragEnded();
+ }
}
d->currentDropData.reset();
}
}
-static blink::WebDragOperationsMask toWeb(const Qt::DropActions action)
-{
- int result = blink::WebDragOperationNone;
- if (action & Qt::CopyAction)
- result |= blink::WebDragOperationCopy;
- if (action & Qt::LinkAction)
- result |= blink::WebDragOperationLink;
- if (action & Qt::MoveAction)
- result |= blink::WebDragOperationMove;
- return static_cast<blink::WebDragOperationsMask>(result);
-}
-
static void fillDropDataFromMimeData(content::DropData *dropData, const QMimeData *mimeData)
{
Q_ASSERT(dropData->filenames.empty());
@@ -1257,12 +1261,40 @@ Qt::DropAction toQt(blink::WebDragOperation op)
return Qt::IgnoreAction;
}
+static int toWeb(Qt::MouseButtons buttons)
+{
+ int result = 0;
+ if (buttons & Qt::LeftButton)
+ result |= blink::WebInputEvent::LeftButtonDown;
+ if (buttons & Qt::RightButton)
+ result |= blink::WebInputEvent::RightButtonDown;
+ if (buttons & Qt::MiddleButton)
+ result |= blink::WebInputEvent::MiddleButtonDown;
+ return result;
+}
+
+static int toWeb(Qt::KeyboardModifiers modifiers)
+{
+ int result = 0;
+ if (modifiers & Qt::ShiftModifier)
+ result |= blink::WebInputEvent::ShiftKey;
+ if (modifiers & Qt::ControlModifier)
+ result |= blink::WebInputEvent::ControlKey;
+ if (modifiers & Qt::AltModifier)
+ result |= blink::WebInputEvent::AltKey;
+ if (modifiers & Qt::MetaModifier)
+ result |= blink::WebInputEvent::MetaKey;
+ return result;
+}
+
Qt::DropAction WebContentsAdapter::updateDragPosition(QDragMoveEvent *e, const QPoint &screenPos)
{
Q_D(WebContentsAdapter);
content::RenderViewHost *rvh = d->webContents->GetRenderViewHost();
- rvh->DragTargetDragOver(toGfx(e->pos()), toGfx(screenPos), toWeb(e->possibleActions()),
- blink::WebInputEvent::LeftButtonDown);
+ d->lastDragClientPos = toGfx(e->pos());
+ d->lastDragScreenPos = toGfx(screenPos);
+ rvh->DragTargetDragOver(d->lastDragClientPos, d->lastDragScreenPos, toWeb(e->possibleActions()),
+ toWeb(e->mouseButtons()) | toWeb(e->keyboardModifiers()));
base::MessageLoop *currentMessageLoop = base::MessageLoop::current();
DCHECK(currentMessageLoop);
@@ -1309,7 +1341,9 @@ void WebContentsAdapter::endDragging(const QPoint &clientPos, const QPoint &scre
finishDragUpdate();
content::RenderViewHost *rvh = d->webContents->GetRenderViewHost();
rvh->FilterDropData(d->currentDropData.get());
- rvh->DragTargetDrop(*d->currentDropData, toGfx(clientPos), toGfx(screenPos), 0);
+ d->lastDragClientPos = toGfx(clientPos);
+ d->lastDragScreenPos = toGfx(screenPos);
+ rvh->DragTargetDrop(*d->currentDropData, d->lastDragClientPos, d->lastDragScreenPos, 0);
d->currentDropData.reset();
}