Reset dead keys when the SDL window loses focus, so dead keys pressed in SDL applications don't affect text input into other applications.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index 8b5fbec..ecd3619 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -451,6 +451,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
if (SDL_GetKeyboardFocus() == data->window) {
SDL_SetKeyboardFocus(NULL);
+ WIN_ResetDeadKeys();
}
ClipCursor(NULL);
diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c
index de72ad7..8271b04 100644
--- a/src/video/windows/SDL_windowskeyboard.c
+++ b/src/video/windows/SDL_windowskeyboard.c
@@ -165,7 +165,6 @@ WIN_ResetDeadKeys()
this tries to undo the effect pressing the deadkey.
see: http://archives.miloush.net/michkap/archive/2006/09/10/748775.html
*/
-
BYTE keyboardState[256];
WCHAR buffer[16];
int keycode, scancode, result, i;
@@ -174,17 +173,14 @@ WIN_ResetDeadKeys()
keycode = VK_SPACE;
scancode = MapVirtualKey(keycode, MAPVK_VK_TO_VSC);
- if (scancode == 0)
- {
+ if (scancode == 0) {
/* the keyboard doesn't have this key */
return;
}
- for (i = 0; i < 5; i++)
- {
+ for (i = 0; i < 5; i++) {
result = ToUnicode(keycode, scancode, keyboardState, (LPWSTR)buffer, 16, 0);
- if (result > 0)
- {
+ if (result > 0) {
/* success */
return;
}
diff --git a/src/video/windows/SDL_windowskeyboard.h b/src/video/windows/SDL_windowskeyboard.h
index d330d38..84654d7 100644
--- a/src/video/windows/SDL_windowskeyboard.h
+++ b/src/video/windows/SDL_windowskeyboard.h
@@ -27,6 +27,8 @@ extern void WIN_InitKeyboard(_THIS);
extern void WIN_UpdateKeymap(void);
extern void WIN_QuitKeyboard(_THIS);
+extern void WIN_ResetDeadKeys(void);
+
extern void WIN_StartTextInput(_THIS);
extern void WIN_StopTextInput(_THIS);
extern void WIN_SetTextInputRect(_THIS, SDL_Rect *rect);