summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-04-20 17:07:58 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-04-20 17:07:58 +0300
commitba9c5af788fddf64d84dc14ac9e7c72559df7f13 (patch)
treed28a921ca41a87c5199ff18e7c6e7de5300194e6
parentee2dc3a919e2ebea0d0f786e29daea26fec38c93 (diff)
Touch: Resuming a drag scroll from momentum
Continue a scroll if there's still a momentum scroll ongoing instead of checking long-press.
-rw-r--r--src/ui/touch.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/ui/touch.c b/src/ui/touch.c
index 4bbabece..f534c4e8 100644
--- a/src/ui/touch.c
+++ b/src/ui/touch.c
@@ -140,14 +140,16 @@ static iBool isStationary_Touch_(const iTouch *d) {
140 return isStationaryDistance_Touch_(d, tapRadiusPt_); 140 return isStationaryDistance_Touch_(d, tapRadiusPt_);
141} 141}
142 142
143static void clearWidgetMomentum_TouchState_(iTouchState *d, iWidget *widget) { 143static iBool clearWidgetMomentum_TouchState_(iTouchState *d, iWidget *widget) {
144 if (!widget) return; 144 if (!widget) return;
145 iForEach(Array, m, d->moms) { 145 iForEach(Array, m, d->moms) {
146 iMomentum *mom = m.value; 146 iMomentum *mom = m.value;
147 if (mom->affinity == widget) { 147 if (mom->affinity == widget) {
148 remove_ArrayIterator(&m); 148 remove_ArrayIterator(&m);
149 return iTrue;
149 } 150 }
150 } 151 }
152 return iFalse;
151} 153}
152 154
153static void dispatchMotion_Touch_(iFloat3 pos, int buttonState) { 155static void dispatchMotion_Touch_(iFloat3 pos, int buttonState) {
@@ -240,7 +242,9 @@ static void update_TouchState_(void *ptr) {
240 if (isStationary_Touch_(touch)) { 242 if (isStationary_Touch_(touch)) {
241 const int elapsed = nowTime - touch->startTime; 243 const int elapsed = nowTime - touch->startTime;
242 if (elapsed > 25) { /* TODO: Shouldn't this be done only once? */ 244 if (elapsed > 25) { /* TODO: Shouldn't this be done only once? */
243 clearWidgetMomentum_TouchState_(d, touch->affinity); 245 if (clearWidgetMomentum_TouchState_(d, touch->affinity)) {
246 touch->hasMoved = iTrue; /* resume scrolling */
247 }
244 clear_Array(d->moms); /* stop all ongoing momentum */ 248 clear_Array(d->moms); /* stop all ongoing momentum */
245 } 249 }
246 if (elapsed > 50 && !touch->isTapBegun) { 250 if (elapsed > 50 && !touch->isTapBegun) {
@@ -455,7 +459,6 @@ iBool processEvent_Touch(const SDL_Event *ev) {
455 .id = fing->fingerId, 459 .id = fing->fingerId,
456 .affinity = aff, 460 .affinity = aff,
457 .edgeDragging = dragging, 461 .edgeDragging = dragging,
458// .hasMoved = (flags_Widget(aff) & touchDrag_WidgetFlag) != 0,
459 .didBeginOnTouchDrag = (flags_Widget(aff) & touchDrag_WidgetFlag) != 0, 462 .didBeginOnTouchDrag = (flags_Widget(aff) & touchDrag_WidgetFlag) != 0,
460 .edge = edge, 463 .edge = edge,
461 .startTime = nowTime, 464 .startTime = nowTime,