Skip to content

Commit b608108

Browse files
Susko3slouken
authored andcommitted
Properly fix cursor position in Korean IME
1 parent b5ac641 commit b608108

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/video/windows/SDL_windowskeyboard.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,11 @@ static void IME_GetCompositionString(SDL_VideoData *videodata, HIMC himc, LPARAM
828828
}
829829
length /= sizeof(WCHAR);
830830

831+
if (!(*lParam & GCS_CURSORPOS)) {
832+
// If the IME doesn't support GCS_CURSORPOS, default the cursor to the end of the composition.
833+
videodata->ime_cursor = length;
834+
}
835+
831836
if ((dwLang == LANG_CHT || dwLang == LANG_CHS) &&
832837
videodata->ime_cursor > 0 &&
833838
videodata->ime_cursor < (int)(videodata->ime_composition_length / sizeof(WCHAR)) &&
@@ -889,7 +894,7 @@ static void IME_SendInputEvent(SDL_VideoData *videodata)
889894

890895
videodata->ime_composition[0] = 0;
891896
videodata->ime_readingstring[0] = 0;
892-
videodata->ime_cursor = 1; // Korean IME cursor
897+
videodata->ime_cursor = 0;
893898
}
894899

895900
static void IME_SendEditingEvent(SDL_VideoData *videodata)
@@ -1072,7 +1077,7 @@ bool WIN_HandleIMEMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SD
10721077
} else if (msg == WM_IME_STARTCOMPOSITION) {
10731078
SDL_DebugIMELog("WM_IME_STARTCOMPOSITION");
10741079
if (videodata->ime_internal_composition) {
1075-
videodata->ime_cursor = 1; // Korean IME cursor
1080+
videodata->ime_cursor = 0;
10761081
// Windows may still display a composition dialog even with
10771082
// ISC_SHOWUICOMPOSITIONWINDOW cleared, so trap the message
10781083
// here to prevent that (even when the IME is disabled).

0 commit comments

Comments
 (0)