src/events/SDL_mouse.c
changeset 10390 420482621a34
parent 10366 e1b52e69578b
child 10499 363c1c7e7a41
     1.1 --- a/src/events/SDL_mouse.c	Thu Sep 29 23:42:18 2016 -0400
     1.2 +++ b/src/events/SDL_mouse.c	Fri Sep 30 23:30:54 2016 +0200
     1.3 @@ -358,22 +358,26 @@
     1.4  
     1.5      if (clicks < 0) {
     1.6          SDL_MouseClickState *clickstate = GetMouseClickState(mouse, button);
     1.7 -        if (state == SDL_PRESSED) {
     1.8 -            Uint32 now = SDL_GetTicks();
     1.9 +        if (clickstate) {
    1.10 +            if (state == SDL_PRESSED) {
    1.11 +                Uint32 now = SDL_GetTicks();
    1.12  
    1.13 -            if (SDL_TICKS_PASSED(now, clickstate->last_timestamp + SDL_double_click_time) ||
    1.14 -                SDL_abs(mouse->x - clickstate->last_x) > SDL_double_click_radius ||
    1.15 -                SDL_abs(mouse->y - clickstate->last_y) > SDL_double_click_radius) {
    1.16 -                clickstate->click_count = 0;
    1.17 +                if (SDL_TICKS_PASSED(now, clickstate->last_timestamp + SDL_double_click_time) ||
    1.18 +                    SDL_abs(mouse->x - clickstate->last_x) > SDL_double_click_radius ||
    1.19 +                    SDL_abs(mouse->y - clickstate->last_y) > SDL_double_click_radius) {
    1.20 +                    clickstate->click_count = 0;
    1.21 +                }
    1.22 +                clickstate->last_timestamp = now;
    1.23 +                clickstate->last_x = mouse->x;
    1.24 +                clickstate->last_y = mouse->y;
    1.25 +                if (clickstate->click_count < 255) {
    1.26 +                    ++clickstate->click_count;
    1.27 +                }
    1.28              }
    1.29 -            clickstate->last_timestamp = now;
    1.30 -            clickstate->last_x = mouse->x;
    1.31 -            clickstate->last_y = mouse->y;
    1.32 -            if (clickstate->click_count < 255) {
    1.33 -                ++clickstate->click_count;
    1.34 -            }
    1.35 +            clicks = clickstate->click_count;
    1.36 +        } else {
    1.37 +            clicks = 1;
    1.38          }
    1.39 -        clicks = clickstate->click_count;
    1.40      }
    1.41  
    1.42      /* Post the event, if desired */