Windows: Alt-F4 hotkey should be checked on keydown, not keyup (thanks, Matt!).
authorRyan C. Gordon <icculus@icculus.org>
Tue, 26 May 2015 20:40:00 -0400
changeset 9641425c1100b496
parent 9640 d86771e28c51
child 9642 cd237569d0f6
Windows: Alt-F4 hotkey should be checked on keydown, not keyup (thanks, Matt!).

Fixes Bugzilla #2780.
src/video/windows/SDL_windowsevents.c
     1.1 --- a/src/video/windows/SDL_windowsevents.c	Tue May 26 20:36:45 2015 -0400
     1.2 +++ b/src/video/windows/SDL_windowsevents.c	Tue May 26 20:40:00 2015 -0400
     1.3 @@ -549,6 +549,16 @@
     1.4      case WM_SYSKEYDOWN:
     1.5          {
     1.6              SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam);
     1.7 +            const Uint8 *keyboardState = SDL_GetKeyboardState(NULL);
     1.8 +
     1.9 +            /* Detect relevant keyboard shortcuts */
    1.10 +            if (keyboardState[SDL_SCANCODE_LALT] == SDL_PRESSED || keyboardState[SDL_SCANCODE_RALT] == SDL_PRESSED) {
    1.11 +                /* ALT+F4: Close window */
    1.12 +                if (code == SDL_SCANCODE_F4) {
    1.13 +                    SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0);
    1.14 +                }
    1.15 +            }
    1.16 +
    1.17              if (code != SDL_SCANCODE_UNKNOWN) {
    1.18                  SDL_SendKeyboardKey(SDL_PRESSED, code);
    1.19              }
    1.20 @@ -577,14 +587,6 @@
    1.21              SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam);
    1.22              const Uint8 *keyboardState = SDL_GetKeyboardState(NULL);
    1.23  
    1.24 -            /* Detect relevant keyboard shortcuts */
    1.25 -            if (keyboardState[SDL_SCANCODE_LALT] == SDL_PRESSED || keyboardState[SDL_SCANCODE_RALT] == SDL_PRESSED) {
    1.26 -                /* ALT+F4: Close window */
    1.27 -                if (code == SDL_SCANCODE_F4) {
    1.28 -                    SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0);
    1.29 -                }
    1.30 -            }
    1.31 -
    1.32              if (code != SDL_SCANCODE_UNKNOWN) {
    1.33                  if (code == SDL_SCANCODE_PRINTSCREEN &&
    1.34                      keyboardState[code] == SDL_RELEASED) {