Center the composition text in the text input area

This commit is contained in:
Sam Lantinga 2024-06-28 17:08:54 -07:00
parent 4c7db129df
commit a7d4f0a76c
1 changed files with 10 additions and 1 deletions

View File

@ -656,11 +656,17 @@ static void IME_SetTextInputArea(SDL_VideoData *videodata, const SDL_Rect *rect,
if (himc) {
COMPOSITIONFORM cof;
CANDIDATEFORM caf;
int font_height = rect->h;
LOGFONTW font;
if (ImmGetCompositionFontW(himc, &font)) {
font_height = font.lfHeight;
}
SDL_zero(cof);
cof.dwStyle = CFS_RECT;
cof.ptCurrentPos.x = rect->x + cursor;
cof.ptCurrentPos.y = rect->y;
cof.ptCurrentPos.y = rect->y + (rect->h - font_height) / 2;
cof.rcArea.left = rect->x;
cof.rcArea.right = (LONG)rect->x + rect->w;
cof.rcArea.top = rect->y;
@ -1055,6 +1061,9 @@ SDL_bool WIN_HandleIMEMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam
case IMN_SETCOMPOSITIONWINDOW:
SDL_DebugIMELog("IMN_SETCOMPOSITIONWINDOW\n");
break;
case IMN_SETCOMPOSITIONFONT:
SDL_DebugIMELog("IMN_SETCOMPOSITIONFONT\n");
break;
case IMN_SETCANDIDATEPOS:
SDL_DebugIMELog("IMN_SETCANDIDATEPOS\n");
break;