summaryrefslogtreecommitdiff
path: root/src/ui/touch.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-04-11 08:34:14 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-04-11 08:34:14 +0300
commite08bf8f56c078ba0e5c2aa363c43ea5db3561aa2 (patch)
tree6fbe657e55d531988e184b289275e5599ba2d4e4 /src/ui/touch.c
parent44b1f58bb25817d2bc4578e727ce637752d00299 (diff)
Mobile: Long press to select; navbar page menu
DocumentWidget now supports a long-press drag selection mode. The context menu was moved to the URL bar, replacing the reload button.
Diffstat (limited to 'src/ui/touch.c')
-rw-r--r--src/ui/touch.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/ui/touch.c b/src/ui/touch.c
index 87bb7478..0f23e948 100644
--- a/src/ui/touch.c
+++ b/src/ui/touch.c
@@ -59,6 +59,7 @@ struct Impl_Touch {
59 iBool hasMoved; 59 iBool hasMoved;
60 iBool isTapBegun; 60 iBool isTapBegun;
61 iBool isTouchDrag; 61 iBool isTouchDrag;
62 iBool didConvertToTouchDrag;
62 iBool isTapAndHold; 63 iBool isTapAndHold;
63 int pinchId; 64 int pinchId;
64 enum iTouchEdge edge; 65 enum iTouchEdge edge;
@@ -226,7 +227,7 @@ static void update_TouchState_(void *ptr) {
226 /* Check for long presses to simulate right clicks. */ 227 /* Check for long presses to simulate right clicks. */
227 iForEach(Array, i, d->touches) { 228 iForEach(Array, i, d->touches) {
228 iTouch *touch = i.value; 229 iTouch *touch = i.value;
229 if (touch->pinchId) { 230 if (touch->pinchId || touch->isTouchDrag) {
230 continue; 231 continue;
231 } 232 }
232 /* Holding a touch will reset previous momentum for this widget. */ 233 /* Holding a touch will reset previous momentum for this widget. */
@@ -253,6 +254,14 @@ static void update_TouchState_(void *ptr) {
253#endif 254#endif
254 dispatchMotion_Touch_(init_F3(-100, -100, 0), 0); 255 dispatchMotion_Touch_(init_F3(-100, -100, 0), 0);
255 } 256 }
257 if (touch->isTapAndHold && touch->affinity &&
258 flags_Widget(touch->affinity) & touchDrag_WidgetFlag) {
259 /* Convert to touch drag. */
260 touch->isTapAndHold = iFalse;
261 touch->isTouchDrag = iTrue;
262 touch->didConvertToTouchDrag = iTrue;
263 dispatchButtonDown_Touch_(touch->pos[0]);
264 }
256 } 265 }
257 } 266 }
258 /* Update/cancel momentum scrolling. */ { 267 /* Update/cancel momentum scrolling. */ {
@@ -486,16 +495,7 @@ iBool processEvent_Touch(const SDL_Event *ev) {
486 touch->edge = none_TouchEdge; 495 touch->edge = none_TouchEdge;
487 pushPos_Touch_(touch, pos, fing->timestamp); 496 pushPos_Touch_(touch, pos, fing->timestamp);
488 dispatchMotion_Touch_(touch->startPos, 0); 497 dispatchMotion_Touch_(touch->startPos, 0);
489 dispatchEvent_Widget(window->root, (SDL_Event *) &(SDL_MouseButtonEvent){ 498 dispatchButtonDown_Touch_(touch->startPos);
490 .type = SDL_MOUSEBUTTONDOWN,
491 .timestamp = fing->timestamp,
492 .clicks = 1,
493 .state = SDL_PRESSED,
494 .which = SDL_TOUCH_MOUSEID,
495 .button = SDL_BUTTON_LEFT,
496 .x = x_F3(touch->startPos),
497 .y = y_F3(touch->startPos)
498 });
499 dispatchMotion_Touch_(pos, SDL_BUTTON_LMASK); 499 dispatchMotion_Touch_(pos, SDL_BUTTON_LMASK);
500 return iTrue; 500 return iTrue;
501 } 501 }
@@ -603,11 +603,10 @@ iBool processEvent_Touch(const SDL_Event *ev) {
603 continue; 603 continue;
604 } 604 }
605 if (flags_Widget(touch->affinity) & touchDrag_WidgetFlag) { 605 if (flags_Widget(touch->affinity) & touchDrag_WidgetFlag) {
606 if (!touch->isTouchDrag) { 606 if (!touch->isTouchDrag && !touch->didConvertToTouchDrag) {
607 dispatchButtonDown_Touch_(touch->startPos); 607 dispatchButtonDown_Touch_(touch->startPos);
608 } 608 }
609 dispatchButtonUp_Touch_(pos); 609 dispatchButtonUp_Touch_(pos);
610// setHover_Widget(NULL);
611 remove_ArrayIterator(&i); 610 remove_ArrayIterator(&i);
612 continue; 611 continue;
613 } 612 }
@@ -678,7 +677,7 @@ void widgetDestroyed_Touch(iWidget *widget) {
678 } 677 }
679 } 678 }
680 iForEach(Array, p, d->pinches) { 679 iForEach(Array, p, d->pinches) {
681 iPinch *pinch = i.value; 680 iPinch *pinch = p.value;
682 if (pinch->affinity == widget) { 681 if (pinch->affinity == widget) {
683 remove_ArrayIterator(&p); 682 remove_ArrayIterator(&p);
684 } 683 }