Reset the keyboard before we lose focus so the correct window is listed in focus events.
authorSam Lantinga <slouken@libsdl.org>
Thu, 08 Nov 2012 01:07:29 -0800
changeset 6665 c0ea8c57034c
parent 6664 2deb17aefbaf
child 6666 018f8019ce36
Reset the keyboard before we lose focus so the correct window is listed in focus events.
src/events/SDL_keyboard.c
--- a/src/events/SDL_keyboard.c	Wed Nov 07 20:17:27 2012 -0800
+++ b/src/events/SDL_keyboard.c	Thu Nov 08 01:07:29 2012 -0800
@@ -612,6 +612,11 @@
 {
     SDL_Keyboard *keyboard = &SDL_keyboard;
 
+    if (keyboard->focus && !window) {
+        /* We won't get anymore keyboard messages, so reset keyboard state */
+        SDL_ResetKeyboard();
+    }
+
     /* See if the current window has lost focus */
     if (keyboard->focus && keyboard->focus != window) {
         SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_LOST,
@@ -638,9 +643,6 @@
                 video->StartTextInput(video);
             }
         }
-    } else {
-        /* We won't get anymore keyboard messages, so reset keyboard state */
-        SDL_ResetKeyboard();
     }
 }