Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Reset the keyboard before we lose focus so the correct window is list…
Browse files Browse the repository at this point in the history
…ed in focus events.
  • Loading branch information
slouken committed Nov 8, 2012
1 parent e20db11 commit 6c83a63
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/events/SDL_keyboard.c
Expand Up @@ -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,
Expand All @@ -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();
}
}

Expand Down

0 comments on commit 6c83a63

Please sign in to comment.