src/video/win32/SDL_win32keyboard.c
changeset 4753 11b0a6a3eb4d
parent 4752 dc7bdcf06367
child 4759 863ba7d1f029
--- a/src/video/win32/SDL_win32keyboard.c	Mon Jul 12 11:33:27 2010 -0400
+++ b/src/video/win32/SDL_win32keyboard.c	Mon Jul 12 14:17:43 2010 -0400
@@ -141,21 +141,29 @@
 }
 
 void
-WIN_StartTextInput(_THIS, SDL_Window *window)
+WIN_StartTextInput(_THIS)
 {
-    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
-    SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
-    IME_Init(videodata, hwnd);
-    IME_Enable(videodata, hwnd);
+    SDL_Window *window = SDL_GetKeyboardFocus();
+    if (window)
+    {
+        HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
+        SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
+        IME_Init(videodata, hwnd);
+        IME_Enable(videodata, hwnd);
+    }
 }
 
 void
-WIN_StopTextInput(_THIS, SDL_Window *window)
+WIN_StopTextInput(_THIS)
 {
-    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
-    SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
-    IME_Init(videodata, hwnd);
-    IME_Disable(videodata, hwnd);
+    SDL_Window *window = SDL_GetKeyboardFocus();
+    if (window)
+    {
+        HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
+        SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
+        IME_Init(videodata, hwnd);
+        IME_Disable(videodata, hwnd);
+    }
 }
 
 void