From 1cbfe93520d73605b92110a51ac1f8636a50cea3 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 5 Jan 2022 13:27:48 +0100 Subject: [PATCH] Platform IME: [windows] call ImmSetCandidateWindow() to position candidate window. --- docs/CHANGELOG.txt | 1 + imgui.cpp | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 305864e8..4c427303 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -61,6 +61,7 @@ Other Changes: - Platform IME: changed io.ImeSetInputScreenPosFn() to io.SetPlatformImeDataFn() API, now taking a ImGuiPlatformImeData structure which we can more easily extend in the future. - Platform IME: moved io.ImeWindowHandle to GetMainViewport()->PlatformHandleRaw. +- Platform IME: [windows] call ImmSetCandidateWindow() to position candidate window. - Backends: OpenGL3: Fixed a buffer overflow in imgui_impl_opengl3_loader.h init (added in 1.86). (#4468, #4830) [@dymk] It would generally not have noticeable side-effect at runtime but would be detected by runtime checkers. - Backends: Metal: Added Apple Metal C++ API support. (#4824, #4746) [@luigifcruz] diff --git a/imgui.cpp b/imgui.cpp index 2e9bc281..ebde53df 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -11512,11 +11512,16 @@ static void SetPlatformImeDataFn_DefaultImpl(ImGuiViewport* viewport, ImGuiPlatf if (HIMC himc = ::ImmGetContext(hwnd)) { - COMPOSITIONFORM cf; - cf.ptCurrentPos.x = (LONG)data->InputPos.x; - cf.ptCurrentPos.y = (LONG)data->InputPos.y; - cf.dwStyle = CFS_FORCE_POSITION; - ::ImmSetCompositionWindow(himc, &cf); + COMPOSITIONFORM composition_form = {}; + composition_form.ptCurrentPos.x = (LONG)data->InputPos.x; + composition_form.ptCurrentPos.y = (LONG)data->InputPos.y; + composition_form.dwStyle = CFS_FORCE_POSITION; + ::ImmSetCompositionWindow(himc, &composition_form); + CANDIDATEFORM candidate_form = {}; + candidate_form.dwStyle = CFS_CANDIDATEPOS; + candidate_form.ptCurrentPos.x = (LONG)data->InputPos.x; + candidate_form.ptCurrentPos.y = (LONG)data->InputPos.y; + ::ImmSetCandidateWindow(himc, &candidate_form); ::ImmReleaseContext(hwnd, himc); } }