summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-04-09 21:42:50 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-04-10 06:29:31 +0300
commitf9ef1545a644b3f39d300c5a51cb0d8804e6fa09 (patch)
tree00e9fc5c7bcf1ab144c4f9c16107359ecf62ba24 /src/ui
parentd5249e99515c1a10db34bd9cd730b315c35fecc8 (diff)
Touch: Notify widget when tap is about to begin
Notify when hover state should be updated again after scrolling.
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/documentwidget.c5
-rw-r--r--src/ui/touch.c12
2 files changed, 16 insertions, 1 deletions
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 }