Emscripten: fix duplicate mousebuttonup/mousebuttondown events when touch events are disabled
authorSylvain Beucler <beuc@beuc.net>
Tue, 29 Jan 2019 12:14:44 +0000
changeset 12572397aa57185c4
parent 12571 aa455cfe9ff3
child 12573 296d155a8ce5
Emscripten: fix duplicate mousebuttonup/mousebuttondown events when touch events are disabled
src/video/emscripten/SDL_emscriptenevents.c
     1.1 --- a/src/video/emscripten/SDL_emscriptenevents.c	Tue Jan 29 12:14:41 2019 +0000
     1.2 +++ b/src/video/emscripten/SDL_emscriptenevents.c	Tue Jan 29 12:14:44 2019 +0000
     1.3 @@ -458,6 +458,7 @@
     1.4              }
     1.5              SDL_SendTouch(deviceId, id, SDL_TRUE, x, y, 1.0f);
     1.6  
     1.7 +            /* disable browser scrolling/pinch-to-zoom if app handles touch events */
     1.8              if (!preventDefault && SDL_GetEventState(SDL_FINGERDOWN) == SDL_ENABLE) {
     1.9                  preventDefault = 1;
    1.10              }
    1.11 @@ -466,10 +467,6 @@
    1.12                  SDL_SendMouseMotion(window_data->window, SDL_TOUCH_MOUSEID, 0, mx, my);
    1.13              }
    1.14              SDL_SendTouchMotion(deviceId, id, x, y, 1.0f);
    1.15 -
    1.16 -            if (!preventDefault && SDL_GetEventState(SDL_FINGERMOTION) == SDL_ENABLE) {
    1.17 -                preventDefault = 1;
    1.18 -            }
    1.19          } else {
    1.20              if ((window_data->finger_touching) && (window_data->first_finger == id)) {
    1.21                  SDL_SendMouseButton(window_data->window, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
    1.22 @@ -477,9 +474,8 @@
    1.23              }
    1.24              SDL_SendTouch(deviceId, id, SDL_FALSE, x, y, 1.0f);
    1.25  
    1.26 -            if (!preventDefault && SDL_GetEventState(SDL_FINGERUP) == SDL_ENABLE) {
    1.27 -                preventDefault = 1;
    1.28 -            }
    1.29 +            /* block browser's simulated mousedown/mouseup on touchscreen devices */
    1.30 +            preventDefault = 1;
    1.31          }
    1.32      }
    1.33