From cbdfd31a3c4607501d3869af87695b524b51a911 Mon Sep 17 00:00:00 2001 From: michi_cc Date: Mon, 5 Aug 2013 20:37:18 +0000 Subject: (svn r25682) -Change: [Win32] Position the IME candidate window at the caret position. --- src/video/win32_v.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src/video/win32_v.cpp') diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index f7394ba99..a6ca85c97 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -523,6 +523,40 @@ static void SetCompositionPos(HWND hwnd) ImmReleaseContext(hwnd, hIMC); } +/** Set the position of the candidate window. */ +static void SetCandidatePos(HWND hwnd) +{ + HIMC hIMC = ImmGetContext(hwnd); + if (hIMC != NULL) { + CANDIDATEFORM cf; + cf.dwIndex = 0; + cf.dwStyle = CFS_EXCLUDE; + + if (EditBoxInGlobalFocus()) { + Point pt = _focused_window->GetCaretPosition(); + cf.ptCurrentPos.x = _focused_window->left + pt.x; + cf.ptCurrentPos.y = _focused_window->top + pt.y; + if (_focused_window->window_class == WC_CONSOLE) { + cf.rcArea.left = _focused_window->left; + cf.rcArea.top = _focused_window->top; + cf.rcArea.right = _focused_window->left + _focused_window->width; + cf.rcArea.bottom = _focused_window->top + _focused_window->height; + } else { + cf.rcArea.left = _focused_window->left + _focused_window->nested_focus->pos_x; + cf.rcArea.top = _focused_window->top + _focused_window->nested_focus->pos_y; + cf.rcArea.right = cf.rcArea.left + _focused_window->nested_focus->current_x; + cf.rcArea.bottom = cf.rcArea.top + _focused_window->nested_focus->current_y; + } + } else { + cf.ptCurrentPos.x = 0; + cf.ptCurrentPos.y = 0; + SetRectEmpty(&cf.rcArea); + } + ImmSetCandidateWindow(hIMC, &cf); + } + ImmReleaseContext(hwnd, hIMC); +} + /** Handle WM_IME_COMPOSITION messages. */ static LRESULT HandleIMEComposition(HWND hwnd, WPARAM wParam, LPARAM lParam) { @@ -560,6 +594,7 @@ static void CancelIMEComposition(HWND hwnd) #else static void SetCompositionPos(HWND hwnd) {} +static void SetCandidatePos(HWND hwnd) {} static void CancelIMEComposition(HWND hwnd) {} #endif /* !defined(WINCE) || _WIN32_WCE >= 0x400 */ @@ -707,6 +742,10 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP case WM_IME_COMPOSITION: return HandleIMEComposition(hwnd, wParam, lParam); + case WM_IME_NOTIFY: + if (wParam == IMN_OPENCANDIDATE) SetCandidatePos(hwnd); + break; + #if !defined(UNICODE) case WM_IME_CHAR: if (GB(wParam, 8, 8) != 0) { @@ -1252,4 +1291,5 @@ void VideoDriver_Win32::EditBoxLostFocus() { CancelIMEComposition(_wnd.main_wnd); SetCompositionPos(_wnd.main_wnd); + SetCandidatePos(_wnd.main_wnd); } -- cgit v1.2.3-54-g00ecf