(svn r25682) -Change: [Win32] Position the IME candidate window at the caret position.

This commit is contained in:
michi_cc 2013-08-05 20:37:18 +00:00
parent da09fd3077
commit cbdfd31a3c
1 changed files with 40 additions and 0 deletions

View File

@ -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);
}