Debian Codegraph @

src/LomiriGestures/touchregistry.cpp

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 #include "touchregistry_p.h"cxx . . $ `<file>/src/LomiriGestures/touchregistry_p.h`/
18
19 #include <QtCore/QCoreApplication>
20 #include <QtCore/QDebug>
21 #include <QtQuick/private/qquickitem_p.h>
22 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
23 #include <private/qeventpoint_p.h>
24 #endif
25
26 #include "candidateinactivitytimer_p.h"cxx . . $ `<file>/src/LomiriGestures/candidateinactivitytimer_p.h`/
27 #include "timer_p.h"cxx . . $ `<file>/src/LomiriGestures/timer_p.h`/
28 #include "touchownershipevent_p.h"cxx . . $ `<file>/src/LomiriGestures/touchownershipevent_p.h`/
29 #include "unownedtouchevent_p.h"cxx . . $ `<file>/src/LomiriGestures/unownedtouchevent_p.h`/
30
31 Q_LOGGING_CATEGORYcxx . . $ `<external>/13903568758641964362/qloggingcategory.h:114:9`!(ugTouchRegistry, "liblomirigestures.TouchRegistry", QtMsgType::QtWarningMsg)
32
33 #define UG_DEBUGcxx . . $ `src/LomiriGestures/touchregistry.cpp:33:9`! qCDebugcxx . . $ `<external>/13903568758641964362/qloggingcategory.h:122:11`!(ugTouchRegistry) << "[TouchRegistry]"
34
35 UG_NAMESPACE_BEGINcxx . . $ `src/LomiriGestures/lomirigesturesglobal.h:30:9`!
36
37 TouchRegistrycxx . . $ LomiriGestures/TouchRegistry# *TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::m_instancecxx . . $ LomiriGestures/TouchRegistry#m_instance. = nullptr;
38
39 TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#TouchRegistry(749de1b6ae65bddd).(QObjectcxx . . $ QObject# *parent)
40 : QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(parent)
41 , m_inDispatchLoopcxx . . $ LomiriGestures/TouchRegistry#m_inDispatchLoop.(false)
42 , m_timerFactorycxx . . $ LomiriGestures/TouchRegistry#m_timerFactory.(new TimerFactorycxx . . $ LomiriGestures/TimerFactory#)
43 {
44 }
45
46 TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::~cxx . . $ LomiriGestures/TouchRegistry#`~TouchRegistry`(ced63f7c635d850d).TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#()
47 {
48 Q_ASSERTcxx . . $ `<external>/15045578679651060896/qglobal.h:859:13`!(m_instance != nullptr);
49 m_instancecxx . . $ LomiriGestures/TouchRegistry#m_instance. = nullptr;
50 delete m_timerFactorycxx . . $ LomiriGestures/TouchRegistry#m_timerFactory.;
51 }
52
53 TouchRegistrycxx . . $ LomiriGestures/TouchRegistry# *TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::instancecxx . . $ LomiriGestures/TouchRegistry#instance(644997df756d5d7e).()
54 {
55 if (m_instancecxx . . $ LomiriGestures/TouchRegistry#m_instance. == nullptr) {
56 m_instancecxx . . $ LomiriGestures/TouchRegistry#m_instance. = new TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#;
57 }
58 return m_instancecxx . . $ LomiriGestures/TouchRegistry#m_instance.;
59 }
60
61 void TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::setTimerFactorycxx . . $ LomiriGestures/TouchRegistry#setTimerFactory(6294414dca231b3a).(AbstractTimerFactorycxx . . $ LomiriGestures/AbstractTimerFactory# *timerFactory)
62 {
63 delete m_timerFactorycxx . . $ LomiriGestures/TouchRegistry#m_timerFactory.;
64 m_timerFactorycxx . . $ LomiriGestures/TouchRegistry#m_timerFactory. = timerFactory;
65 }
66
67 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
68 void TouchRegistry::update(QTouchEvent *event)
69 #else
70 void TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::updatecxx . . $ LomiriGestures/TouchRegistry#update(113de7f4948514a0).(const QTouchEventcxx . . $ QTouchEvent# *event)
71 #endif
72 {
73 UG_DEBUGcxx . . $ `src/LomiriGestures/touchregistry.cpp:33:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "got" <<cxx . . $ QDebug#`operator<<`(4f783e5a5d632c7c). event;
74
75 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
76 m_eventsInDelivery.append(event);
77 #endif
78
79 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
80 const QList<QTouchEvent::TouchPoint> &touchPoints = event->points();
81 #else
82 const QListcxx . . $ QList#<QTouchEventcxx . . $ QTouchEvent#::TouchPointcxx . . $ QTouchEvent#TouchPoint#> &touchPoints = event->touchPointscxx . . $ QTouchEvent#touchPoints(ab2597e7c7c2418b).();
83 #endif
84 for (int i = 0; i <cxx . . $ `operator<`(945cec9d77892c2f). touchPoints.count(); ++i) {
85 const QTouchEventcxx . . $ QTouchEvent#::TouchPointcxx . . $ QTouchEvent#TouchPoint# &touchPoint = touchPoints.at(i);
86 if (touchPoint.statecxx . . $ QTouchEvent#TouchPoint#state(376f2e065f4f14a6).() == Qtcxx . . $ Qt/::TouchPointPressedcxx . . $ Qt/TouchPointPressed.) {
87 TouchInfocxx . . $ LomiriGestures/TouchRegistry#TouchInfo# &touchInfo = m_touchInfoPool.getEmptySlot();
88 touchInfo.initcxx . . $ LomiriGestures/TouchRegistry#TouchInfo#init(d4f767463ce0a6b3).(touchPoint.idcxx . . $ QTouchEvent#TouchPoint#id(455f465bc33b4cdf).());
89 } else if (touchPoint.statecxx . . $ QTouchEvent#TouchPoint#state(376f2e065f4f14a6).() == Qtcxx . . $ Qt/::TouchPointReleasedcxx . . $ Qt/TouchPointReleased.) {
90 Pool<TouchInfo>::Iterator touchInfo = findTouchInfo(touchPoint.id());
91 if (!touchInfo) {
92 // Possibly an early touch before our eventFilter is installed.
93 continue;
94 }
95
96 touchInfo->physicallyEnded = true;
97 }
98 }
99
100 deliverTouchUpdatesToUndecidedCandidatesAndWatcherscxx . . $ LomiriGestures/TouchRegistry#deliverTouchUpdatesToUndecidedCandidatesAndWatchers(113de7f4948514a0).(event);
101
102 freeEndedTouchInfoscxx . . $ LomiriGestures/TouchRegistry#freeEndedTouchInfos(49f6e7a06ebc5aa8).();
103
104 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
105 m_eventsInDelivery.takeLast();
106 #endif
107 }
108
109 void TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::deliverTouchUpdatesToUndecidedCandidatesAndWatcherscxx . . $ LomiriGestures/TouchRegistry#deliverTouchUpdatesToUndecidedCandidatesAndWatchers(113de7f4948514a0).(const QTouchEventcxx . . $ QTouchEvent# *event)
110 {
111 // TODO: Look into how we could optimize this whole thing.
112 // Although it's not really a problem as we should have at most two candidates
113 // for each point and there should not be many active points at any given moment.
114 // But having three nested for-loops does scare.
115
116 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
117 const QList<QTouchEvent::TouchPoint> &updatedTouchPoints = event->points();
118 #else
119 const QListcxx . . $ QList#<QTouchEventcxx . . $ QTouchEvent#::TouchPointcxx . . $ QTouchEvent#TouchPoint#> &updatedTouchPoints = event->touchPointscxx . . $ QTouchEvent#touchPoints(ab2597e7c7c2418b).();
120 #endif
121 // Maps an item to the touches in this event he should be informed about.
122 // E.g.: a QTouchEvent might have three touches but a given item might be interested in only
123 // one of them. So he will get a UnownedTouchEvent from this QTouchEvent containing only that
124 // touch point.
125 QHashcxx . . $ QHash#<QQuickItemcxx . . $ QQuickItem#*, QListcxx . . $ QList#<int>> touchIdsForItems;
126
127 // Build touchIdsForItems
128 m_touchInfoPool.forEach([&](Pool<TouchInfo>::Iterator &touchInfo) {
129 if (touchInfo->isOwned() && touchInfo->watchers.isEmpty())
130 return true;
131
132 for (int j = 0; j < updatedTouchPoints.count(); ++j) {
133 if (updatedTouchPoints[j].id() == touchInfo->id) {
134 if (!touchInfo->isOwned()) {
135 for (int i = 0; i < touchInfo->candidates.count(); ++i) {
136 CandidateInfo &candidate = touchInfo->candidates[i];
137 Q_ASSERTcxx . . $ `<external>/15045578679651060896/qglobal.h:859:13`!(!candidate.item.isNull());
138 if (candidate.state != CandidateInfo::InterimOwner) {
139 touchIdsForItems[candidate.item.data()].append(touchInfo->id);
140 }
141 }
142 }
143
144 const QList<QPointer<QQuickItem>> &watchers = touchInfo->watchers;
145 for (int i = 0; i < watchers.count(); ++i) {
146 if (!watchers[i].isNull()) {
147 touchIdsForItems[watchers[i].data()].append(touchInfo->id);
148 }
149 }
150
151 return true;
152 }
153 }
154
155 return true;
156 });
157
158 // TODO: Consider what happens if an item calls any of TouchRegistry's public methods
159 // from the event handler callback.
160 m_inDispatchLoopcxx . . $ LomiriGestures/TouchRegistry#m_inDispatchLoop. = true;
161 auto it = touchIdsForItems.constBegin();
162 while (it !=cxx . . $ `operator!=`(d35e8b31fb5dfd9b). touchIdsForItems.constEnd()) {
163 QQuickItemcxx . . $ QQuickItem# *item = it.key();
164 const QListcxx . . $ QList#<int> &touchIds = it.value();
165 dispatchPointsToItemcxx . . $ LomiriGestures/TouchRegistry#dispatchPointsToItem(10b350cc33ed59cf).(event, touchIds, item);
166 ++it;
167 };
168 m_inDispatchLoopcxx . . $ LomiriGestures/TouchRegistry#m_inDispatchLoop. = false;
169 }
170
171 void TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::freeEndedTouchInfoscxx . . $ LomiriGestures/TouchRegistry#freeEndedTouchInfos(49f6e7a06ebc5aa8).()
172 {
173 m_touchInfoPool.forEach([&](Pool<TouchInfo>::Iterator &touchInfo) {
174 if (touchInfo->ended()) {
175 m_touchInfoPool.freeSlot(touchInfo);
176 }
177 return true;
178 });
179 }
180
181 /*
182 Extracts the touches with the given touchIds from event and send them in a
183 UnownedTouchEvent to the given item
184 */
185 void TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::dispatchPointsToItemcxx . . $ LomiriGestures/TouchRegistry#dispatchPointsToItem(10b350cc33ed59cf).(const QTouchEventcxx . . $ QTouchEvent# *event, const QListcxx . . $ QList#<int> &touchIds,
186 QQuickItemcxx . . $ QQuickItem# *item)
187 {
188 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! < QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
189 Qtcxx . . $ Qt/::TouchPointStatescxx . . $ Qt/TouchPointStates# touchPointStates;
190 #endif
191 QListcxx . . $ QList#<QTouchEventcxx . . $ QTouchEvent#::TouchPointcxx . . $ QTouchEvent#TouchPoint#> touchPoints;
192
193 const QListcxx . . $ QList#<QTouchEventcxx . . $ QTouchEvent#::TouchPointcxx . . $ QTouchEvent#TouchPoint#> &allTouchPoints = event->touchPointscxx . . $ QTouchEvent#touchPoints(ab2597e7c7c2418b).();
194
195 QTransformcxx . . $ QTransform# windowToCandidateTransform = QQuickItemPrivatecxx . . $ QQuickItemPrivate#::getcxx . . $ QQuickItemPrivate#get(e67074e0a8812cda).(item)->windowToItemTransformcxx . . $ QQuickItemPrivate#windowToItemTransform(89b51d5baeafd349).();
196 QMatrix4x4cxx . . $ QMatrix4x4# windowToCandidateMatrixcxx . . $ QMatrix4x4#QMatrix4x4(cf78037186126e54).(windowToCandidateTransform);
197
198 for (int i = 0; i <cxx . . $ `operator<`(945cec9d77892c2f). allTouchPoints.count(); ++i) {
199 const QTouchEventcxx . . $ QTouchEvent#::TouchPointcxx . . $ QTouchEvent#TouchPoint# &originalTouchPoint = allTouchPoints[i];
200 if (touchIds.contains(originalTouchPoint.idcxx . . $ QTouchEvent#TouchPoint#id(455f465bc33b4cdf).())) {
201 QTouchEventcxx . . $ QTouchEvent#::TouchPointcxx . . $ QTouchEvent#TouchPoint# touchPoint = originalTouchPointcxx . . $ QTouchEvent#TouchPoint#TouchPoint(89aabad56e6271a1).;
202 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
203 QMutableEventPoint::detach(touchPoint);
204 #endif
205
206 translateTouchPointFromScreenToWindowCoordscxx . . $ LomiriGestures/TouchRegistry#translateTouchPointFromScreenToWindowCoords(661675b14117eae0).(touchPoint);
207
208 // Set the point's local coordinates to that of the item
209 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
210 QMutableEventPoint::setPosition(touchPoint, windowToCandidateTransform.map(touchPoint.scenePos()));
211 #else
212 touchPoint.setPoscxx . . $ QTouchEvent#TouchPoint#setPos(4258778b894f8bb6).(windowToCandidateTransform.mapcxx . . $ QTransform#map(d99487573c8c6d6c).(touchPoint.scenePoscxx . . $ QTouchEvent#TouchPoint#scenePos(a5b3784bf6777acb).()));
213 #endif
214
215 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
216 QMutableEventPoint::setGlobalPressPosition(touchPoint, windowToCandidateTransform.map(touchPoint.pressPosition()));
217 QMutableEventPoint::setGlobalLastPosition(touchPoint, windowToCandidateTransform.map(touchPoint.lastPosition()));
218 QMutableEventPoint::setVelocity(touchPoint, windowToCandidateMatrix.mapVector(touchPoint.velocity().toVector3D()).toVector2D());
219 #else
220
221 touchPoint.setStartPoscxx . . $ QTouchEvent#TouchPoint#setStartPos(4258778b894f8bb6).(windowToCandidateTransform.mapcxx . . $ QTransform#map(d99487573c8c6d6c).(touchPoint.startScenePoscxx . . $ QTouchEvent#TouchPoint#startScenePos(a5b3784bf6777acb).()));
222 touchPoint.setLastPoscxx . . $ QTouchEvent#TouchPoint#setLastPos(4258778b894f8bb6).(windowToCandidateTransform.mapcxx . . $ QTransform#map(d99487573c8c6d6c).(touchPoint.lastScenePoscxx . . $ QTouchEvent#TouchPoint#lastScenePos(a5b3784bf6777acb).()));
223 touchPoint.setVelocitycxx . . $ QTouchEvent#TouchPoint#setVelocity(b3dd5520347dc555).(windowToCandidateMatrix.mapVectorcxx . . $ QMatrix4x4#mapVector(3633f0023a5294a2).(touchPointcxx . . $ QVector3D#QVector3D(b3dd5520347dc555)..velocitycxx . . $ QTouchEvent#TouchPoint#velocity(fe8156ea8904509c).()).toVector2Dcxx . . $ QVector3D#toVector2D(fe8156ea8904509c).());
224 #endif
225 touchPoints.append(touchPoint);
226 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! < QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
227 touchPointStates |=cxx . . $ `operator|=`(6d65a53d6912906f). touchPoint.statecxx . . $ QTouchEvent#TouchPoint#state(376f2e065f4f14a6).();
228 #endif
229 }
230 }
231
232 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
233 QTouchEvent *eventForItem = new QTouchEvent(event->type(),
234 event->pointingDevice(),
235 event->modifiers(),
236 touchPoints);
237
238 eventForItem->setTimestamp(event->timestamp());
239 QMutableTouchEvent::setTarget(eventForItem, event->target());
240 // window() is moved to QEventPoint.
241 #else
242 QTouchEventcxx . . $ QTouchEvent# *eventForItem = new QTouchEventcxx . . $ QTouchEvent#(event->typecxx . . $ QEvent#type(916a8de57f4d422b).(),
243 event->devicecxx . . $ QTouchEvent#device(94b99c182f8f7074).(),
244 event->modifiers(),
245 touchPointStates,
246 touchPoints);
247 eventForItem->setWindowcxx . . $ QTouchEvent#setWindow(35681b993d9a3c79).(event->windowcxx . . $ QTouchEvent#window(d520c9a5ccf200dd).());
248 eventForItem->setTimestampcxx . . $ QInputEvent#setTimestamp(2c44cd906ae4e829).(event->timestampcxx . . $ QInputEvent#timestamp(fe4d2d262d4164a8).());
249 eventForItem->setTargetcxx . . $ QTouchEvent#setTarget(749de1b6ae65bddd).(event->targetcxx . . $ QTouchEvent#target(2dbb680a34285c44).());
250 #endif
251
252 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
253 m_eventsInDelivery.append(eventForItem);
254 #endif
255
256 UnownedTouchEventcxx . . $ LomiriGestures/UnownedTouchEvent# unownedTouchEventcxx . . $ LomiriGestures/UnownedTouchEvent#UnownedTouchEvent(3088690d2ec9a7bd).(eventForItem);
257
258 UG_DEBUGcxx . . $ `src/LomiriGestures/touchregistry.cpp:33:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Sending unowned" <<cxx . . $ QDebug#`operator<<`(4f783e5a5d632c7c). eventForItem
259 <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "to" <<cxx . . $ `operator<<`(8519bbeb1a57acf3). item;
260
261 QCoreApplicationcxx . . $ QCoreApplication#::sendEventcxx . . $ QCoreApplication#sendEvent(978aa4af1d030efa).(item, &unownedTouchEvent);
262
263 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
264 m_eventsInDelivery.takeLast();
265 #endif
266 // `eventForItem` is freed by `unownedTouchEvent`.
267 }
268
269 void TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::translateTouchPointFromScreenToWindowCoordscxx . . $ LomiriGestures/TouchRegistry#translateTouchPointFromScreenToWindowCoords(661675b14117eae0).(QTouchEventcxx . . $ QTouchEvent#::TouchPointcxx . . $ QTouchEvent#TouchPoint# &touchPoint)
270 {
271 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
272 QMutableEventPoint::setGlobalPosition(touchPoint, touchPoint.scenePosition());
273 QMutableEventPoint::setGlobalPressPosition(touchPoint, touchPoint.scenePressPosition());
274 QMutableEventPoint::setGlobalLastPosition(touchPoint, touchPoint.sceneLastPosition());
275
276 QMutableEventPoint::setScenePosition(touchPoint, touchPoint.position());
277 // Qt 6 now calculates scene{Press,Last}Position from global{Press,Last}Position,
278 // globalPosition, and scenePosition.
279 #else
280 touchPoint.setScreenPoscxx . . $ QTouchEvent#TouchPoint#setScreenPos(4258778b894f8bb6).(touchPoint.scenePoscxx . . $ QTouchEvent#TouchPoint#scenePos(a5b3784bf6777acb).());
281 touchPoint.setStartScreenPoscxx . . $ QTouchEvent#TouchPoint#setStartScreenPos(4258778b894f8bb6).(touchPoint.startScenePoscxx . . $ QTouchEvent#TouchPoint#startScenePos(a5b3784bf6777acb).());
282 touchPoint.setLastScreenPoscxx . . $ QTouchEvent#TouchPoint#setLastScreenPos(4258778b894f8bb6).(touchPoint.lastScenePoscxx . . $ QTouchEvent#TouchPoint#lastScenePos(a5b3784bf6777acb).());
283
284 touchPoint.setScenePoscxx . . $ QTouchEvent#TouchPoint#setScenePos(4258778b894f8bb6).(touchPoint.poscxx . . $ QTouchEvent#TouchPoint#pos(a5b3784bf6777acb).());
285 touchPoint.setStartScenePoscxx . . $ QTouchEvent#TouchPoint#setStartScenePos(4258778b894f8bb6).(touchPoint.startPoscxx . . $ QTouchEvent#TouchPoint#startPos(a5b3784bf6777acb).());
286 touchPoint.setLastScenePoscxx . . $ QTouchEvent#TouchPoint#setLastScenePos(4258778b894f8bb6).(touchPoint.lastPoscxx . . $ QTouchEvent#TouchPoint#lastPos(a5b3784bf6777acb).());
287 #endif
288 }
289
290 bool TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::eventFiltercxx . . $ LomiriGestures/TouchRegistry#eventFilter(978aa4af1d030efa).(QObjectcxx . . $ QObject# *watched, QEventcxx . . $ QEvent# *event)
291 {
292 Q_UNUSEDcxx . . $ `<external>/15045578679651060896/qglobal.h:117:9`!(watched);
293
294 switch (event->typecxx . . $ QEvent#type(916a8de57f4d422b).()) {
295 case QEventcxx . . $ QEvent#::TouchBegincxx . . $ QEvent#TouchBegin.:
296 case QEventcxx . . $ QEvent#::TouchUpdatecxx . . $ QEvent#TouchUpdate.:
297 case QEventcxx . . $ QEvent#::TouchEndcxx . . $ QEvent#TouchEnd.:
298 case QEventcxx . . $ QEvent#::TouchCancelcxx . . $ QEvent#TouchCancel.:
299 updatecxx . . $ LomiriGestures/TouchRegistry#update(113de7f4948514a0).(static_cast<QTouchEvent*>(event));
300 break;
301 default:
302 // do nothing
303 break;
304 }
305
306 // Do not filter out the event. i.e., let it be handled further as
307 // we're just monitoring events
308 return false;
309 }
310
311 void TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::addCandidateOwnerForTouchcxx . . $ LomiriGestures/TouchRegistry#addCandidateOwnerForTouch(1dd929642e598acc).(int id, QQuickItemcxx . . $ QQuickItem# *candidate)
312 {
313 UG_DEBUGcxx . . $ `src/LomiriGestures/touchregistry.cpp:33:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "addCandidateOwnerForTouch id" <<cxx . . $ QDebug#`operator<<`(6e3b7ae53f380c3). id <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "candidate" <<cxx . . $ `operator<<`(8519bbeb1a57acf3). candidate;
314
315 Pool<TouchInfo>::Iterator touchInfo = findTouchInfo(id);
316 if (!touchInfo) {
317 qCriticalcxx . . $ `<external>/10450329605257866924/qlogging.h:167:9`!("TouchRegistry: Failed to find TouchInfo");
318 return;
319 }
320
321 if (touchInfo->isOwned()) {
322 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("TouchRegistry: trying to add candidate owner for a touch that's already owned");
323 return;
324 }
325
326 // TODO: Check if candidate already exists
327
328 CandidateInfocxx . . $ LomiriGestures/TouchRegistry#CandidateInfo# candidateInfo;
329 candidateInfo.statecxx . . $ LomiriGestures/TouchRegistry#CandidateInfo#state. = CandidateInfocxx . . $ LomiriGestures/TouchRegistry#CandidateInfo#::Undecidedcxx . . $ LomiriGestures/TouchRegistry#CandidateInfo#Undecided.;
330 candidateInfo.item = candidate;
331 candidateInfo.inactivityTimer = new CandidateInactivityTimer(id, candidate,
332 m_timerFactory->createTimer(),
333 this);
334 connectcxx . . $ QObject#connect(835f87066c895669).(candidateInfo.inactivityTimer.data(), &CandidateInactivityTimercxx . . $ LomiriGestures/CandidateInactivityTimer#::candidateDefaultedcxx . . $ LomiriGestures/CandidateInactivityTimer#candidateDefaulted(1dd929642e598acc).,
335 this, &TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::rejectCandidateOwnerForTouchcxx . . $ LomiriGestures/TouchRegistry#rejectCandidateOwnerForTouch(1dd929642e598acc).);
336
337 touchInfo->candidates.append(candidateInfo);
338
339 connectcxx . . $ QObject#connect(835f87066c895669).(candidate, &QObjectcxx . . $ QObject#::destroyedcxx . . $ QObject#destroyed(749de1b6ae65bddd)., this, [=](){ pruneNullCandidatesForTouchcxx . . $ LomiriGestures/TouchRegistry#pruneNullCandidatesForTouch(d4f767463ce0a6b3).(id); });
340 }
341
342 void TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::addTouchWatchercxx . . $ LomiriGestures/TouchRegistry#addTouchWatcher(1dd929642e598acc).(int touchId, QQuickItemcxx . . $ QQuickItem# *watcher)
343 {
344 UG_DEBUGcxx . . $ `src/LomiriGestures/touchregistry.cpp:33:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "addTouchWatcher id" <<cxx . . $ QDebug#`operator<<`(6e3b7ae53f380c3). touchId <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "watcher" <<cxx . . $ `operator<<`(8519bbeb1a57acf3). watcher;
345
346 Pool<TouchInfo>::Iterator touchInfo = findTouchInfo(touchId);
347 if (!touchInfo) {
348 qCriticalcxx . . $ `<external>/10450329605257866924/qlogging.h:167:9`!("TouchRegistry: Failed to find TouchInfo");
349 return;
350 }
351
352 // TODO: Check if watcher already exists
353
354 touchInfo->watchers.append(watcher);
355 }
356
357 void TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::removeCandidateOwnerForTouchcxx . . $ LomiriGestures/TouchRegistry#removeCandidateOwnerForTouch(1dd929642e598acc).(int id, QQuickItemcxx . . $ QQuickItem# *candidate)
358 {
359 UG_DEBUGcxx . . $ `src/LomiriGestures/touchregistry.cpp:33:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "removeCandidateOwnerForTouch id" <<cxx . . $ QDebug#`operator<<`(6e3b7ae53f380c3). id <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "candidate" <<cxx . . $ `operator<<`(8519bbeb1a57acf3). candidate;
360
361 Pool<TouchInfo>::Iterator touchInfo = findTouchInfo(id);
362 if (!touchInfo) {
363 qCriticalcxx . . $ `<external>/10450329605257866924/qlogging.h:167:9`!("TouchRegistry: Failed to find TouchInfo");
364 return;
365 }
366
367 // TODO: check if the candidate is in fact the owner of the touch
368
369 bool removed = false;
370 for (int i = 0; i < touchInfo->candidates.count() && !removed; ++i) {
371 if (touchInfo->candidates[i].item == candidate) {
372 removeCandidateOwnerForTouchByIndex(touchInfo, i);
373 removed = true;
374 }
375 }
376 }
377
378 void TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::pruneNullCandidatesForTouchcxx . . $ LomiriGestures/TouchRegistry#pruneNullCandidatesForTouch(d4f767463ce0a6b3).(int touchId)
379 {
380 UG_DEBUGcxx . . $ `src/LomiriGestures/touchregistry.cpp:33:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "pruneNullCandidatesForTouch touchId" <<cxx . . $ QDebug#`operator<<`(6e3b7ae53f380c3). touchId;
381
382 Pool<TouchInfo>::Iterator touchInfo = findTouchInfo(touchId);
383 if (!touchInfo) {
384 // doesn't matter as touch is already gone.
385 return;
386 }
387
388 int i = 0;
389 while (i < touchInfo->candidates.count()) {
390 if (touchInfo->candidates[i].item.isNull()) {
391 removeCandidateOwnerForTouchByIndex(touchInfo, i);
392 } else {
393 ++i;
394 }
395 }
396 }
397
398 void TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::removeCandidateOwnerForTouchByIndexcxx . . $ LomiriGestures/TouchRegistry#removeCandidateOwnerForTouchByIndex(3108d22d6d7c43ca).(Pool<TouchRegistry::TouchInfo>::Iterator &touchInfo,
399 int candidateIndex)
400 {
401 // TODO: check if the candidate is in fact the owner of the touch
402
403 Q_ASSERTcxx . . $ `<external>/15045578679651060896/qglobal.h:859:13`!(candidateIndex < touchInfo->candidates.count());
404
405 if (candidateIndex == 0 && touchInfo->candidates[candidateIndex].state !=cxx . . $ `operator!=`(d35e8b31fb5dfd9b). CandidateInfocxx . . $ LomiriGestures/TouchRegistry#CandidateInfo#::Undecidedcxx . . $ LomiriGestures/TouchRegistry#CandidateInfo#Undecided.) {
406 qCriticalcxx . . $ `<external>/10450329605257866924/qlogging.h:167:9`!("TouchRegistry: touch owner is being removed.");
407 }
408
409 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
410 QQuickItem * candidateItem = touchInfo->candidates[candidateIndex].item;
411 #endif
412
413 removeCandidateHelper(touchInfo, candidateIndex);
414
415 if (candidateIndex == 0 && touchInfo->isOwned()) {
416 // the top candidate has been removed. if the new top candidate
417 // wants the touch let him know he's now the owner.
418 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
419 auto [pointerEvent, point] = findMostRelavantEventForId(
420 touchInfo->id, candidateItem);
421 touchInfo->notifyCandidatesOfOwnershipResolution(pointerEvent, point);
422 #else
423 touchInfo->notifyCandidatesOfOwnershipResolution();
424 #endif
425 }
426
427 if (!m_inDispatchLoopcxx . . $ LomiriGestures/TouchRegistry#m_inDispatchLoop. && touchInfo->ended()) {
428 m_touchInfoPool.freeSlot(touchInfo);
429 }
430 }
431
432 void TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::requestTouchOwnershipcxx . . $ LomiriGestures/TouchRegistry#requestTouchOwnership(1dd929642e598acc).(int id, QQuickItemcxx . . $ QQuickItem# *candidate)
433 {
434 UG_DEBUGcxx . . $ `src/LomiriGestures/touchregistry.cpp:33:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "requestTouchOwnership id " <<cxx . . $ QDebug#`operator<<`(6e3b7ae53f380c3). id <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "candidate" <<cxx . . $ `operator<<`(8519bbeb1a57acf3). candidate;
435
436 Pool<TouchInfo>::Iterator touchInfo = findTouchInfo(id);
437 if (!touchInfo) {
438 qCriticalcxx . . $ `<external>/10450329605257866924/qlogging.h:167:9`!("TouchRegistry: Failed to find TouchInfo");
439 return;
440 }
441
442 Q_ASSERTcxx . . $ `<external>/15045578679651060896/qglobal.h:859:13`!(!touchInfo->isOwned());
443
444 int candidateIndex = -1;
445 for (int i = 0; i < touchInfo->candidates.count(); ++i) {
446 CandidateInfocxx . . $ LomiriGestures/TouchRegistry#CandidateInfo# &candidateInfo = touchInfo->candidates[i];
447 if (candidateInfo.item ==cxx . . $ `operator==`(d35e8b31fb5dfd9b). candidate) {
448 candidateInfo.statecxx . . $ LomiriGestures/TouchRegistry#CandidateInfo#state. = CandidateInfocxx . . $ LomiriGestures/TouchRegistry#CandidateInfo#::Requestedcxx . . $ LomiriGestures/TouchRegistry#CandidateInfo#Requested.;
449 delete candidateInfo.inactivityTimer;
450 candidateInfo.inactivityTimer = nullptr;
451 candidateIndex = i;
452 break;
453 }
454 }
455
456 // add it as a candidate if not present yet
457 if (candidateIndex < 0) {
458 CandidateInfocxx . . $ LomiriGestures/TouchRegistry#CandidateInfo# candidateInfo;
459 candidateInfo.statecxx . . $ LomiriGestures/TouchRegistry#CandidateInfo#state. = CandidateInfocxx . . $ LomiriGestures/TouchRegistry#CandidateInfo#::InterimOwnercxx . . $ LomiriGestures/TouchRegistry#CandidateInfo#InterimOwner.;
460 candidateInfo.item = candidate;
461 candidateInfo.inactivityTimer = nullptr;
462 touchInfo->candidates.append(candidateInfo);
463 // it's the last one
464 candidateIndex = touchInfo->candidates.count() - 1;
465 connectcxx . . $ QObject#connect(835f87066c895669).(candidate, &QObjectcxx . . $ QObject#::destroyedcxx . . $ QObject#destroyed(749de1b6ae65bddd)., this, [=](){ pruneNullCandidatesForTouchcxx . . $ LomiriGestures/TouchRegistry#pruneNullCandidatesForTouch(d4f767463ce0a6b3).(id); });
466 }
467
468 // If it's the top candidate it means it's now the owner. Let
469 // it know about it.
470 if (candidateIndex == 0) {
471 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
472 auto [pointerEvent, point] = findMostRelavantEventForId(id, candidate);
473 touchInfo->notifyCandidatesOfOwnershipResolution(pointerEvent, point);
474 #else
475 touchInfo->notifyCandidatesOfOwnershipResolution();
476 #endif
477 }
478 }
479
480 Pool<TouchRegistry::TouchInfo>::Iterator TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::findTouchInfocxx . . $ LomiriGestures/TouchRegistry#findTouchInfo(7864480464b09eea).(int id)
481 {
482 Pool<TouchInfo>::Iterator touchInfo;
483
484 m_touchInfoPool.forEach([&](Pool<TouchInfo>::Iterator &someTouchInfo) -> bool {
485 if (someTouchInfo->id == id) {
486 touchInfo = someTouchInfo;
487 return false;
488 } else {
489 return true;
490 }
491 });
492
493 return touchInfo;
494 }
495
496 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
497 static const QEventPoint * findPointInEvent(const QPointerEvent *event, int id)
498 {
499 if (!event)
500 return nullptr;
501
502 const auto & points = event->points();
503
504 for (const auto & point : points) {
505 if (point.id() == id)
506 return &point;
507 }
508
509 return nullptr;
510 }
511
512 std::pair<QPointerEvent *, const QEventPoint *>
513 TouchRegistry::findMostRelavantEventForId(int id, QQuickItem *item)
514 {
515 QPointerEvent *event = nullptr;
516 const QEventPoint *point = nullptr;
517
518 for (int i = m_eventsInDelivery.size() - 1; i >= 0; i--) {
519 point = findPointInEvent(m_eventsInDelivery[i], id);
520 if (point) {
521 event = m_eventsInDelivery[i];
522 break;
523 }
524 }
525
526 if (!event && item) {
527 #if QT_VERSION >= QT_VERSION_CHECK(6, 1, 0)
528 QQuickItemPrivate *itemPriv = QQuickItemPrivate::get(item);
529 auto *dap = itemPriv->deliveryAgentPrivate();
530 auto quickEventInDelivery = dap ? dap->eventInDelivery() : nullptr;
531 #else
532 QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(window());
533 auto quickEventInDelivery = windowPriv->eventInDelivery();
534 #endif
535
536 point = findPointInEvent(quickEventInDelivery, id);
537 if (point) {
538 event = quickEventInDelivery;
539 }
540 }
541
542 return { event, point };
543 }
544 #endif
545
546 void TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::rejectCandidateOwnerForTouchcxx . . $ LomiriGestures/TouchRegistry#rejectCandidateOwnerForTouch(1dd929642e598acc).(int id, QQuickItemcxx . . $ QQuickItem# *candidate)
547 {
548 // NB: It's technically possible that candidate is a dangling pointer at this point.
549 // Although that would most likely be due to a bug in our code.
550 // In any case, only dereference it after it's confirmed that it indeed exists.
551
552 UG_DEBUGcxx . . $ `src/LomiriGestures/touchregistry.cpp:33:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "rejectCandidateOwnerForTouch id" <<cxx . . $ QDebug#`operator<<`(6e3b7ae53f380c3). id <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "candidate" <<cxx . . $ QDebug#`operator<<`(4f783e5a5d632c7c). (void*)candidate;
553
554 Pool<TouchInfo>::Iterator touchInfo = findTouchInfo(id);
555 if (!touchInfo) {
556 UG_DEBUGcxx . . $ `src/LomiriGestures/touchregistry.cpp:33:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Failed to find TouchInfo for id" <<cxx . . $ QDebug#`operator<<`(6e3b7ae53f380c3). id;
557 return;
558 }
559
560 int rejectedCandidateIndex = -1;
561
562 // Check if the given candidate is valid and still undecided
563 for (int i = 0; i < touchInfo->candidates.count() && rejectedCandidateIndex == -1; ++i) {
564 CandidateInfocxx . . $ LomiriGestures/TouchRegistry#CandidateInfo# &candidateInfo = touchInfo->candidates[i];
565 if (candidateInfo.item ==cxx . . $ `operator==`(d35e8b31fb5dfd9b). candidate) {
566 Q_ASSERTcxx . . $ `<external>/15045578679651060896/qglobal.h:859:13`!(i > 0 || candidateInfo.state == CandidateInfo::Undecided);
567 if (i == 0 && candidateInfo.statecxx . . $ LomiriGestures/TouchRegistry#CandidateInfo#state. != CandidateInfocxx . . $ LomiriGestures/TouchRegistry#CandidateInfo#::Undecidedcxx . . $ LomiriGestures/TouchRegistry#CandidateInfo#Undecided.) {
568 qCriticalcxx . . $ `<external>/10450329605257866924/qlogging.h:167:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "TouchRegistry: Can't reject item (" <<cxx . . $ QDebug#`operator<<`(4f783e5a5d632c7c). (void*)candidate
569 <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). ") as it already owns touch" <<cxx . . $ QDebug#`operator<<`(6e3b7ae53f380c3). id;
570 return;
571 } else {
572 // we found the guy and it's all fine.
573 rejectedCandidateIndex = i;
574 }
575 }
576 }
577
578 // If we reached this point it's because the given candidate exists and is indeed undecided.
579
580 Q_ASSERTcxx . . $ `<external>/15045578679651060896/qglobal.h:859:13`!(rejectedCandidateIndex >= 0 && rejectedCandidateIndex < touchInfo->candidates.size());
581
582 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
583 auto [pointerEvent, point] = findMostRelavantEventForId(id, candidate);
584 if (!pointerEvent) {
585 qWarning() << "Can't find a QPointerEvent for touch id" << id;
586 // XXX: proceed to send TouchOwnershipEvent; even without pointerEvent
587 // the item losing focus might still have to do internal rollback.
588 }
589 #endif
590
591 {
592 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
593 TouchOwnershipEvent lostOwnershipEvent(
594 id, false /*gained*/, pointerEvent, point);
595 #else
596 TouchOwnershipEventcxx . . $ LomiriGestures/TouchOwnershipEvent# lostOwnershipEventcxx . . $ LomiriGestures/TouchOwnershipEvent#TouchOwnershipEvent(918ebd27a9ddbad3).(id, false /*gained*/);
597 #endif
598 QCoreApplicationcxx . . $ QCoreApplication#::sendEventcxx . . $ QCoreApplication#sendEvent(978aa4af1d030efa).(candidate, &lostOwnershipEvent);
599 }
600
601 removeCandidateHelper(touchInfo, rejectedCandidateIndex);
602
603 if (rejectedCandidateIndex == 0 && touchInfo->isOwned()) {
604 // the top candidate has been removed. if the new top candidate
605 // wants the touch let him know he's now the owner.
606 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
607 touchInfo->notifyCandidatesOfOwnershipResolution(pointerEvent, point);
608 #else
609 touchInfo->notifyCandidatesOfOwnershipResolution();
610 #endif
611 }
612 }
613
614 void TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::removeCandidateHelpercxx . . $ LomiriGestures/TouchRegistry#removeCandidateHelper(3108d22d6d7c43ca).(Pool<TouchInfo>::Iterator &touchInfo, int candidateIndex)
615 {
616 {
617 CandidateInfocxx . . $ LomiriGestures/TouchRegistry#CandidateInfo# &candidateInfo = touchInfo->candidates[candidateIndex];
618
619 delete candidateInfo.inactivityTimer;
620 candidateInfo.inactivityTimer = nullptr;
621
622 if (candidateInfo.item) {
623 disconnectcxx . . $ QObject#disconnect(bb355c0e5cae20e4).(candidateInfo.item.data(), nullptr, this, nullptr);
624 }
625 }
626 touchInfo->candidates.removeAt(candidateIndex);
627 }
628
629 ////////////////////////////////////// TouchRegistry::TouchInfo ////////////////////////////////////
630
631 TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::TouchInfocxx . . $ LomiriGestures/TouchRegistry#TouchInfo#::TouchInfocxx . . $ LomiriGestures/TouchRegistry#TouchInfo#TouchInfo(d4f767463ce0a6b3).(int id)
632 {
633 initcxx . . $ LomiriGestures/TouchRegistry#TouchInfo#init(d4f767463ce0a6b3).(id);
634 }
635
636 void TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::TouchInfocxx . . $ LomiriGestures/TouchRegistry#TouchInfo#::resetcxx . . $ LomiriGestures/TouchRegistry#TouchInfo#reset(49f6e7a06ebc5aa8).()
637 {
638 idcxx . . $ LomiriGestures/TouchRegistry#TouchInfo#id. = -1;
639
640 for (int i = 0; i < candidates.count(); ++i) {
641 CandidateInfocxx . . $ LomiriGestures/TouchRegistry#CandidateInfo# &candidate = candidates[i];
642 delete candidate.inactivityTimer;
643 candidate.inactivityTimer.clear(); // shoundn't be needed but anyway...
644 }
645 }
646
647 void TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::TouchInfocxx . . $ LomiriGestures/TouchRegistry#TouchInfo#::initcxx . . $ LomiriGestures/TouchRegistry#TouchInfo#init(d4f767463ce0a6b3).(int id)
648 {
649 this->idcxx . . $ LomiriGestures/TouchRegistry#TouchInfo#id. = id;
650 physicallyEndedcxx . . $ LomiriGestures/TouchRegistry#TouchInfo#physicallyEnded. = false;
651 candidates.clear();
652 watchers.clear();
653 }
654
655 bool TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::TouchInfocxx . . $ LomiriGestures/TouchRegistry#TouchInfo#::isOwnedcxx . . $ LomiriGestures/TouchRegistry#TouchInfo#isOwned(50ce9a9e25b4a850).() const
656 {
657 return !candidates.isEmpty() && candidates.first().state != CandidateInfo::Undecided;
658 }
659
660 bool TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::TouchInfocxx . . $ LomiriGestures/TouchRegistry#TouchInfo#::endedcxx . . $ LomiriGestures/TouchRegistry#TouchInfo#ended(50ce9a9e25b4a850).() const
661 {
662 Q_ASSERTcxx . . $ `<external>/15045578679651060896/qglobal.h:859:13`!(isValid());
663 return physicallyEnded && (isOwned() || candidates.isEmpty());
664 }
665
666 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
667 void TouchRegistry::TouchInfo::notifyCandidatesOfOwnershipResolution(
668 QPointerEvent *pointerEvent, const QEventPoint *point)
669 #else
670 void TouchRegistrycxx . . $ LomiriGestures/TouchRegistry#::TouchInfocxx . . $ LomiriGestures/TouchRegistry#TouchInfo#::notifyCandidatesOfOwnershipResolutioncxx . . $ LomiriGestures/TouchRegistry#TouchInfo#notifyCandidatesOfOwnershipResolution(49f6e7a06ebc5aa8).()
671 #endif
672 {
673 Q_ASSERTcxx . . $ `<external>/15045578679651060896/qglobal.h:859:13`!(isOwned());
674
675 UG_DEBUGcxx . . $ `src/LomiriGestures/touchregistry.cpp:33:9`! << "sending TouchOwnershipEvent(id =" << id
676 << " gained) to candidate" << candidates[0].item;
677
678 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
679 if (!pointerEvent) {
680 qWarning() << "Can't find a QPointerEvent for touch id" << id
681 << ", candidate" << candidates[0].item
682 << "might not be able to grab the point";
683 }
684 #endif
685
686 // need to take a copy of the item list in case
687 // we call back in to remove candidate during the lost ownership event.
688 QListcxx . . $ QList#<QPointercxx . . $ QPointer#<QQuickItemcxx . . $ QQuickItem#>> items;
689 Q_FOREACHcxx . . $ `<external>/15045578679651060896/qglobal.h:1137:9`!(const CandidateInfo& info, candidates) {
690 items <<cxx . . $ `operator<<`(194be36db48dc79f). info.item;
691 }
692
693 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
694 TouchOwnershipEvent gainedOwnershipEvent(
695 id, true /*gained*/, pointerEvent, point);
696 #else
697 TouchOwnershipEventcxx . . $ LomiriGestures/TouchOwnershipEvent# gainedOwnershipEventcxx . . $ LomiriGestures/TouchOwnershipEvent#TouchOwnershipEvent(918ebd27a9ddbad3).(idcxx . . $ LomiriGestures/TouchRegistry#TouchInfo#id., true /*gained*/);
698 #endif
699 QCoreApplicationcxx . . $ QCoreApplication#::sendEventcxx . . $ QCoreApplication#sendEvent(978aa4af1d030efa).(items[0], &gainedOwnershipEvent);
700
701 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0)
702 TouchOwnershipEvent lostOwnershipEvent(
703 id, false /*gained*/, pointerEvent, point);
704 #else
705 TouchOwnershipEventcxx . . $ LomiriGestures/TouchOwnershipEvent# lostOwnershipEventcxx . . $ LomiriGestures/TouchOwnershipEvent#TouchOwnershipEvent(918ebd27a9ddbad3).(idcxx . . $ LomiriGestures/TouchRegistry#TouchInfo#id., false /*gained*/);
706 #endif
707
708 for (int i = 1; i <cxx . . $ `operator<`(945cec9d77892c2f). items.count(); ++i) {
709 UG_DEBUGcxx . . $ `src/LomiriGestures/touchregistry.cpp:33:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "sending TouchOwnershipEvent(id =" <<cxx . . $ QDebug#`operator<<`(6e3b7ae53f380c3). idcxx . . $ LomiriGestures/TouchRegistry#TouchInfo#id. <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). " lost) to candidate"
710 <<cxx . . $ `operator<<`(194be36db48dc79f). items[i];
711 QCoreApplicationcxx . . $ QCoreApplication#::sendEventcxx . . $ QCoreApplication#sendEvent(978aa4af1d030efa).(items[i], &lostOwnershipEvent);
712 }
713 }
714
715 UG_NAMESPACE_ENDcxx . . $ `src/LomiriGestures/lomirigesturesglobal.h:31:9`!