17 #ifndef UBUNTU_TOUCH_GATE_H
18 #define UBUNTU_TOUCH_GATE_H
20 #include "UbuntuGesturesQmlGlobal.h"
21 #include "TouchDispatcher.h"
27 #define TOUCHGATE_DEBUG 0
29 class TouchOwnershipEvent;
41 class UBUNTUGESTURESQML_EXPORT TouchGate :
public QQuickItem {
45 Q_PROPERTY(QQuickItem* targetItem READ targetItem WRITE setTargetItem NOTIFY targetItemChanged)
48 TouchGate(QQuickItem *parent =
nullptr);
50 bool event(QEvent *e)
override;
52 QQuickItem *targetItem() {
return m_dispatcher.targetItem(); }
53 void setTargetItem(QQuickItem *item);
56 void targetItemChanged(QQuickItem *item);
59 void touchEvent(QTouchEvent *event)
override;
60 void itemChange(ItemChange change,
const ItemChangeData &value)
override;
63 void onEnabledChanged();
70 TouchEvent(QTouchDevice *device,
71 Qt::KeyboardModifiers modifiers,
72 const QList<QTouchEvent::TouchPoint> &touchPoints,
76 bool removeTouch(
int touchId);
79 Qt::KeyboardModifiers modifiers;
80 QList<QTouchEvent::TouchPoint> touchPoints;
85 void touchOwnershipEvent(TouchOwnershipEvent *event);
86 bool isTouchPointOwned(
int touchId)
const;
87 void storeTouchEvent(QTouchDevice *device,
88 Qt::KeyboardModifiers modifiers,
89 const QList<QTouchEvent::TouchPoint> &touchPoints,
92 void removeTouchFromStoredEvents(
int touchId);
93 void dispatchFullyOwnedEvents();
94 bool eventIsFullyOwned(
const TouchEvent &event)
const;
96 void dispatchTouchEventToTarget(
const TouchEvent &event);
98 void removeTouchInfoForEndedTouches(
const QList<QTouchEvent::TouchPoint> &touchPoints);
101 QString oldestPendingTouchIdsString();
104 QList<TouchEvent> m_storedEvents;
113 TouchInfo() {ownership = OwnershipUndefined; ended =
false;}
117 QMap<int, TouchInfo> m_touchInfoMap;
119 TouchDispatcher m_dispatcher;
121 friend class tst_TouchGate;
124 #endif // UBUNTU_TOUCH_GATE_H