From 6c83a63849ad26c3abb5cddc62429d74fe45816f Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 8 Nov 2012 01:07:29 -0800 Subject: [PATCH] Reset the keyboard before we lose focus so the correct window is listed in focus events. --- src/events/SDL_keyboard.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c index e58f8ba36..9e2b59b1d 100644 --- a/src/events/SDL_keyboard.c +++ b/src/events/SDL_keyboard.c @@ -612,6 +612,11 @@ SDL_SetKeyboardFocus(SDL_Window * window) { 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 @@ SDL_SetKeyboardFocus(SDL_Window * window) video->StartTextInput(video); } } - } else { - /* We won't get anymore keyboard messages, so reset keyboard state */ - SDL_ResetKeyboard(); } }