Debian Codegraph @

src/LomiriGestures/touchregistry_p.h

raw symbols SCIP
1 /*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 #ifndef TOUCHREGISTRY_P_H
18 #define TOUCHREGISTRY_P_Hcxx . . $ `src/LomiriGestures/touchregistry_p.h:18:9`!
19
20 #include <utility>
21
22 #include <QtCore/QLoggingCategory>
23 #include <QtCore/QObject>
24 #include <QtCore/QPointer>
25 #include <QtCore/QVector>
26 #include <QtGui/QTouchEvent>
27 #include <QtQuick/QQuickItem>
28
29 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
30 #include <LomiriGestures-Qt6/lomirigesturesglobal.h>
31 #else
32 #include <LomiriGestures/lomirigesturesglobal.h>cxx . . $ `<file>/include/LomiriGestures/lomirigesturesglobal.h`/
33 #endif
34 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
35 #include <LomiriGestures-Qt6/private/candidateinactivitytimer_p.h>
36 #else
37 #include <LomiriGestures/private/candidateinactivitytimer_p.h>cxx . . $ `<file>/include/LomiriGestures/5.5.0/LomiriGestures/private/candidateinactivitytimer_p.h`/
38 #endif
39 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
40 #include <LomiriGestures-Qt6/private/timer_p.h>
41 #else
42 #include <LomiriGestures/private/timer_p.h>cxx . . $ `<file>/include/LomiriGestures/5.5.0/LomiriGestures/private/timer_p.h`/
43 #endif
44 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
45 #include <LomiriGestures-Qt6/private/pool_p.h>
46 #else
47 #include <LomiriGestures/private/pool_p.h>cxx . . $ `<file>/include/LomiriGestures/5.5.0/LomiriGestures/private/pool_p.h`/
48 #endif
49
50 UG_FORWARD_DECLARE_CLASScxx . . $ AbstractTimerFactory#(AbstractTimerFactory)
51
52 /*
53 Where the ownership of touches is registered.
54
55 Singleton used for adding a touch point ownership model analogous to the one
56 described in the XInput 2.2 protocol[1] on top of the existing input dispatch logic in QQuickWindow.
57
58 It provides a much more flexible and powerful way of dealing with pointer ownership than the existing
59 mechanisms in Qt. Namely QQuickItem::grabTouchPoints, QuickItem::keepTouchGrab,
60 QQuickItem::setFiltersChildMouseEvents, QQuickItem::ungrabTouchPoints and QQuickItem::touchUngrabEvent.
61
62 Usage:
63
64 1- An item receives a a new touch point. If he's not sure whether he wants it yet, he calls:
65 TouchRegistry::instance()->addCandidateOwnerForTouch(touchId, this);
66 touchEvent->ignore();
67 Ignoring the event is crucial so that it can be seen by other interested parties, which will
68 behave similarly.
69
70 2- That item will then start receiving UnownedTouchEvents for that touch from step 1. Once he's
71 made a decision he calls either:
72 TouchRegistry::instance()->requestTouchOwnership(touchId, this);
73 If he wants the touch point or:
74 TouchRegistry::instance()->removeCandidateOwnerForTouch(touchId, this);
75 if he does not want it.
76
77 Candidates are put in a priority queue. The first one to call addCandidateOwnerForTouch() will
78 take precedence over the others for receiving ownership over the touch point (from now on called
79 simply top-candidate).
80
81 If the top-candidate calls requestTouchOwnership() he will immediately receive a
82 TouchOwnershipEvent(gained=true) for that touch point. He can then safely call
83 QQuickItem::grabTouchPoints to actually get the owned touch points. The other candidates
84 will receive TouchOwnershipEvent(gained=false) and will no longer receive UnownedTouchEvents
85 for that touch point. They will have to undo whatever action they were performing with that
86 touch point.
87
88 But if the top-candidate calls removeCandidateOwnerForTouch() instead, he's popped from the
89 candidacy queue and ownership is given to the new top-most candidate if he has already
90 made his decision, that is.
91
92 The TouchRegistry cannot enforce the results of this pointer ownership negotiation (i.e.,
93 who gets to grab the touch points) as that would clash with QQuickWindow's input event
94 dispatching logic. The candidates have to respect the decision and grab the touch points
95 themselves.
96
97 If an item wants ownership over touches as soon as he receives the TouchBegin for them, his step 1
98 would be instead:
99 TouchRegistry::instance()->requestTouchOwnership(touchId, this);
100 touchEvent->accept();
101 He won't get any UnownedTouchEvent for that touch as he is already the interim owner (ie, QQuickWindow
102 will keep sending touch updates to him already). Eventually he will be notified once ownership has
103 been granted to him (from TouchRegistry perspective), from which point onwards he could safely assume
104 other TouchRegistry users wouldn't snatch this touch away from him.
105
106 Items oblivious to TouchRegistry will lose their touch points without warning, just like in plain Qt.
107
108 [1] - http://www.x.org/releases/X11R7.7/doc/inputproto/XI2proto.txt (see multitouch-ownership)
109 */
110
111 UG_NAMESPACE_BEGINcxx . . $ `src/LomiriGestures/lomirigesturesglobal.h:30:9`!
112
113 class LOMIRIGESTURES_EXPORTcxx . . $ `src/LomiriGestures/lomirigesturesglobal.h:25:11`! TouchRegistrycxx . . $ LomiriGestures/TouchRegistry# : public QObjectcxx . . $ QObject#
114 {
115 Q_OBJECTcxx . . $ QMetaObject#Call#
116 public:
117 virtual ~cxx . . $ LomiriGestures/TouchRegistry#`~TouchRegistry`(49f6e7a06ebc5aa8).TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#();
118
119 // Returns a pointer to the application's TouchRegistry instance.
120 static TouchRegistrycxx . . $ LomiriGestures/TouchRegistry# *instancecxx . . $ LomiriGestures/TouchRegistry#instance(644997df756d5d7e).();
121
122 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
123 void update(QTouchEvent *event);
124 #else
125 void updatecxx . . $ LomiriGestures/TouchRegistry#update(113de7f4948514a0).(const QTouchEventcxx . . $ QTouchEvent# *event);
126 #endif
127
128 // Calls update() if the given event is a QTouchEvent
129 bool eventFiltercxx . . $ LomiriGestures/TouchRegistry#eventFilter(978aa4af1d030efa).(QObjectcxx . . $ QObject# *watched, QEventcxx . . $ QEvent# *event) override;
130
131 // An item that might later request ownership over the given touch point.
132 // He will be kept informed about that touch point through UnownedTouchEvents
133 // All candidates must eventually decide whether they want to own the touch point
134 // or not. That decision is informed through requestTouchOwnership() or
135 // removeCandidateOwnerForTouch()
136 void addCandidateOwnerForTouchcxx . . $ LomiriGestures/TouchRegistry#addCandidateOwnerForTouch(1dd929642e598acc).(int id, QQuickItemcxx . . $ QQuickItem# *candidate);
137
138 // The same as rejecting ownership of a touch
139 void removeCandidateOwnerForTouchcxx . . $ LomiriGestures/TouchRegistry#removeCandidateOwnerForTouch(1dd929642e598acc).(int id, QQuickItemcxx . . $ QQuickItem# *candidate);
140
141 // The candidate object wants to be the owner of the touch with the given id.
142 // If he's currently the oldest/top-most candidate, he will get an ownership
143 // event immediately. If not, he will get ownership if (or once) he becomes the
144 // top-most candidate.
145 void requestTouchOwnershipcxx . . $ LomiriGestures/TouchRegistry#requestTouchOwnership(1dd929642e598acc).(int id, QQuickItemcxx . . $ QQuickItem# *candidate);
146
147 // An item that has no interest (effective or potential) in owning a touch point
148 // but would nonetheless like to be kept up-to-date on its state.
149 void addTouchWatchercxx . . $ LomiriGestures/TouchRegistry#addTouchWatcher(1dd929642e598acc).(int touchId, QQuickItemcxx . . $ QQuickItem# *watcherItem);
150
151 // Useful for tests, where you should use fake timers
152 void setTimerFactorycxx . . $ LomiriGestures/TouchRegistry#setTimerFactory(6294414dca231b3a).(AbstractTimerFactorycxx . . $ LomiriGestures/AbstractTimerFactory# *timerFactory);
153
154 private Q_SLOTScxx . . $ `<external>/1208926524888476972/qobjectdefs.h:92:10`!:
155 void rejectCandidateOwnerForTouchcxx . . $ LomiriGestures/TouchRegistry#rejectCandidateOwnerForTouch(1dd929642e598acc).(int id, QQuickItemcxx . . $ QQuickItem# *candidate);
156
157 private:
158 // Only instance() can cronstruct one
159 TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#TouchRegistry(749de1b6ae65bddd).(QObjectcxx . . $ QObject# *parent = nullptr);
160
161 class CandidateInfocxx . . $ LomiriGestures/TouchRegistry#CandidateInfo# {
162 public:
163 enumcxx . . $ LomiriGestures/TouchRegistry#CandidateInfo#$anonymous_type_0# {
164 // A candidate owner that doesn't yet know for sure whether he wants the touch point
165 // (gesture recognition is stilll going on)
166 Undecidedcxx . . $ LomiriGestures/TouchRegistry#CandidateInfo#Undecided. = 0,
167 // A candidate owner that wants the touch but hasn't been granted it yet,
168 // most likely because there's an undecided candidate with higher priority
169 Requestedcxx . . $ LomiriGestures/TouchRegistry#CandidateInfo#Requested. = 1,
170 // An item that is the interim owner of the touch, receiving QTouchEvents of it
171 // from QQuickWindow. Ie, it's the actual touch owner from Qt's point of view.
172 // It wants to keep its touch ownership but hasn't been granted it by TouchRegistry
173 // yet because of undecided candidates higher up.
174 InterimOwnercxx . . $ LomiriGestures/TouchRegistry#CandidateInfo#InterimOwner. = 2
175 } statecxx . . $ LomiriGestures/TouchRegistry#CandidateInfo#state.;
176 QPointercxx . . $ QPointer#<QQuickItemcxx . . $ QQuickItem#> itemcxx . . $ LomiriGestures/TouchRegistry#CandidateInfo#item.;
177 QPointercxx . . $ QPointer#<UG_PREPEND_NAMESPACEcxx . . $ LomiriGestures/(CandidateInactivityTimer)> inactivityTimercxx . . $ LomiriGestures/TouchRegistry#CandidateInfo#inactivityTimer.;
178 };
179
180 class TouchInfocxx . . $ LomiriGestures/TouchRegistry#TouchInfo# {
181 public:
182 TouchInfocxx . . $ LomiriGestures/TouchRegistry#TouchInfo#TouchInfo(49f6e7a06ebc5aa8).() : idcxx . . $ LomiriGestures/TouchRegistry#TouchInfo#id.(-1), physicallyEndedcxx . . $ LomiriGestures/TouchRegistry#TouchInfo#physicallyEnded.(false) {}
183 TouchInfocxx . . $ LomiriGestures/TouchRegistry#TouchInfo#TouchInfo(d4f767463ce0a6b3).(int id);
184 bool isValidcxx . . $ LomiriGestures/TouchRegistry#TouchInfo#isValid(50ce9a9e25b4a850).() const { return idcxx . . $ LomiriGestures/TouchRegistry#TouchInfo#id. >= 0; }
185 void resetcxx . . $ LomiriGestures/TouchRegistry#TouchInfo#reset(49f6e7a06ebc5aa8).();
186 void initcxx . . $ LomiriGestures/TouchRegistry#TouchInfo#init(d4f767463ce0a6b3).(int id);
187 int idcxx . . $ LomiriGestures/TouchRegistry#TouchInfo#id.;
188 bool physicallyEndedcxx . . $ LomiriGestures/TouchRegistry#TouchInfo#physicallyEnded.;
189 bool isOwnedcxx . . $ LomiriGestures/TouchRegistry#TouchInfo#isOwned(50ce9a9e25b4a850).() const;
190 bool endedcxx . . $ LomiriGestures/TouchRegistry#TouchInfo#ended(50ce9a9e25b4a850).() const;
191 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
192 void notifyCandidatesOfOwnershipResolution(QPointerEvent *pointerEvent,
193 const QEventPoint *point);
194 #else
195 void notifyCandidatesOfOwnershipResolutioncxx . . $ LomiriGestures/TouchRegistry#TouchInfo#notifyCandidatesOfOwnershipResolution(49f6e7a06ebc5aa8).();
196 #endif
197
198 // TODO optimize storage (s/QList/Pool)
199 QListcxx . . $ QList#<CandidateInfocxx . . $ LomiriGestures/TouchRegistry#CandidateInfo#> candidatescxx . . $ LomiriGestures/TouchRegistry#TouchInfo#candidates.;
200 QListcxx . . $ QList#<QPointercxx . . $ QPointer#<QQuickItemcxx . . $ QQuickItem#>> watcherscxx . . $ LomiriGestures/TouchRegistry#TouchInfo#watchers.;
201 };
202
203 void pruneNullCandidatesForTouchcxx . . $ LomiriGestures/TouchRegistry#pruneNullCandidatesForTouch(d4f767463ce0a6b3).(int touchId);
204 void removeCandidateOwnerForTouchByIndexcxx . . $ LomiriGestures/TouchRegistry#removeCandidateOwnerForTouchByIndex(3108d22d6d7c43ca).(Poolcxx . . $ Pool#<TouchInfo>::Iteratorcxx . . $ Pool#Iterator# &touchInfo, int candidateIndex);
205 void removeCandidateHelpercxx . . $ LomiriGestures/TouchRegistry#removeCandidateHelper(3108d22d6d7c43ca).(Poolcxx . . $ Pool#<TouchInfo>::Iteratorcxx . . $ Pool#Iterator# &touchInfo, int candidateIndex);
206
207 Poolcxx . . $ Pool#<TouchInfo>::Iteratorcxx . . $ Pool#Iterator# findTouchInfocxx . . $ LomiriGestures/TouchRegistry#findTouchInfo(7864480464b09eea).(int id);
208
209 void deliverTouchUpdatesToUndecidedCandidatesAndWatcherscxx . . $ LomiriGestures/TouchRegistry#deliverTouchUpdatesToUndecidedCandidatesAndWatchers(113de7f4948514a0).(const QTouchEventcxx . . $ QTouchEvent# *event);
210
211 static void translateTouchPointFromScreenToWindowCoordscxx . . $ LomiriGestures/TouchRegistry#translateTouchPointFromScreenToWindowCoords(661675b14117eae0).(QTouchEventcxx . . $ QTouchEvent#::TouchPointcxx . . $ QTouchEvent#TouchPoint# &touchPoint);
212
213 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
214 void dispatchPointsToItem(const QTouchEvent *event, const QList<int> &touchIds,
215 QQuickItem *item);
216 #else
217 static void dispatchPointsToItemcxx . . $ LomiriGestures/TouchRegistry#dispatchPointsToItem(10b350cc33ed59cf).(const QTouchEventcxx . . $ QTouchEvent# *event, const QListcxx . . $ QList#<int> &touchIds,
218 QQuickItemcxx . . $ QQuickItem# *item);
219 #endif
220 void freeEndedTouchInfoscxx . . $ LomiriGestures/TouchRegistry#freeEndedTouchInfos(49f6e7a06ebc5aa8).();
221
222 Poolcxx . . $ Pool#<TouchInfocxx . . $ LomiriGestures/TouchRegistry#TouchInfo#> m_touchInfoPoolcxx . . $ LomiriGestures/TouchRegistry#m_touchInfoPool.;
223
224 // the singleton instance
225 static TouchRegistrycxx . . $ LomiriGestures/TouchRegistry# *m_instancecxx . . $ LomiriGestures/TouchRegistry#m_instance.;
226
227 bool m_inDispatchLoopcxx . . $ LomiriGestures/TouchRegistry#m_inDispatchLoop.;
228
229 AbstractTimerFactorycxx . . $ LomiriGestures/AbstractTimerFactory# *m_timerFactorycxx . . $ LomiriGestures/TouchRegistry#m_timerFactory.;
230
231 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
232 QList<QPointerEvent *> m_eventsInDelivery;
233
234 std::pair<QPointerEvent *, const QEventPoint *>
235 findMostRelavantEventForId(int id, QQuickItem *item);
236 #endif
237
238 friend class tst_TouchRegistrycxx . . $ LomiriGestures/tst_TouchRegistry#;
239 friend class tst_DirectionalDragAreacxx . . $ LomiriGestures/tst_DirectionalDragArea#;
240 };
241
242 UG_NAMESPACE_ENDcxx . . $ `src/LomiriGestures/lomirigesturesglobal.h:31:9`!
243
244 Q_DECLARE_LOGGING_CATEGORYcxx . . $ `<external>/13903568758641964362/qloggingcategory.h:111:9`!(ugTouchRegistry)
245
246 #endif // TOUCHREGISTRY_P_H