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>
65 p->extra.value().pointerHandlers.removeOne(
this);
95 if (
d->m_margin == pointDistanceThreshold)
98 d->m_margin = pointDistanceThreshold;
116 if (
d->dragThreshold < 0)
117 return qApp->styleHints()->startDragDistance();
118 return d->dragThreshold;
124 if (
d->dragThreshold ==
t)
127 if (
t > std::numeric_limits<qint16>::max())
128 qWarning() <<
"drag threshold cannot exceed" << std::numeric_limits<qint16>::max();
130 emit dragThresholdChanged();
136 if (
d->dragThreshold < 0)
139 d->dragThreshold = -1;
140 emit dragThresholdChanged();
188 return d->cursorShape;
194 if (
d->cursorSet && shape ==
d->cursorShape)
196 d->cursorShape = shape;
203 emit cursorShapeChanged();
206void QQuickPointerHandler::resetCursorShape()
212 d->cursorSet =
false;
218 emit cursorShapeChanged();
221bool QQuickPointerHandler::isCursorShapeExplicitlySet()
const
245 qCDebug(lcPointerHandlerGrab) << point << transition << grabber;
246 if (grabber ==
this) {
247 bool wasCanceled =
false;
248 switch (transition) {
262 par->setKeepMouseGrab(
d->hadKeepMouseGrab);
263 par->setKeepTouchGrab(
d->hadKeepTouchGrab);
294 qCDebug(lcPointerHandlerGrab) <<
this << point << grab <<
"via"
297 event->addPassiveGrabber(point,
this);
299 event->removePassiveGrabber(point,
this);
330 bool allowed =
false;
331 QObject* existingGrabber =
event->exclusiveGrabber(point);
332 if (proposedGrabber ==
this) {
334 if (existingGrabber) {
337 existingPhGrabber->metaObject()->className() !=
metaObject()->className())
340 existingPhGrabber->metaObject()->className() ==
metaObject()->className())
348 const bool isTouchMouse = (da && da->isDeliveringTouchAsMouse());
349 if (existingItemGrabber &&
364 if (isTouchMouse && point.
id() == da->touchMouseId) {
365 qCDebug(lcPointerHandlerGrab) <<
this <<
"steals touchpoint" << point.
id()
366 <<
"despite parent touch-mouse grabber with keepMouseGrab=true" << existingItemGrabber;
371 qCDebug(lcPointerHandlerGrab) <<
this <<
"wants to grab point" << point.
id()
372 <<
"but declines to steal from grabber" << existingItemGrabber
373 <<
"with keepMouseGrab=" << existingItemGrabber->
keepMouseGrab()
381 if (proposedGrabber) {
397 qCDebug(lcPointerHandlerGrab) <<
"point" <<
Qt::hex << point.
id() <<
"permission" <<
398 QMetaEnum::fromType<GrabPermissions>().valueToKeys(
grabPermissions()) <<
399 ':' <<
this << (allowed ?
"approved from" :
"denied from") <<
400 existingGrabber <<
"to" << proposedGrabber;
440 return static_cast<QQuickPointerHandler::GrabPermissions
>(
d->grabPermissions);
446 if (
d->grabPermissions == grabPermission)
449 d->grabPermissions = grabPermission;
485 return d->currentEvent;
507 if (existingPhGrabber && existingPhGrabber !=
this && !existingPhGrabber->
approveGrabTransition(ev, point,
nullptr))
510 qCDebug(lcPointerHandlerGrab) << point << (grab ?
"grab" :
"ungrab") << (allowed ?
"allowed" :
"forbidden") <<
522 qCDebug(lcPointerHandlerGrab) << point;
523 if (
event->exclusiveGrabber(point) ==
this) {
524 event->setExclusiveGrabber(point,
nullptr);
527 if (
event->removePassiveGrabber(point,
this))
559 QRect windowGeometry = par->window()->geometry();
560 if (!par->window()->isTopLevel())
562 QPoint screenPosition = par->window()->mapToGlobal(scenePosition.
toPoint());
563 if (!windowGeometry.
contains(screenPosition))
566 QPointF p = par->mapFromScene(scenePosition);
569 return p.x() >= -
m &&
p.y() >= -
m &&
p.x() <= par->width() +
m &&
p.y() <= par->height() +
m;
570 return par->contains(
p);
598 d->onEnabledChanged();
617 if (!
d->targetExplicitlySet)
625 d->targetExplicitlySet =
true;
667 qCDebug(lcHandlerParent) <<
"reparenting handler" <<
this <<
":" <<
parent() <<
"->" <<
p;
674 d->onParentChanged(oldParent,
p);
675 emit parentChanged();
689 for (
int i = 0;
i < te->pointCount(); ++
i)
711 << (wants ?
"WANTS" :
"DECLINES") <<
event;
715 d->lastEventTime =
event->timestamp();
717#if QT_CONFIG(gestures)
721 for (
int i = 0;
i <
event->pointCount(); ++
i) {
722 auto &pt =
event->point(
i);
724 event->setExclusiveGrabber(pt,
nullptr);
727 d->currentEvent =
nullptr;
784 bool ret =
event->exclusiveGrabber(point) ==
this ||
785 event->passiveGrabbers(point).contains(
this) ||
parentContains(point);
811 qCDebug(lcPointerHandlerActive) <<
this <<
d->active <<
"->" <<
active;
868 , cursorShape(
Qt::ArrowCursor)
871 , targetExplicitlySet(
false)
872 , hadKeepMouseGrab(
false)
873 , hadKeepTouchGrab(
false)
885template <
typename TEventPo
int>
890 bool overThreshold =
qAbs(
d) >
q->dragThreshold();
892 if (!overThreshold && dragVelocityLimitAvailable) {
896 return overThreshold;
908 const float threshold =
q->dragThreshold();
909 return qAbs(delta.
x()) > threshold ||
qAbs(delta.
y()) > threshold;
933#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.
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.
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
\inmodule QtCore\reentrant
A base class for pointer events.
void setExclusiveGrabber(const QEventPoint &point, QObject *exclusiveGrabber)
Informs the delivery logic that the given exclusiveGrabber is to receive all future update events and...
QObject * exclusiveGrabber(const QEventPoint &point) const
Returns the object which has been set to receive all future update events and the release event conta...
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)
virtual void removePointerHandler(QQuickPointerHandler *h)
void setHasCursorInChild(bool hasCursor)
QQuickDeliveryAgentPrivate * deliveryAgentPrivate()
virtual void addPointerHandler(QQuickPointerHandler *h)
static QQuickItemPrivate * get(QQuickItem *item)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
bool keepTouchGrab() const
Returns whether the touch points grabbed by this item should exclusively remain with this item.
bool filtersChildMouseEvents() const
Returns whether pointer events intended for this item's children should be filtered through this item...
bool keepMouseGrab() const
Returns whether mouse input should exclusively remain with this item.
bool isAncestorOf(const QQuickItem *child) const
Returns true if this item is an ancestor of child (i.e., if this item is child's parent,...
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
Returns true if the movement delta d in pixels along the axis exceeds QQuickPointerHandler::dragThres...
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 QRect &r, bool proper=false) 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)
QPoint globalPosition() const
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()
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent