summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app.h4
-rw-r--r--src/ui/documentwidget.c5
-rw-r--r--src/ui/touch.c12
3 files changed, 20 insertions, 1 deletions
diff --git a/src/app.h b/src/app.h
index 4d09f5da..4eae7afd 100644
--- a/src/app.h
+++ b/src/app.h
@@ -57,6 +57,10 @@ enum iUserEventCode {
57 command_UserEventCode = 1, 57 command_UserEventCode = 1,
58 refresh_UserEventCode = 2, 58 refresh_UserEventCode = 2,
59 asleep_UserEventCode = 3, 59 asleep_UserEventCode = 3,
60 /* The start of a potential touch tap event is notified via a custom event because
61 sending SDL_MOUSEBUTTONDOWN would be premature: we don't know how long the tap will
62 take, it could turn into a tap-and-hold for example. */
63 widgetTapBegins_UserEventCode = 4,
60}; 64};
61 65
62const iString *execPath_App (void); 66const iString *execPath_App (void);
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 84e9ebfe..c3a6d40d 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -2602,8 +2602,11 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
2602 updateHover_DocumentWidget_(d, mpos); 2602 updateHover_DocumentWidget_(d, mpos);
2603 } 2603 }
2604 } 2604 }
2605 if (ev->type == SDL_MOUSEBUTTONDOWN) { 2605 if (ev->type == SDL_USEREVENT && ev->user.code == widgetTapBegins_UserEventCode) {
2606 iChangeFlags(d->flags, noHoverWhileScrolling_DocumentWidgetFlag, iFalse); 2606 iChangeFlags(d->flags, noHoverWhileScrolling_DocumentWidgetFlag, iFalse);
2607 return iTrue;
2608 }
2609 if (ev->type == SDL_MOUSEBUTTONDOWN) {
2607 if (ev->button.button == SDL_BUTTON_X1) { 2610 if (ev->button.button == SDL_BUTTON_X1) {
2608 postCommand_App("navigate.back"); 2611 postCommand_App("navigate.back");
2609 return iTrue; 2612 return iTrue;
diff --git a/src/ui/touch.c b/src/ui/touch.c
index 68c493dc..bf217301 100644
--- a/src/ui/touch.c
+++ b/src/ui/touch.c
@@ -209,6 +209,17 @@ static void dispatchButtonUp_Touch_(iFloat3 pos) {
209 }); 209 });
210} 210}
211 211
212static void dispatchNotification_Touch_(const iTouch *d, int code) {
213 if (d->affinity) {
214 dispatchEvent_Widget(d->affinity, (SDL_Event *) &(SDL_UserEvent){
215 .type = SDL_USEREVENT,
216 .timestamp = SDL_GetTicks(),
217 .code = code,
218 .data1 = d->affinity
219 });
220 }
221}
222
212static void update_TouchState_(void *ptr) { 223static void update_TouchState_(void *ptr) {
213 iTouchState *d = ptr; 224 iTouchState *d = ptr;
214 const uint32_t nowTime = SDL_GetTicks(); 225 const uint32_t nowTime = SDL_GetTicks();
@@ -226,6 +237,7 @@ static void update_TouchState_(void *ptr) {
226 } 237 }
227 if (elapsed > 50 && !touch->isTapBegun) { 238 if (elapsed > 50 && !touch->isTapBegun) {
228 /* Looks like a possible tap. */ 239 /* Looks like a possible tap. */
240 dispatchNotification_Touch_(touch, widgetTapBegins_UserEventCode);
229 dispatchMotion_Touch_(touch->pos[0], 0); 241 dispatchMotion_Touch_(touch->pos[0], 0);
230 touch->isTapBegun = iTrue; 242 touch->isTapBegun = iTrue;
231 } 243 }