5#include <QtQuick/qquickwindow.h>
6#include <private/qsgadaptationlayer_p.h>
7#include <private/qquickitem_p.h>
8#include <private/qquickwindow_p.h>
9#include <private/qguiapplication_p.h>
10#include <QtGui/private/qevent_p.h>
11#include <QtGui/private/qeventpoint_p.h>
12#include <QtGui/private/qpointingdevice_p.h>
16#include <qpa/qplatformnativeinterface.h>
47 emit pointIdChanged();
59 bool xch = (_x !=
p.x());
60 bool ych = (_y !=
p.y());
80 if (_ellipseDiameters ==
d)
82 _ellipseDiameters =
d;
83 emit ellipseDiametersChanged();
125 emit rotationChanged();
251 emit uniqueIdChanged();
432 _minimumTouchPoints(0),
433 _maximumTouchPoints(INT_MAX),
440 if (qmlMptaVisualTouchDebugging()) {
452 for (
QObject *
obj : std::as_const(_touchPoints)) {
478 return _minimumTouchPoints;
483 if (_minimumTouchPoints ==
num)
485 _minimumTouchPoints =
num;
491 return _maximumTouchPoints;
496 if (_maximumTouchPoints ==
num)
498 _maximumTouchPoints =
num;
513 if (_mouseEnabled !=
arg) {
515 if (_mouseTouchPoint && !
arg)
516 _mouseTouchPoint =
nullptr;
523 switch (
event->type()) {
529 QQuickItem *grabber =
c ?
c->mouseGrabberItem() :
nullptr;
562 pt->exclusiveGrabber =
this;
571 bool started =
false;
575 bool touchPointsFromEvent =
false;
578 switch (
event->type()) {
584 touchPointsFromEvent =
true;
590 _mouseQpaTouchPoint =
QEventPoint(da->touchMouseId);
591 _touchMouseDevice = da->touchMouseDevice;
607 qWarning(
"updateTouchData: unhandled event type %d",
event->type());
622 _releasedTouchPoints.
append(dtp);
627 if (numTouchPoints >= _minimumTouchPoints && numTouchPoints <= _maximumTouchPoints) {
630 auto transformBack =
qScopeGuard([&] { QMutableEventPoint::setPosition(
p, oldPos); });
632 QMutableEventPoint::setPosition(
p,
mapFromScene(
p.scenePosition()));
637 }
else if (!_touchPoints.
contains(
id)) {
646 _movedTouchPoints.
append(dtp);
658 bool offerGrab =
false;
663 const QPointF ¤tPos =
p.scenePosition();
664 const QPointF &startPos =
p.scenePressPosition();
665 if (
qAbs(currentPos.
x() - startPos.
x()) > dragThreshold)
667 else if (
qAbs(currentPos.
y() - startPos.
y()) > dragThreshold)
675 event._touchPoints = _touchPoints.
values();
677 if (
event.wantsGrab() && dev)
686 if (started && !_pressedTouchPoints.
isEmpty())
694 for (
QObject *
obj : std::as_const(_releasedTouchPoints)) {
703 _releasedTouchPoints.
clear();
704 _pressedTouchPoints.
clear();
705 _movedTouchPoints.
clear();
724 _touchPoints.
insert(
p->id(),dtp);
725 _pressedTouchPoints.
append(dtp);
736 }
else if (_mouseTouchPoint == tp) {
745 _touchPoints.
insert(_mouseQpaTouchPoint.
id(), dtp);
746 _pressedTouchPoints.
append(dtp);
747 _mouseTouchPoint = dtp;
759 setTouchEventsEnabled(
false);
763void QQuickMultiPointTouchArea::setTouchEventsEnabled(
bool enable)
766 typedef void (*RegisterTouchWindowFunction)(
QWindow *, bool);
767 RegisterTouchWindowFunction registerTouchWindow =
reinterpret_cast<RegisterTouchWindowFunction
>(
769 if (!registerTouchWindow)
785 int id = _touchPrototypes.
size();
787 _touchPrototypes.
insert(
id, prototype);
801 area.moveCenter(
p->position());
833 event->setAccepted(
true);
834 _mousePos =
event->position();
838 if (_touchPoints.
size() >= _minimumTouchPoints - 1 && _touchPoints.
size() < _maximumTouchPoints) {
853 _movedTouchPoints.
clear();
868 if (_mouseTouchPoint) {
871 _releasedTouchPoints.
removeAll(_mouseTouchPoint);
872 _mouseTouchPoint =
nullptr;
878void QQuickMultiPointTouchArea::ungrab(
bool normalRelease)
886 if (_touchPoints.
size()) {
899 _touchPoints.
clear();
919 QQuickItem *grabber =
c ?
c->mouseGrabberItem() :
nullptr;
920 bool stealThisEvent = _stealMouse;
924 QMutableEventPoint::setPosition(mouseEvent.
point(0), localPos);
929 switch (mouseEvent.
type()) {
942 grabber =
c ?
c->mouseGrabberItem() :
nullptr;
943 if (grabber && stealThisEvent && !grabber->
keepMouseGrab() && grabber !=
this)
947 return stealThisEvent;
951 if (
c &&
c->mouseGrabberItem() ==
this)
962 switch (
event->type()) {
968 _lastFilterableTouchPointIds.contains(da->touchMouseId))
975 _lastFilterableTouchPointIds.clear();
980 _lastFilterableTouchPointIds << tp.id();
1002 QQuickItem *grabber =
c ?
c->mouseGrabberItem() :
nullptr;
1003 bool disabledItem = grabber && !grabber->
isEnabled();
1004 bool stealThisEvent = _stealMouse;
1005 bool containsPoint =
false;
1006 if (!stealThisEvent) {
1007 switch (
event->type()) {
1021 containsPoint =
true;
1031 if ((stealThisEvent || containsPoint) && (!grabber || !grabber->
keepMouseGrab() || disabledItem)) {
1042 if (!qmlMptaVisualTouchDebugging())
1056#include "moc_qquickmultipointtoucharea_p.cpp"
The QColor class provides colors based on RGB, HSV or CMYK values.
The QEventPoint class provides information about a point in a QPointerEvent.
int id
the ID number of this event point.
State
Specifies the state of this event point.
Type type() const
Returns the event type.
QGraphicsItem * parentItem() const
Returns a pointer to this item's parent item.
static QPlatformNativeInterface * platformNativeInterface()
static QStyleHints * styleHints()
Returns the application's style hints.
bool isEmpty() const noexcept
qsizetype removeAll(const AT &t)
void append(parameter_type t)
iterator insert(const Key &key, const T &value)
T value(const Key &key, const T &defaultValue=T()) const
bool contains(const Key &key) const
QList< T > values() const
size_type remove(const Key &key)
key_iterator keyBegin() const
key_iterator keyEnd() const
void setSource(Qt::MouseEventSource s)
\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.
const QPointingDevice * pointingDevice() const
Returns the source device from which this event originates.
QEventPoint & point(qsizetype i)
Returns a QEventPoint reference for the point at index i.
virtual void setAccepted(bool accepted) override
\reimp
const QList< QEventPoint > & points() const
Returns a list of points in this pointer event.
EventPointData * queryPointById(int id) const
static QPointingDevicePrivate * get(QPointingDevice *q)
QPointingDeviceUniqueId identifies a unique object, such as a tagged token or stylus,...
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
QSGContext * sceneGraphContext() const
QQuickDeliveryAgentPrivate * deliveryAgentPrivate()
static QQuickItemPrivate * get(QQuickItem *item)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
void setFiltersChildMouseEvents(bool filter)
Sets whether pointer events intended for this item's children should be filtered through this item.
virtual void mouseReleaseEvent(QMouseEvent *event)
This event handler can be reimplemented in a subclass to receive mouse release events for an item.
virtual void hoverEnterEvent(QHoverEvent *event)
This event handler can be reimplemented in a subclass to receive hover-enter events for an item.
void setKeepTouchGrab(bool)
Sets whether the touch points grabbed by this item should remain exclusively with this item.
void setFlag(Flag flag, bool enabled=true)
Enables the specified flag for this item if enabled is true; if enabled is false, the flag is disable...
void setAcceptHoverEvents(bool enabled)
If enabled is true, this sets the item to accept hover events; otherwise, hover events are not accept...
QPointF mapFromScene(const QPointF &point) const
Maps the given point in the scene's coordinate system to the equivalent point within this item's coor...
void setAcceptTouchEvents(bool accept)
If enabled is true, this sets the item to accept touch events; otherwise, touch events are not accept...
virtual Q_INVOKABLE bool contains(const QPointF &point) const
\qmlmethod bool QtQuick::Item::contains(point point)
void setAcceptedMouseButtons(Qt::MouseButtons buttons)
Sets the mouse buttons accepted by this item to buttons.
QQuickWindow * window() const
Returns the window in which this item is rendered.
virtual void mousePressEvent(QMouseEvent *event)
This event handler can be reimplemented in a subclass to receive mouse press events for an item.
qreal width
This property holds the width of this item.
virtual void itemChange(ItemChange, const ItemChangeData &)
Called when change occurs for this item.
bool keepMouseGrab() const
Returns whether mouse input should exclusively remain with this item.
void setKeepMouseGrab(bool)
Sets whether the mouse input should remain exclusively with this item.
virtual void touchEvent(QTouchEvent *event)
This event handler can be reimplemented in a subclass to receive touch events for an item.
qreal height
This property holds the height of this item.
virtual bool childMouseEventFilter(QQuickItem *, QEvent *)
Reimplement this method to filter the pointer events that are received by this item's children.
virtual void hoverLeaveEvent(QHoverEvent *event)
This event handler can be reimplemented in a subclass to receive hover-leave events for an item.
virtual void mouseMoveEvent(QMouseEvent *event)
This event handler can be reimplemented in a subclass to receive mouse move events for an item.
~QQuickMultiPointTouchArea()
void canceled(const QList< QObject * > &points)
void mouseEnabledChanged()
void setMinimumTouchPoints(int num)
void updateTouchData(QEvent *, RemapEventPoints remap=RemapEventPoints::No)
void mouseReleaseEvent(QMouseEvent *event) override
This event handler can be reimplemented in a subclass to receive mouse release events for an item.
QQuickMultiPointTouchArea(QQuickItem *parent=nullptr)
\qmltype GestureEvent \instantiates QQuickGrabGestureEvent \inqmlmodule QtQuick
void setMouseEnabled(bool arg)
\qmlproperty bool QtQuick::MultiPointTouchArea::mouseEnabled
void minimumTouchPointsChanged()
bool shouldFilter(QEvent *event)
void addTouchPrototype(QQuickTouchPoint *prototype)
bool childMouseEventFilter(QQuickItem *receiver, QEvent *event) override
Reimplement this method to filter the pointer events that are received by this item's children.
void setMaximumTouchPoints(int num)
void touchUngrabEvent() override
This event handler can be reimplemented in a subclass to be notified when a touch ungrab event has oc...
void mouseMoveEvent(QMouseEvent *event) override
This event handler can be reimplemented in a subclass to receive mouse move events for an item.
void maximumTouchPointsChanged()
void touchEvent(QTouchEvent *) override
This event handler can be reimplemented in a subclass to receive touch events for an item.
void gestureStarted(QQuickGrabGestureEvent *gesture)
void addTouchPoint(const QEventPoint *p)
void mouseUngrabEvent() override
This event handler can be reimplemented in a subclass to be notified when a mouse ungrab event has oc...
QQmlListProperty< QQuickTouchPoint > touchPoints
bool sendMouseEvent(QMouseEvent *event)
void mousePressEvent(QMouseEvent *event) override
This event handler can be reimplemented in a subclass to receive mouse press events for an item.
void updated(const QList< QObject * > &points)
void released(const QList< QObject * > &points)
void updateTouchPoint(QQuickTouchPoint *, const QEventPoint *)
void grabGesture(QPointingDevice *dev)
QSGNode * updatePaintNode(QSGNode *, UpdatePaintNodeData *) override
Called on the render thread when it is time to sync the state of the item with the scene graph.
void pressed(const QList< QObject * > &points)
void touchUpdated(const QList< QObject * > &points)
void setArea(const QRectF &area)
void setSceneX(qreal sceneX)
\qmlproperty real QtQuick::TouchPoint::sceneX \qmlproperty real QtQuick::TouchPoint::sceneY
void setPressed(bool pressed)
\qmlproperty bool QtQuick::TouchPoint::pressed
void setEllipseDiameters(const QSizeF &d)
\qmlproperty size QtQuick::TouchPoint::ellipseDiameters
void setStartY(qreal startY)
void setUniqueId(const QPointingDeviceUniqueId &id)
\qmlproperty pointingDeviceUniqueId QtQuick::TouchPoint::uniqueId
void setPressure(qreal pressure)
\qmlproperty real QtQuick::TouchPoint::pressure \qmlproperty vector2d QtQuick::TouchPoint::velocity
void setStartX(qreal startX)
\qmlproperty real QtQuick::TouchPoint::startX \qmlproperty real QtQuick::TouchPoint::startY
void setRotation(qreal r)
\qmlproperty real QtQuick::TouchPoint::rotation
void setPreviousY(qreal previousY)
void setInUse(bool inUse)
void setSceneY(qreal sceneY)
void setVelocity(const QVector2D &velocity)
void setPointId(int id)
\qmltype TouchPoint \instantiates QQuickTouchPoint \inqmlmodule QtQuick
void setPosition(QPointF pos)
\qmlproperty real QtQuick::TouchPoint::x \qmlproperty real QtQuick::TouchPoint::y
void setPreviousX(qreal previousX)
\qmlproperty real QtQuick::TouchPoint::previousX \qmlproperty real QtQuick::TouchPoint::previousY
bool isQmlDefined() const
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\inmodule QtCore\reentrant
QSGInternalRectangleNode * createInternalRectangleNode(const QRectF &rect, const QColor &c)
Convenience factory function for creating a colored rectangle with the given geometry.
virtual void setRect(const QRectF &rect)=0
virtual void setColor(const QColor &color)=0
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
A base class for pointer events containing a single point, such as mouse events.
QPointF position() const
Returns the position of the point in this event, relative to the widget or item that received the eve...
QPointF scenePosition() const
Returns the position of the point in this event, relative to the window or scene.
int startDragDistance
the distance, in pixels, that the mouse must be moved with a button held down before a drag and drop ...
The QTouchEvent class contains parameters that describe a touch event.
The QVector2D class represents a vector or vertex in 2D space.
QSet< QString >::iterator it
Combined button and popup list for selecting options.
@ MouseEventSynthesizedByQt
@ MouseEventNotSynthesized
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
static int area(const QSize &s)
constexpr T qAbs(const T &t)
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLsizei GLsizei GLchar * source
GLfixed GLfixed GLint GLint GLfixed points
#define DEFINE_BOOL_CONFIG_OPTION(name, var)
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent