src/video/win32/SDL_win32keyboard.c
changeset 4753 11b0a6a3eb4d
parent 4752 dc7bdcf06367
child 4759 863ba7d1f029
     1.1 --- a/src/video/win32/SDL_win32keyboard.c	Mon Jul 12 11:33:27 2010 -0400
     1.2 +++ b/src/video/win32/SDL_win32keyboard.c	Mon Jul 12 14:17:43 2010 -0400
     1.3 @@ -141,21 +141,29 @@
     1.4  }
     1.5  
     1.6  void
     1.7 -WIN_StartTextInput(_THIS, SDL_Window *window)
     1.8 +WIN_StartTextInput(_THIS)
     1.9  {
    1.10 -    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
    1.11 -    SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
    1.12 -    IME_Init(videodata, hwnd);
    1.13 -    IME_Enable(videodata, hwnd);
    1.14 +    SDL_Window *window = SDL_GetKeyboardFocus();
    1.15 +    if (window)
    1.16 +    {
    1.17 +        HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
    1.18 +        SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
    1.19 +        IME_Init(videodata, hwnd);
    1.20 +        IME_Enable(videodata, hwnd);
    1.21 +    }
    1.22  }
    1.23  
    1.24  void
    1.25 -WIN_StopTextInput(_THIS, SDL_Window *window)
    1.26 +WIN_StopTextInput(_THIS)
    1.27  {
    1.28 -    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
    1.29 -    SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
    1.30 -    IME_Init(videodata, hwnd);
    1.31 -    IME_Disable(videodata, hwnd);
    1.32 +    SDL_Window *window = SDL_GetKeyboardFocus();
    1.33 +    if (window)
    1.34 +    {
    1.35 +        HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
    1.36 +        SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
    1.37 +        IME_Init(videodata, hwnd);
    1.38 +        IME_Disable(videodata, hwnd);
    1.39 +    }
    1.40  }
    1.41  
    1.42  void