Implement repositioning the OS-rendered IME with SDL_SetTextInputRect on Windows.
authorColby Klein <shakesoda@gmail.com>
Mon, 15 Jun 2015 20:24:51 -0700
changeset 974459a012991992
parent 9743 5f2ac7cec7e9
child 9745 885b6b5c8426
Implement repositioning the OS-rendered IME with SDL_SetTextInputRect on Windows.
src/video/windows/SDL_windowskeyboard.c
     1.1 --- a/src/video/windows/SDL_windowskeyboard.c	Tue Jun 16 00:57:45 2015 -0400
     1.2 +++ b/src/video/windows/SDL_windowskeyboard.c	Mon Jun 15 20:24:51 2015 -0700
     1.3 @@ -187,6 +187,7 @@
     1.4  WIN_SetTextInputRect(_THIS, SDL_Rect *rect)
     1.5  {
     1.6      SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
     1.7 +    HIMC himc = 0;
     1.8  
     1.9      if (!rect) {
    1.10          SDL_InvalidParamError("rect");
    1.11 @@ -194,6 +195,17 @@
    1.12      }
    1.13  
    1.14      videodata->ime_rect = *rect;
    1.15 +
    1.16 +    himc = ImmGetContext(videodata->ime_hwnd_current);
    1.17 +    if (himc)
    1.18 +    {
    1.19 +        COMPOSITIONFORM cf;
    1.20 +        cf.ptCurrentPos.x = videodata->ime_rect.x;
    1.21 +        cf.ptCurrentPos.y = videodata->ime_rect.y;
    1.22 +        cf.dwStyle = CFS_FORCE_POSITION;
    1.23 +        ImmSetCompositionWindow(himc, &cf);
    1.24 +        ImmReleaseContext(videodata->ime_hwnd_current, himc);
    1.25 +    }
    1.26  }
    1.27  
    1.28  #ifdef SDL_DISABLE_WINDOWS_IME