From b608108593ce3770426bc45be5a48db649d41e79 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Mon, 18 May 2026 17:28:31 +0200 Subject: [PATCH] Properly fix cursor position in Korean IME --- src/video/windows/SDL_windowskeyboard.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c index 6d8cd52458..b114772d85 100644 --- a/src/video/windows/SDL_windowskeyboard.c +++ b/src/video/windows/SDL_windowskeyboard.c @@ -828,6 +828,11 @@ static void IME_GetCompositionString(SDL_VideoData *videodata, HIMC himc, LPARAM } length /= sizeof(WCHAR); + if (!(*lParam & GCS_CURSORPOS)) { + // If the IME doesn't support GCS_CURSORPOS, default the cursor to the end of the composition. + videodata->ime_cursor = length; + } + if ((dwLang == LANG_CHT || dwLang == LANG_CHS) && videodata->ime_cursor > 0 && videodata->ime_cursor < (int)(videodata->ime_composition_length / sizeof(WCHAR)) && @@ -889,7 +894,7 @@ static void IME_SendInputEvent(SDL_VideoData *videodata) videodata->ime_composition[0] = 0; videodata->ime_readingstring[0] = 0; - videodata->ime_cursor = 1; // Korean IME cursor + videodata->ime_cursor = 0; } static void IME_SendEditingEvent(SDL_VideoData *videodata) @@ -1072,7 +1077,7 @@ bool WIN_HandleIMEMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SD } else if (msg == WM_IME_STARTCOMPOSITION) { SDL_DebugIMELog("WM_IME_STARTCOMPOSITION"); if (videodata->ime_internal_composition) { - videodata->ime_cursor = 1; // Korean IME cursor + videodata->ime_cursor = 0; // Windows may still display a composition dialog even with // ISC_SHOWUICOMPOSITIONWINDOW cleared, so trap the message // here to prevent that (even when the IME is disabled).