6#include <QtQuick/private/qquickitem_p.h>
7#include <QtQuick/private/qquickhandlerpoint_p.h>
8#include <QtQuick/private/qquickdeliveryagent_p_p.h>
9#include <QtGui/private/qinputdevice_p.h>
11#include <QtCore/qpointer.h>
67 p->extra.value().pointerHandlers.removeOne(
this);
97 if (
d->m_margin == pointDistanceThreshold)
100 d->m_margin = pointDistanceThreshold;
118 if (
d->dragThreshold < 0)
119 return qApp->styleHints()->startDragDistance();
120 return d->dragThreshold;
126 if (
d->dragThreshold ==
t)
129 if (
t > std::numeric_limits<qint16>::max())
130 qWarning() <<
"drag threshold cannot exceed" << std::numeric_limits<qint16>::max();
132 emit dragThresholdChanged();
138 if (
d->dragThreshold < 0)
141 d->dragThreshold = -1;
142 emit dragThresholdChanged();
190 return d->cursorShape;
196 if (
d->cursorSet && shape ==
d->cursorShape)
198 d->cursorShape = shape;
200 d->cursorDirty =
true;
203 itemPriv->hasCursorHandler =
true;
204 itemPriv->setHasCursorInChild(
true);
207 emit cursorShapeChanged();
210void QQuickPointerHandler::resetCursorShape()
216 d->cursorSet =
false;
219 itemPriv->hasCursorHandler =
false;
220 itemPriv->setHasCursorInChild(itemPriv->hasCursor);
222 emit cursorShapeChanged();
225bool QQuickPointerHandler::isCursorShapeExplicitlySet()
const
249 qCDebug(lcPointerHandlerGrab) << point << transition << grabber;
250 if (grabber ==
this) {
251 bool wasCanceled =
false;
252 switch (transition) {
266 par->setKeepMouseGrab(
d->hadKeepMouseGrab);
267 par->setKeepTouchGrab(
d->hadKeepTouchGrab);
298 qCDebug(lcPointerHandlerGrab) <<
this << point << grab <<
"via"
301 event->addPassiveGrabber(point,
this);
303 event->removePassiveGrabber(point,
this);
322 (existingPhGrabber ? existingPhGrabber->approveGrabTransition(
event, point,
this) :
true);
334 bool allowed =
false;
335 QObject* existingGrabber =
event->exclusiveGrabber(point);
336 if (proposedGrabber ==
this) {
338 if (existingGrabber) {
341 existingPhGrabber->metaObject()->className() !=
metaObject()->className())
344 existingPhGrabber->metaObject()->className() ==
metaObject()->className())
352 const bool isTouchMouse = (da && da->isDeliveringTouchAsMouse());
353 if (existingItemGrabber &&
354 ((existingItemGrabber->keepMouseGrab() &&
365 if (existingItemGrabber->keepMouseGrab() &&
366 existingItemGrabber->filtersChildMouseEvents() && existingItemGrabber->isAncestorOf(
parentItem())) {
368 if (isTouchMouse && point.
id() == da->touchMouseId) {
369 qCDebug(lcPointerHandlerGrab) <<
this <<
"steals touchpoint" << point.
id()
370 <<
"despite parent touch-mouse grabber with keepMouseGrab=true" << existingItemGrabber;
375 qCDebug(lcPointerHandlerGrab) <<
this <<
"wants to grab point" << point.
id()
376 <<
"but declines to steal from grabber" << existingItemGrabber
377 <<
"with keepMouseGrab=" << existingItemGrabber->keepMouseGrab()
378 <<
"keepTouchGrab=" << existingItemGrabber->keepTouchGrab();
385 if (proposedGrabber) {
401 qCDebug(lcPointerHandlerGrab) <<
"point" <<
Qt::hex << point.
id() <<
"permission" <<
402 QMetaEnum::fromType<GrabPermissions>().valueToKeys(
grabPermissions()) <<
403 ':' <<
this << (allowed ?
"approved from" :
"denied from") <<
404 existingGrabber <<
"to" << proposedGrabber;
444 return static_cast<QQuickPointerHandler::GrabPermissions
>(
d->grabPermissions);
450 if (
d->grabPermissions == grabPermission)
453 d->grabPermissions = grabPermission;
474 itemPriv->hasCursorHandler =
true;
475 itemPriv->setHasCursorInChild(
true);
489 return d->currentEvent;
502 if ((grab && ev->exclusiveGrabber(point) ==
this) || (!grab && ev->exclusiveGrabber(point) !=
this))
509 QQuickPointerHandler *existingPhGrabber = qobject_cast<QQuickPointerHandler *>(ev->exclusiveGrabber(point));
511 if (existingPhGrabber && existingPhGrabber !=
this && !existingPhGrabber->approveGrabTransition(ev, point,
nullptr))
514 qCDebug(lcPointerHandlerGrab) << point << (grab ?
"grab" :
"ungrab") << (allowed ?
"allowed" :
"forbidden") <<
515 ev->exclusiveGrabber(point) <<
"->" << (grab ?
this :
nullptr);
517 ev->setExclusiveGrabber(point, grab ?
this :
nullptr);
526 qCDebug(lcPointerHandlerGrab) << point;
527 if (
event->exclusiveGrabber(point) ==
this) {
528 event->setExclusiveGrabber(point,
nullptr);
531 if (
event->removePassiveGrabber(point,
this))
563 QRectF windowGeometry = par->window()->geometry();
564 if (!par->window()->isTopLevel())
566 QPointF screenPosition = par->window()->mapToGlobal(scenePosition);
567 if (!windowGeometry.
contains(screenPosition))
570 QPointF p = par->mapFromScene(scenePosition);
573 return p.x() >= -
m &&
p.y() >= -
m &&
p.x() <= par->width() +
m &&
p.y() <= par->height() +
m;
574 return par->contains(
p);
602 d->onEnabledChanged();
621 if (!
d->targetExplicitlySet)
629 d->targetExplicitlySet =
true;
671 qCDebug(lcHandlerParent) <<
"reparenting handler" <<
this <<
":" <<
parent() <<
"->" <<
p;
678 d->onParentChanged(oldParent,
p);
679 emit parentChanged();
693 for (
int i = 0;
i < te->pointCount(); ++
i)
715 << (wants ?
"WANTS" :
"DECLINES") <<
event;
719 d->lastEventTime =
event->timestamp();
721#if QT_CONFIG(gestures)
725 for (
int i = 0;
i <
event->pointCount(); ++
i) {
726 auto &pt =
event->point(
i);
728 event->setExclusiveGrabber(pt,
nullptr);
731 d->currentEvent =
nullptr;
788 bool ret =
event->exclusiveGrabber(point) ==
this ||
789 event->passiveGrabbers(point).contains(
this) ||
parentContains(point);
815 qCDebug(lcPointerHandlerActive) <<
this <<
d->active <<
"->" <<
active;
875 , cursorShape(
Qt::ArrowCursor)
878 , targetExplicitlySet(
false)
879 , hadKeepMouseGrab(
false)
880 , hadKeepTouchGrab(
false)
893template <
typename TEventPo
int>
898 bool overThreshold =
qAbs(
d) >
q->dragThreshold();
900 if (!overThreshold && dragVelocityLimitAvailable) {
904 return overThreshold;
916 const float threshold =
q->dragThreshold();
917 return qAbs(delta.
x()) > threshold ||
qAbs(delta.
y()) > threshold;
941#include "moc_qquickpointerhandler_p.cpp"
IOBluetoothDevice * device
The QEventPoint class provides information about a point in a QPointerEvent.
int id
the ID number of this event point.
QPointF scenePosition
the scene position of this point.
void setAccepted(bool accepted=true)
QPointF scenePressPosition
the scene position at which this point was pressed.
Type type() const
Returns the event type.
static QObjectPrivate * get(QObject *o)
QObject * parent() const
Returns a pointer to the parent object.
QString objectName
the name of this object
virtual bool event(QEvent *event)
This virtual function receives events to an object and should return true if the event e was recogniz...
void setParent(QObject *parent)
Makes the object a child of parent.
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
A base class for pointer events.
GrabTransition
This enum represents a transition of exclusive or passive grab from one object (possibly nullptr) to ...
static QQuickPointingDeviceExtra * deviceExtra(const QInputDevice *device)
static QQuickDeliveryAgent * currentEventDeliveryAgent
static bool isTouchEvent(const QPointerEvent *ev)
static bool isMouseEvent(const QPointerEvent *ev)
static QQuickDeliveryAgent * currentOrItemDeliveryAgent(const QQuickItem *item)
static QQuickItemPrivate * get(QQuickItem *item)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
QQuickPointerHandlerPrivate()
\qmlsignal QtQuick::PointerHandler::grabChanged(PointerDevice::GrabTransition transition,...
static QVector< QObject * > & deviceDeliveryTargets(const QInputDevice *device)
bool dragOverThreshold(qreal d, Qt::Axis axis, const TEventPoint &p) const
virtual bool canGrab(QPointerEvent *event, const QEventPoint &point)
Check whether it's OK to take an exclusive grab of the point.
bool parentContains(const QEventPoint &point) const
Returns true if margin() > 0 and point is within the margin beyond QQuickItem::boundingRect(),...
QQuickItem * parentItem() const
\qmlproperty Item QtQuick::PointerHandler::parent
void handlePointerEvent(QPointerEvent *event)
QQuickPointerHandler(QQuickItem *parent=nullptr)
\qmltype PointerHandler \qmlabstract
void grabChanged(QPointingDevice::GrabTransition transition, QEventPoint point)
void cancelAllGrabs(QPointerEvent *event, QEventPoint &point)
Cancel any existing grab of the given point.
virtual bool wantsPointerEvent(QPointerEvent *event)
It is the responsibility of this function to decide whether the event could be relevant at all to thi...
void resetDragThreshold()
void setMargin(qreal pointDistanceThreshold)
virtual bool approveGrabTransition(QPointerEvent *event, const QEventPoint &point, QObject *proposedGrabber)
Check this handler's rules to see if \l proposedGrabber will be allowed to take the exclusive grab.
virtual bool wantsEventPoint(const QPointerEvent *event, const QEventPoint &point)
Returns true if the given point (as part of event) could be relevant at all to this handler,...
void setPassiveGrab(QPointerEvent *event, const QEventPoint &point, bool grab=true)
Acquire or give up a passive grab of the given point, according to the grab state.
virtual void onActiveChanged()
void setGrabPermissions(GrabPermissions grabPermissions)
void grabPermissionChanged()
virtual void onGrabChanged(QQuickPointerHandler *grabber, QPointingDevice::GrabTransition transition, QPointerEvent *event, QEventPoint &point)
Notification that the grab has changed in some way which is relevant to this handler.
void setParentItem(QQuickItem *p)
void componentComplete() override
Overridden from QQmlParserStatus to ensure that parentItem() sets its cursor if this handler's \l cur...
virtual void onTargetChanged(QQuickItem *oldTarget)
QPointF eventPos(const QEventPoint &point) const
GrabPermissions grabPermissions
virtual void handlePointerEventImpl(QPointerEvent *event)
This function can be overridden to implement whatever behavior a specific subclass is intended to hav...
void setEnabled(bool enabled)
void classBegin() override
Overridden only because QQmlParserStatus requires it.
void setTarget(QQuickItem *target)
@ ApprovesTakeOverByAnything
@ CanTakeOverFromHandlersOfSameType
@ ApprovesTakeOverByHandlersOfSameType
@ CanTakeOverFromHandlersOfDifferentType
@ ApprovesTakeOverByItems
@ ApprovesTakeOverByHandlersOfDifferentType
@ CanTakeOverFromAnything
bool setExclusiveGrab(QPointerEvent *ev, const QEventPoint &point, bool grab=true)
Acquire or give up the exclusive grab of the given point, according to the grab state,...
void canceled(QEventPoint point)
QPointerEvent * currentEvent()
void setDragThreshold(int t)
bool event(QEvent *) override
void setActive(bool active)
\inmodule QtCore\reentrant
bool contains(const QRectF &r) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QStyleHints class contains platform specific hints and settings. \inmodule QtGui.
int startDragVelocity
the limit for the velocity, in pixels per second, that the mouse may be moved, with a button held dow...
The QTouchEvent class contains parameters that describe a touch event.
The QVector2D class represents a vector or vertex in 2D space.
constexpr float y() const noexcept
Returns the y coordinate of this point.
constexpr float x() const noexcept
Returns the x coordinate of this point.
static QWindowPrivate * get(QWindow *window)
Combined button and popup list for selecting options.
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
constexpr T qAbs(const T &t)
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLdouble GLdouble GLdouble GLdouble q
QQuickItem * qmlobject_cast< QQuickItem * >(QObject *object)
QQuickItem * qobject_cast< QQuickItem * >(QObject *o)
const char className[16]
[1]
obj metaObject() -> className()