diff options
Diffstat (limited to 'src/ui/touch.c')
-rw-r--r-- | src/ui/touch.c | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/ui/touch.c b/src/ui/touch.c index dbb16bd5..9b47d0fe 100644 --- a/src/ui/touch.c +++ b/src/ui/touch.c | |||
@@ -212,9 +212,23 @@ iBool processEvent_Touch(const SDL_Event *ev) { | |||
212 | edge = right_TouchEdge; | 212 | edge = right_TouchEdge; |
213 | } | 213 | } |
214 | iWidget *aff = hitChild_Widget(window->root, init_I2(iRound(x), iRound(y_F3(pos)))); | 214 | iWidget *aff = hitChild_Widget(window->root, init_I2(iRound(x), iRound(y_F3(pos)))); |
215 | if (flags_Widget(aff) & touchDrag_WidgetFlag) { | ||
216 | dispatchEvent_Widget(window->root, (SDL_Event *) &(SDL_MouseButtonEvent){ | ||
217 | .type = SDL_MOUSEBUTTONDOWN, | ||
218 | .timestamp = fing->timestamp, | ||
219 | .clicks = 1, | ||
220 | .state = SDL_PRESSED, | ||
221 | .which = SDL_TOUCH_MOUSEID, | ||
222 | .button = SDL_BUTTON_LEFT, | ||
223 | .x = x_F3(pos), | ||
224 | .y = y_F3(pos) | ||
225 | }); | ||
226 | edge = none_TouchEdge; | ||
227 | } | ||
215 | pushBack_Array(d->touches, &(iTouch){ | 228 | pushBack_Array(d->touches, &(iTouch){ |
216 | .id = fing->fingerId, | 229 | .id = fing->fingerId, |
217 | .affinity = aff, | 230 | .affinity = aff, |
231 | .hasMoved = (flags_Widget(aff) & touchDrag_WidgetFlag) != 0, | ||
218 | .edge = edge, | 232 | .edge = edge, |
219 | .startTime = nowTime, | 233 | .startTime = nowTime, |
220 | .startPos = pos, | 234 | .startPos = pos, |
@@ -223,7 +237,7 @@ iBool processEvent_Touch(const SDL_Event *ev) { | |||
223 | /* Some widgets rely on hover state. */ | 237 | /* Some widgets rely on hover state. */ |
224 | dispatchEvent_Widget(window->root, (SDL_Event *) &(SDL_MouseMotionEvent){ | 238 | dispatchEvent_Widget(window->root, (SDL_Event *) &(SDL_MouseMotionEvent){ |
225 | .type = SDL_MOUSEMOTION, | 239 | .type = SDL_MOUSEMOTION, |
226 | .timestamp = SDL_GetTicks(), | 240 | .timestamp = fing->timestamp, |
227 | .which = SDL_TOUCH_MOUSEID, | 241 | .which = SDL_TOUCH_MOUSEID, |
228 | .x = x_F3(pos), | 242 | .x = x_F3(pos), |
229 | .y = y_F3(pos) | 243 | .y = y_F3(pos) |
@@ -233,6 +247,17 @@ iBool processEvent_Touch(const SDL_Event *ev) { | |||
233 | else if (ev->type == SDL_FINGERMOTION) { | 247 | else if (ev->type == SDL_FINGERMOTION) { |
234 | iTouch *touch = find_TouchState_(d, fing->fingerId); | 248 | iTouch *touch = find_TouchState_(d, fing->fingerId); |
235 | if (touch && touch->affinity) { | 249 | if (touch && touch->affinity) { |
250 | if (flags_Widget(touch->affinity) & touchDrag_WidgetFlag) { | ||
251 | dispatchEvent_Widget(window->root, (SDL_Event *) &(SDL_MouseMotionEvent){ | ||
252 | .type = SDL_MOUSEMOTION, | ||
253 | .timestamp = fing->timestamp, | ||
254 | .which = SDL_TOUCH_MOUSEID, | ||
255 | .state = SDL_BUTTON_LMASK, | ||
256 | .x = x_F3(pos), | ||
257 | .y = y_F3(pos) | ||
258 | }); | ||
259 | return iTrue; | ||
260 | } | ||
236 | /* Update touch position. */ | 261 | /* Update touch position. */ |
237 | pushPos_Touch_(touch, pos, nowTime); | 262 | pushPos_Touch_(touch, pos, nowTime); |
238 | const iFloat3 amount = add_F3(touch->remainder, | 263 | const iFloat3 amount = add_F3(touch->remainder, |
@@ -278,6 +303,20 @@ iBool processEvent_Touch(const SDL_Event *ev) { | |||
278 | if (touch->id != fing->fingerId) { | 303 | if (touch->id != fing->fingerId) { |
279 | continue; | 304 | continue; |
280 | } | 305 | } |
306 | if (flags_Widget(touch->affinity) & touchDrag_WidgetFlag) { | ||
307 | dispatchEvent_Widget(window->root, (SDL_Event *) &(SDL_MouseButtonEvent){ | ||
308 | .type = SDL_MOUSEBUTTONUP, | ||
309 | .timestamp = fing->timestamp, | ||
310 | .clicks = 1, | ||
311 | .state = SDL_RELEASED, | ||
312 | .which = SDL_TOUCH_MOUSEID, | ||
313 | .button = SDL_BUTTON_LEFT, | ||
314 | .x = x_F3(pos), | ||
315 | .y = y_F3(pos) | ||
316 | }); | ||
317 | remove_ArrayIterator(&i); | ||
318 | continue; | ||
319 | } | ||
281 | /* Edge swipes do not generate momentum. */ | 320 | /* Edge swipes do not generate momentum. */ |
282 | const uint32_t duration = nowTime - touch->startTime; | 321 | const uint32_t duration = nowTime - touch->startTime; |
283 | const iFloat3 gestureVector = sub_F3(pos, touch->startPos); | 322 | const iFloat3 gestureVector = sub_F3(pos, touch->startPos); |