Commit f17fb1bd authored by Tasos Sahanidis's avatar Tasos Sahanidis Committed by Nate Graham
Browse files

Prevent drag & drop if left mouse button isn't pressed

Summary:
It is possible to begin a drag & drop sequence using the forward/backward mouse buttons while moving the cursor.
For example:

> QGraphicsSceneMouseEvent(GraphicsSceneMouseMove, buttons=ForwardButton|XButton2|ExtraButton2, pos=347,127, scenePos=347,127, screenPos=398,255)

This patch only allows drag & drop if the left mouse button is pressed.
Touch events should not be affected as they are handled separately.

Reviewers: ngraham

Reviewed By: ngraham

Subscribers: ngraham

Tags: #gwenview

Differential Revision: https://phabricator.kde.org/D26507
parent 04a77653
......@@ -1033,6 +1033,11 @@ bool DocumentView::sceneEventFilter(QGraphicsItem*, QEvent* event)
if (mouseEvent->source() == Qt::MouseEventSynthesizedByQt) {
return true;
}
// We need to check if the Left mouse button is pressed, otherwise this can lead
// to starting a drag & drop sequence using the Forward/Backward mouse buttons
if (!mouseEvent->buttons().testFlag(Qt::LeftButton)) {
return false;
}
const qreal dragDistance = (mouseEvent->pos() - d->mDragStartPosition).manhattanLength();
const qreal minDistanceToStartDrag = QGuiApplication::styleHints()->startDragDistance();
if (!d->canPan() && dragDistance >= minDistanceToStartDrag) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment