{
if (event->type() == QEvent::TouchCancel) {
touchMouseId = -1;
- if (!mouseGrabberItem)
- return;
- mouseGrabberItem->ungrabMouse();
- mouseGrabberItem = 0;
+ if (mouseGrabberItem)
+ mouseGrabberItem->ungrabMouse();
return;
}
for (int i = 0; i < event->touchPoints().count(); ++i) {
me.setTimestamp(event->timestamp());
me.setCapabilities(event->device()->capabilities());
deliverMouseEvent(&me);
- mouseGrabberItem = 0;
+ if (mouseGrabberItem)
+ mouseGrabberItem->ungrabMouse();
}
break;
}
QMouseEvent me(event->type(), p, event->windowPos(), event->screenPos(),
event->button(), event->buttons(), event->modifiers());
me.accept();
- mouseGrabberItem = item;
+ item->grabMouse();
q->sendEvent(item, &me);
event->setAccepted(me.isAccepted());
if (me.isAccepted())
return true;
- mouseGrabberItem->ungrabMouse();
- mouseGrabberItem = 0;
+ if (mouseGrabberItem)
+ mouseGrabberItem->ungrabMouse();
}
}
}
d->deliverMouseEvent(event);
- d->mouseGrabberItem = 0;
+ if (d->mouseGrabberItem)
+ d->mouseGrabberItem->ungrabMouse();
}
/*! \reimp */
QQuickItemPrivate::get(item)->deliverMouseEvent(static_cast<QMouseEvent *>(e));
}
break;
+ case QEvent::UngrabMouse:
+ if (!d->sendFilteredMouseEvent(item->parentItem(), item, e)) {
+ e->accept();
+ item->mouseUngrabEvent();
+ }
+ break;
case QEvent::Wheel:
QQuickItemPrivate::get(item)->deliverWheelEvent(static_cast<QWheelEvent *>(e));
break;
// RetainGrabVelocity is the maxmimum instantaneous velocity that
// will ensure the Flickable retains the grab on consecutive flicks.
-static const int RetainGrabVelocity = 15;
+static const int RetainGrabVelocity = 100;
QQuickFlickableVisibleArea::QQuickFlickableVisibleArea(QQuickFlickable *parent)
: QObject(parent), flickable(parent), m_xPosition(0.), m_widthRatio(0.)
Q_Q(QQuickFlickable);
QQuickItemPrivate::start(timer);
if (interactive && timeline.isActive()
- && (qAbs(hData.smoothVelocity.value()) > RetainGrabVelocity
- || qAbs(vData.smoothVelocity.value()) > RetainGrabVelocity)) {
+ && ((qAbs(hData.smoothVelocity.value()) > RetainGrabVelocity && !hData.fixingUp && !hData.inOvershoot)
+ || (qAbs(vData.smoothVelocity.value()) > RetainGrabVelocity && !vData.fixingUp && !vData.inOvershoot))) {
stealMouse = true; // If we've been flicked then steal the click.
int flickTime = timeline.time();
if (flickTime > 600) {
}
q->setKeepMouseGrab(stealMouse);
pressed = true;
- timeline.clear();
+ if (!hData.fixingUp)
+ timeline.reset(hData.move);
+ if (!vData.fixingUp)
+ timeline.reset(vData.move);
hData.reset();
vData.reset();
hData.dragMinBound = q->minXExtent();
}
}
if (!rejectY && stealMouse && dy != 0.0) {
+ timeline.clear();
vData.move.setValue(newY);
vMoved = true;
}
}
}
if (!rejectX && stealMouse && dx != 0.0) {
+ timeline.clear();
hData.move.setValue(newX);
hMoved = true;
}
if (d->pressed) {
// if our mouse grab has been removed (probably by another Flickable),
// fix our state
+ d->clearDelayedPress();
d->pressed = false;
d->draggingEnding();
d->stealMouse = false;
case QEvent::MouseMove:
case QEvent::MouseButtonRelease:
return sendMouseEvent(static_cast<QMouseEvent *>(e));
+ case QEvent::UngrabMouse:
+ if (d->canvas && d->canvas->mouseGrabberItem() && d->canvas->mouseGrabberItem() != this) {
+ // The grab has been taken away from a child and given to some other item.
+ mouseUngrabEvent();
+ }
+ break;
default:
break;
}
QQuickItem *oldGrabber = canvasPriv->mouseGrabberItem;
canvasPriv->mouseGrabberItem = this;
- if (oldGrabber)
- oldGrabber->mouseUngrabEvent();
+ if (oldGrabber) {
+ QEvent ev(QEvent::UngrabMouse);
+ d->canvas->sendEvent(oldGrabber, &ev);
+ }
}
void QQuickItem::ungrabMouse()
}
canvasPriv->mouseGrabberItem = 0;
- mouseUngrabEvent();
+
+ QEvent ev(QEvent::UngrabMouse);
+ d->canvas->sendEvent(this, &ev);
}
bool QQuickItem::keepMouseGrab() const
return;
}
- if (tl.isActive() && flicking)
+
+ if (tl.isActive() && flicking && flickDuration && qreal(tl.time())/flickDuration < 0.8)
stealMouse = true; // If we've been flicked then steal the click.
else
stealMouse = false;
} else {
dist = qMin(qreal(modelCount-1), qreal(v2 / (accel * 2.0)));
}
+ flickDuration = static_cast<int>(1000 * qAbs(velocity) / accel);
offsetAdj = 0.0;
moveOffset.setValue(offset);
tl.accel(moveOffset, velocity, accel, dist);
, autoHighlight(true), highlightUp(false), layoutScheduled(false)
, moving(false), flicking(false), requestedOnPath(false), inRequest(false)
, dragMargin(0), deceleration(100)
- , moveOffset(this, &QQuickPathViewPrivate::setAdjustedOffset)
+ , moveOffset(this, &QQuickPathViewPrivate::setAdjustedOffset), flickDuration(0)
, firstIndex(-1), pathItems(-1), requestedIndex(-1), requestedZ(0)
, moveReason(Other), moveDirection(Shortest), attType(0), highlightComponent(0), highlightItem(0)
, moveHighlight(this, &QQuickPathViewPrivate::setHighlightPosition)
qreal deceleration;
QQuickTimeLine tl;
QQuickTimeLineValueProxy<QQuickPathViewPrivate> moveOffset;
+ int flickDuration;
int firstIndex;
int pathItems;
int requestedIndex;