17#ifndef LOMIRI_TOUCH_GATE_H
18#define LOMIRI_TOUCH_GATE_H
20#include "LomiriGesturesQmlGlobal.h"
21#include "TouchDispatcher.h"
22#include <LomiriGestures/lomirigesturesglobal.h>
28#define TOUCHGATE_DEBUG 0
30UG_FORWARD_DECLARE_CLASS(TouchOwnershipEvent)
42class LOMIRIGESTURESQML_EXPORT TouchGate :
public QQuickItem {
46 Q_PROPERTY(QQuickItem* targetItem READ targetItem WRITE setTargetItem NOTIFY targetItemChanged)
49 TouchGate(QQuickItem *parent =
nullptr);
51 bool event(QEvent *e)
override;
53 QQuickItem *targetItem() {
return m_dispatcher.targetItem(); }
54 void setTargetItem(QQuickItem *item);
57 void targetItemChanged(QQuickItem *item);
60 void touchEvent(QTouchEvent *event)
override;
61 void itemChange(ItemChange change,
const ItemChangeData &value)
override;
64 void onEnabledChanged();
71 TouchEvent(QTouchDevice *device,
72 Qt::KeyboardModifiers modifiers,
73 const QList<QTouchEvent::TouchPoint> &touchPoints,
77 bool removeTouch(
int touchId);
80 Qt::KeyboardModifiers modifiers;
81 QList<QTouchEvent::TouchPoint> touchPoints;
86 void touchOwnershipEvent(UG_PREPEND_NAMESPACE(TouchOwnershipEvent) *event);
87 bool isTouchPointOwned(
int touchId)
const;
88 void storeTouchEvent(QTouchDevice *device,
89 Qt::KeyboardModifiers modifiers,
90 const QList<QTouchEvent::TouchPoint> &touchPoints,
93 void removeTouchFromStoredEvents(
int touchId);
94 void dispatchFullyOwnedEvents();
95 bool eventIsFullyOwned(
const TouchEvent &event)
const;
97 void dispatchTouchEventToTarget(
const TouchEvent &event);
99 void removeTouchInfoForEndedTouches(
const QList<QTouchEvent::TouchPoint> &touchPoints);
102 QString oldestPendingTouchIdsString();
105 QList<TouchEvent> m_storedEvents;
114 TouchInfo() {ownership = OwnershipUndefined; ended =
false;}
118 QMap<int, TouchInfo> m_touchInfoMap;
120 TouchDispatcher m_dispatcher;
122 friend class tst_TouchGate;