summaryrefslogtreecommitdiff
path: root/src/ui/touch.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/touch.c')
-rw-r--r--src/ui/touch.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/ui/touch.c b/src/ui/touch.c
index 0f23e948..98dabc39 100644
--- a/src/ui/touch.c
+++ b/src/ui/touch.c
@@ -58,9 +58,10 @@ struct Impl_Touch {
58 iWidget *edgeDragging; 58 iWidget *edgeDragging;
59 iBool hasMoved; 59 iBool hasMoved;
60 iBool isTapBegun; 60 iBool isTapBegun;
61 iBool isLeftDown;
61 iBool isTouchDrag; 62 iBool isTouchDrag;
62 iBool didConvertToTouchDrag;
63 iBool isTapAndHold; 63 iBool isTapAndHold;
64 iBool didBeginOnTouchDrag;
64 int pinchId; 65 int pinchId;
65 enum iTouchEdge edge; 66 enum iTouchEdge edge;
66 uint32_t startTime; 67 uint32_t startTime;
@@ -233,7 +234,7 @@ static void update_TouchState_(void *ptr) {
233 /* Holding a touch will reset previous momentum for this widget. */ 234 /* Holding a touch will reset previous momentum for this widget. */
234 if (isStationary_Touch_(touch)) { 235 if (isStationary_Touch_(touch)) {
235 const int elapsed = nowTime - touch->startTime; 236 const int elapsed = nowTime - touch->startTime;
236 if (elapsed > 25) { 237 if (elapsed > 25) { /* TODO: Shouldn't this be done only once? */
237 clearWidgetMomentum_TouchState_(d, touch->affinity); 238 clearWidgetMomentum_TouchState_(d, touch->affinity);
238 clear_Array(d->moms); /* stop all ongoing momentum */ 239 clear_Array(d->moms); /* stop all ongoing momentum */
239 } 240 }
@@ -254,13 +255,12 @@ static void update_TouchState_(void *ptr) {
254#endif 255#endif
255 dispatchMotion_Touch_(init_F3(-100, -100, 0), 0); 256 dispatchMotion_Touch_(init_F3(-100, -100, 0), 0);
256 } 257 }
257 if (touch->isTapAndHold && touch->affinity && 258 else if (!touch->didBeginOnTouchDrag && touch->isTapAndHold &&
258 flags_Widget(touch->affinity) & touchDrag_WidgetFlag) { 259 touch->affinity && flags_Widget(touch->affinity) & touchDrag_WidgetFlag) {
259 /* Convert to touch drag. */ 260 /* Convert to touch drag. */
260 touch->isTapAndHold = iFalse;
261 touch->isTouchDrag = iTrue; 261 touch->isTouchDrag = iTrue;
262 touch->didConvertToTouchDrag = iTrue;
263 dispatchButtonDown_Touch_(touch->pos[0]); 262 dispatchButtonDown_Touch_(touch->pos[0]);
263 touch->isLeftDown = iTrue;
264 } 264 }
265 } 265 }
266 } 266 }
@@ -451,6 +451,7 @@ iBool processEvent_Touch(const SDL_Event *ev) {
451 .affinity = aff, 451 .affinity = aff,
452 .edgeDragging = dragging, 452 .edgeDragging = dragging,
453// .hasMoved = (flags_Widget(aff) & touchDrag_WidgetFlag) != 0, 453// .hasMoved = (flags_Widget(aff) & touchDrag_WidgetFlag) != 0,
454 .didBeginOnTouchDrag = (flags_Widget(aff) & touchDrag_WidgetFlag) != 0,
454 .edge = edge, 455 .edge = edge,
455 .startTime = nowTime, 456 .startTime = nowTime,
456 .startPos = pos, 457 .startPos = pos,
@@ -497,6 +498,7 @@ iBool processEvent_Touch(const SDL_Event *ev) {
497 dispatchMotion_Touch_(touch->startPos, 0); 498 dispatchMotion_Touch_(touch->startPos, 0);
498 dispatchButtonDown_Touch_(touch->startPos); 499 dispatchButtonDown_Touch_(touch->startPos);
499 dispatchMotion_Touch_(pos, SDL_BUTTON_LMASK); 500 dispatchMotion_Touch_(pos, SDL_BUTTON_LMASK);
501 touch->isLeftDown = iTrue;
500 return iTrue; 502 return iTrue;
501 } 503 }
502 const iFloat3 amount = mul_F3(init_F3(fing->dx, fing->dy, 0), 504 const iFloat3 amount = mul_F3(init_F3(fing->dx, fing->dy, 0),
@@ -594,19 +596,21 @@ iBool processEvent_Touch(const SDL_Event *ev) {
594 if (touch->edgeDragging) { 596 if (touch->edgeDragging) {
595 setFlags_Widget(touch->edgeDragging, dragged_WidgetFlag, iFalse); 597 setFlags_Widget(touch->edgeDragging, dragged_WidgetFlag, iFalse);
596 } 598 }
597 if (touch->isTapAndHold) { 599 if (flags_Widget(touch->affinity) & touchDrag_WidgetFlag) {
598 if (!isStationary_Touch_(touch)) { 600 if (!touch->isLeftDown && !touch->isTapAndHold) {
599 dispatchClick_Touch_(touch, SDL_BUTTON_LEFT); 601 /* This will be a click on a touchDrag widget. */
602 dispatchButtonDown_Touch_(touch->startPos);
600 } 603 }
601 setHover_Widget(NULL); 604 dispatchButtonUp_Touch_(pos);
602 remove_ArrayIterator(&i); 605 remove_ArrayIterator(&i);
603 continue; 606 continue;
604 } 607 }
605 if (flags_Widget(touch->affinity) & touchDrag_WidgetFlag) { 608 if (touch->isTapAndHold) {
606 if (!touch->isTouchDrag && !touch->didConvertToTouchDrag) { 609 if (!isStationary_Touch_(touch)) {
607 dispatchButtonDown_Touch_(touch->startPos); 610 /* Finger moved while holding, so click at the end position. */
611 dispatchClick_Touch_(touch, SDL_BUTTON_LEFT);
608 } 612 }
609 dispatchButtonUp_Touch_(pos); 613 setHover_Widget(NULL);
610 remove_ArrayIterator(&i); 614 remove_ArrayIterator(&i);
611 continue; 615 continue;
612 } 616 }