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 9641 425c1100b496
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
--- a/src/video/windows/SDL_windowsevents.c	Tue May 26 20:36:45 2015 -0400
+++ b/src/video/windows/SDL_windowsevents.c	Tue May 26 20:40:00 2015 -0400
@@ -549,6 +549,16 @@
     case WM_SYSKEYDOWN:
         {
             SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam);
+            const Uint8 *keyboardState = SDL_GetKeyboardState(NULL);
+
+            /* Detect relevant keyboard shortcuts */
+            if (keyboardState[SDL_SCANCODE_LALT] == SDL_PRESSED || keyboardState[SDL_SCANCODE_RALT] == SDL_PRESSED) {
+                /* ALT+F4: Close window */
+                if (code == SDL_SCANCODE_F4) {
+                    SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0);
+                }
+            }
+
             if (code != SDL_SCANCODE_UNKNOWN) {
                 SDL_SendKeyboardKey(SDL_PRESSED, code);
             }
@@ -577,14 +587,6 @@
             SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam);
             const Uint8 *keyboardState = SDL_GetKeyboardState(NULL);
 
-            /* Detect relevant keyboard shortcuts */
-            if (keyboardState[SDL_SCANCODE_LALT] == SDL_PRESSED || keyboardState[SDL_SCANCODE_RALT] == SDL_PRESSED) {
-                /* ALT+F4: Close window */
-                if (code == SDL_SCANCODE_F4) {
-                    SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0);
-                }
-            }
-
             if (code != SDL_SCANCODE_UNKNOWN) {
                 if (code == SDL_SCANCODE_PRINTSCREEN &&
                     keyboardState[code] == SDL_RELEASED) {