diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-06-13 15:26:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-13 15:26:50 +0200 |
commit | d6d8237a5a976317493b9759868c6246c22f39c9 (patch) | |
tree | 55f5622e88e75761adf2ac746d7e9b8bd07a3c50 /platform/windows/os_windows.cpp | |
parent | 7bb6b39c10135119f9510a6f43f929be5dbeceaa (diff) | |
parent | c5bdb5b1d8893abaf171520412479fb31a697a41 (diff) |
Merge pull request #19509 from SaracenOne/ime
IME context detection.
Diffstat (limited to 'platform/windows/os_windows.cpp')
-rw-r--r-- | platform/windows/os_windows.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 3e0c4a7c0c..ca6c793d5d 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1181,6 +1181,15 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int if (p_desired.layered_splash) { set_window_per_pixel_transparency_enabled(true); } + + // IME + im_himc = ImmGetContext(hWnd); + ImmReleaseContext(hWnd, im_himc); + + im_position = Vector2(); + + set_ime_active(false); + return OK; } @@ -2659,13 +2668,29 @@ String OS_Windows::get_unique_id() const { return String(HwProfInfo.szHwProfileGuid); } +void OS_Windows::set_ime_active(const bool p_active) { + + if (p_active) { + ImmAssociateContext(hWnd, im_himc); + + set_ime_position(im_position); + } else { + ImmAssociateContext(hWnd, (HIMC)0); + } +} + void OS_Windows::set_ime_position(const Point2 &p_pos) { + im_position = p_pos; + HIMC himc = ImmGetContext(hWnd); + if (himc == (HIMC)0) + return; + COMPOSITIONFORM cps; cps.dwStyle = CFS_FORCE_POSITION; - cps.ptCurrentPos.x = p_pos.x; - cps.ptCurrentPos.y = p_pos.y; + cps.ptCurrentPos.x = im_position.x; + cps.ptCurrentPos.y = im_position.y; ImmSetCompositionWindow(himc, &cps); ImmReleaseContext(hWnd, himc); } |