diff options
Diffstat (limited to 'src/ui/touch.c')
-rw-r--r-- | src/ui/touch.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/ui/touch.c b/src/ui/touch.c index 6867a34b..e49fce2a 100644 --- a/src/ui/touch.c +++ b/src/ui/touch.c | |||
@@ -161,7 +161,7 @@ static iBool clearWidgetMomentum_TouchState_(iTouchState *d, iWidget *widget) { | |||
161 | 161 | ||
162 | static void dispatchMotion_Touch_(iFloat3 pos, int buttonState) { | 162 | static void dispatchMotion_Touch_(iFloat3 pos, int buttonState) { |
163 | touchState_()->currentTouchPos = initF3_I2(pos); | 163 | touchState_()->currentTouchPos = initF3_I2(pos); |
164 | dispatchEvent_Widget(get_Window()->root.widget, (SDL_Event *) &(SDL_MouseMotionEvent){ | 164 | dispatchEvent_Window(get_Window(), (SDL_Event *) &(SDL_MouseMotionEvent){ |
165 | .type = SDL_MOUSEMOTION, | 165 | .type = SDL_MOUSEMOTION, |
166 | .timestamp = SDL_GetTicks(), | 166 | .timestamp = SDL_GetTicks(), |
167 | .which = SDL_TOUCH_MOUSEID, | 167 | .which = SDL_TOUCH_MOUSEID, |
@@ -185,12 +185,12 @@ static iBool dispatchClick_Touch_(const iTouch *d, int button) { | |||
185 | .x = x_F3(tapPos), | 185 | .x = x_F3(tapPos), |
186 | .y = y_F3(tapPos) | 186 | .y = y_F3(tapPos) |
187 | }; | 187 | }; |
188 | iBool wasUsed = dispatchEvent_Widget(window->root.widget, (SDL_Event *) &btn); | 188 | iBool wasUsed = dispatchEvent_Window(window, (SDL_Event *) &btn); |
189 | /* Immediately released, too. */ | 189 | /* Immediately released, too. */ |
190 | btn.type = SDL_MOUSEBUTTONUP; | 190 | btn.type = SDL_MOUSEBUTTONUP; |
191 | btn.state = SDL_RELEASED; | 191 | btn.state = SDL_RELEASED; |
192 | btn.timestamp = SDL_GetTicks(); | 192 | btn.timestamp = SDL_GetTicks(); |
193 | dispatchEvent_Widget(window->root.widget, (SDL_Event *) &btn); | 193 | dispatchEvent_Window(window, (SDL_Event *) &btn); |
194 | if (!wasUsed && button == SDL_BUTTON_RIGHT) { | 194 | if (!wasUsed && button == SDL_BUTTON_RIGHT) { |
195 | postContextClick_Window(window, &btn); | 195 | postContextClick_Window(window, &btn); |
196 | } | 196 | } |
@@ -199,7 +199,7 @@ static iBool dispatchClick_Touch_(const iTouch *d, int button) { | |||
199 | 199 | ||
200 | static void dispatchButtonDown_Touch_(iFloat3 pos) { | 200 | static void dispatchButtonDown_Touch_(iFloat3 pos) { |
201 | touchState_()->currentTouchPos = initF3_I2(pos); | 201 | touchState_()->currentTouchPos = initF3_I2(pos); |
202 | dispatchEvent_Widget(get_Window()->root.widget, (SDL_Event *) &(SDL_MouseButtonEvent){ | 202 | dispatchEvent_Window(get_Window(), (SDL_Event *) &(SDL_MouseButtonEvent){ |
203 | .type = SDL_MOUSEBUTTONDOWN, | 203 | .type = SDL_MOUSEBUTTONDOWN, |
204 | .timestamp = SDL_GetTicks(), | 204 | .timestamp = SDL_GetTicks(), |
205 | .clicks = 1, | 205 | .clicks = 1, |
@@ -213,7 +213,7 @@ static void dispatchButtonDown_Touch_(iFloat3 pos) { | |||
213 | 213 | ||
214 | static void dispatchButtonUp_Touch_(iFloat3 pos) { | 214 | static void dispatchButtonUp_Touch_(iFloat3 pos) { |
215 | touchState_()->currentTouchPos = initF3_I2(pos); | 215 | touchState_()->currentTouchPos = initF3_I2(pos); |
216 | dispatchEvent_Widget(get_Window()->root.widget, (SDL_Event *) &(SDL_MouseButtonEvent){ | 216 | dispatchEvent_Window(get_Window(), (SDL_Event *) &(SDL_MouseButtonEvent){ |
217 | .type = SDL_MOUSEBUTTONUP, | 217 | .type = SDL_MOUSEBUTTONUP, |
218 | .timestamp = SDL_GetTicks(), | 218 | .timestamp = SDL_GetTicks(), |
219 | .clicks = 1, | 219 | .clicks = 1, |
@@ -227,12 +227,15 @@ static void dispatchButtonUp_Touch_(iFloat3 pos) { | |||
227 | 227 | ||
228 | static void dispatchNotification_Touch_(const iTouch *d, int code) { | 228 | static void dispatchNotification_Touch_(const iTouch *d, int code) { |
229 | if (d->affinity) { | 229 | if (d->affinity) { |
230 | iRoot *oldRoot = get_Root(); | ||
231 | setCurrent_Root(d->affinity->root); | ||
230 | dispatchEvent_Widget(d->affinity, (SDL_Event *) &(SDL_UserEvent){ | 232 | dispatchEvent_Widget(d->affinity, (SDL_Event *) &(SDL_UserEvent){ |
231 | .type = SDL_USEREVENT, | 233 | .type = SDL_USEREVENT, |
232 | .timestamp = SDL_GetTicks(), | 234 | .timestamp = SDL_GetTicks(), |
233 | .code = code, | 235 | .code = code, |
234 | .data1 = d->affinity | 236 | .data1 = d->affinity |
235 | }); | 237 | }); |
238 | setCurrent_Root(oldRoot); | ||
236 | } | 239 | } |
237 | } | 240 | } |
238 | 241 | ||
@@ -335,7 +338,7 @@ static void update_TouchState_(void *ptr) { | |||
335 | } | 338 | } |
336 | 339 | ||
337 | static iWidget *findOverflowScrollable_Widget_(iWidget *d) { | 340 | static iWidget *findOverflowScrollable_Widget_(iWidget *d) { |
338 | const iInt2 rootSize = size_Root(get_Root()); | 341 | const iInt2 rootSize = size_Root(d->root); |
339 | for (iWidget *w = d; w; w = parent_Widget(w)) { | 342 | for (iWidget *w = d; w; w = parent_Widget(w)) { |
340 | if (flags_Widget(w) & overflowScrollable_WidgetFlag) { | 343 | if (flags_Widget(w) & overflowScrollable_WidgetFlag) { |
341 | if (height_Widget(w) > rootSize.y && !hasVisibleChildOnTop_Widget(w)) { | 344 | if (height_Widget(w) > rootSize.y && !hasVisibleChildOnTop_Widget(w)) { |
@@ -441,7 +444,7 @@ iBool processEvent_Touch(const SDL_Event *ev) { | |||
441 | if (!isFinished_Anim(&window->rootOffset)) { | 444 | if (!isFinished_Anim(&window->rootOffset)) { |
442 | return iFalse; | 445 | return iFalse; |
443 | } | 446 | } |
444 | const iInt2 rootSize = size_Root(get_Root()); | 447 | const iInt2 rootSize = size_Window(window); |
445 | const SDL_TouchFingerEvent *fing = &ev->tfinger; | 448 | const SDL_TouchFingerEvent *fing = &ev->tfinger; |
446 | const iFloat3 pos = add_F3(init_F3(fing->x * rootSize.x, fing->y * rootSize.y, 0), /* pixels */ | 449 | const iFloat3 pos = add_F3(init_F3(fing->x * rootSize.x, fing->y * rootSize.y, 0), /* pixels */ |
447 | init_F3(0, -value_Anim(&window->rootOffset), 0)); | 450 | init_F3(0, -value_Anim(&window->rootOffset), 0)); |
@@ -458,7 +461,7 @@ iBool processEvent_Touch(const SDL_Event *ev) { | |||
458 | else if (x > rootSize.x - edgeWidth) { | 461 | else if (x > rootSize.x - edgeWidth) { |
459 | edge = right_TouchEdge; | 462 | edge = right_TouchEdge; |
460 | } | 463 | } |
461 | iWidget *aff = hitChild_Widget(window->root.widget, init_I2(iRound(x), iRound(y_F3(pos)))); | 464 | iWidget *aff = hitChild_Window(window, init_I2(iRound(x), iRound(y_F3(pos)))); |
462 | if (edge == left_TouchEdge) { | 465 | if (edge == left_TouchEdge) { |
463 | dragging = findSlidePanel_Widget_(aff); | 466 | dragging = findSlidePanel_Widget_(aff); |
464 | if (dragging) { | 467 | if (dragging) { |
@@ -607,7 +610,6 @@ iBool processEvent_Touch(const SDL_Event *ev) { | |||
607 | } | 610 | } |
608 | } | 611 | } |
609 | else if (ev->type == SDL_FINGERUP) { | 612 | else if (ev->type == SDL_FINGERUP) { |
610 | iTouch *touch = find_TouchState_(d, fing->fingerId); | ||
611 | iForEach(Array, i, d->touches) { | 613 | iForEach(Array, i, d->touches) { |
612 | iTouch *touch = i.value; | 614 | iTouch *touch = i.value; |
613 | if (touch->id != fing->fingerId) { | 615 | if (touch->id != fing->fingerId) { |