MCPcopy Create free account
hub / github.com/Snapchat/Valdi / refreshTouches

Method refreshTouches

snap_drawing/src/snap_drawing/cpp/Layers/LayerRoot.cpp:202–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200 return processed;
201}
202
203GestureTypes LayerRoot::getGesturesTypesForTouchEvent(const TouchEvent& event) const {
204 if (_contentLayer == nullptr) {
205 return GestureTypes();
206 }
207
208 auto gestureCandidates = _touchDispatcher.getGestureCandidatesForEvent(event, _contentLayer);
209
210 GestureTypes types;
211
212 for (const auto& gesture : gestureCandidates) {
213 if (Valdi::castOrNull<TapGestureRecognizer>(gesture) != nullptr) {
214 types.hasTap = true;
215 } else if (Valdi::castOrNull<ScrollGestureRecognizer>(gesture) != nullptr) {
216 types.hasScroll = true;
217 } else if (Valdi::castOrNull<DragGestureRecognizer>(gesture) != nullptr) {
218 types.hasDrag = true;
219 }
220 }
221
222 return types;
223}
224
225bool LayerRoot::refreshTouches(const TimePoint& currentTime) {
226 if (_touchDispatcher.isEmpty()) {
227 return false;
228 }
229 if (!_touchDispatcher.getLastEvent()) {
230 return false;
231 }
232
233 const auto& lastEvent = _touchDispatcher.getLastEvent().value();
234
235 auto offsetSinceLastEvent = currentTime - lastEvent.getTime();
236
237 if (offsetSinceLastEvent.milliseconds() < kTouchRefreshMs) {
238 // Only refresh gestures if there wasn't another event that came over 10ms ago
239 return false;

Callers 1

TESTFunction · 0.80

Calls 12

getLastEventMethod · 0.80
getTimeMethod · 0.80
getLocationInWindowMethod · 0.80
getLocationMethod · 0.80
getPointerCountMethod · 0.80
getActionIndexMethod · 0.80
getOffsetSinceSourceMethod · 0.80
valueMethod · 0.65
TouchEventClass · 0.50
isEmptyMethod · 0.45
millisecondsMethod · 0.45
getTypeMethod · 0.45

Tested by 1

TESTFunction · 0.64