aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickmousearea.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/items/qquickmousearea.cpp')
-rw-r--r--src/quick/items/qquickmousearea.cpp49
1 files changed, 19 insertions, 30 deletions
diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp
index e75a60181f..2fa52d9ed2 100644
--- a/src/quick/items/qquickmousearea.cpp
+++ b/src/quick/items/qquickmousearea.cpp
@@ -797,9 +797,6 @@ void QQuickMouseArea::mouseMoveEvent(QMouseEvent *event)
curLocalPos = event->windowPos();
}
- qreal dx = qAbs(curLocalPos.x() - startLocalPos.x());
- qreal dy = qAbs(curLocalPos.y() - startLocalPos.y());
-
if (keepMouseGrab() && d->stealMouse && !d->drag->active())
d->drag->setActive(true);
@@ -807,38 +804,30 @@ void QQuickMouseArea::mouseMoveEvent(QMouseEvent *event)
? d->drag->target()->parentItem()->mapFromScene(d->targetStartPos)
: d->targetStartPos;
- QPointF dragPos = d->drag->target()->position();
-
bool dragX = drag()->axis() & QQuickDrag::XAxis;
bool dragY = drag()->axis() & QQuickDrag::YAxis;
- if (dragX && d->drag->active()) {
- qreal x = (curLocalPos.x() - startLocalPos.x()) + startPos.x();
- if (x < drag()->xmin())
- x = drag()->xmin();
- else if (x > drag()->xmax())
- x = drag()->xmax();
- dragPos.setX(x);
+ QPointF dragPos = d->drag->target()->position();
+ if (dragX) {
+ dragPos.setX(qBound(
+ d->drag->xmin(),
+ startPos.x() + curLocalPos.x() - startLocalPos.x(),
+ d->drag->xmax()));
}
- if (dragY && d->drag->active()) {
- qreal y = (curLocalPos.y() - startLocalPos.y()) + startPos.y();
- if (y < drag()->ymin())
- y = drag()->ymin();
- else if (y > drag()->ymax())
- y = drag()->ymax();
- dragPos.setY(y);
+ if (dragY) {
+ dragPos.setY(qBound(
+ d->drag->ymin(),
+ startPos.y() + curLocalPos.y() - startLocalPos.y(),
+ d->drag->ymax()));
}
- d->drag->target()->setPosition(dragPos);
-
- if (!keepMouseGrab()) {
- bool xDragged = QQuickWindowPrivate::dragOverThreshold(dx, Qt::XAxis, event);
- bool yDragged = QQuickWindowPrivate::dragOverThreshold(dy, Qt::YAxis, event);
- if ((!dragY && !yDragged && dragX && xDragged)
- || (!dragX && !xDragged && dragY && yDragged)
- || (dragX && dragY && (xDragged || yDragged))) {
- setKeepMouseGrab(true);
- d->stealMouse = true;
- }
+ if (d->drag->active())
+ d->drag->target()->setPosition(dragPos);
+
+ if (!keepMouseGrab()
+ && (QQuickWindowPrivate::dragOverThreshold(dragPos.x() - startPos.x(), Qt::XAxis, event)
+ || QQuickWindowPrivate::dragOverThreshold(dragPos.y() - startPos.y(), Qt::YAxis, event))) {
+ setKeepMouseGrab(true);
+ d->stealMouse = true;
}
d->moved = true;