Procházet zdrojové kódy

Properly fix cursor position in Korean IME

Susko3 před 1 dnem
rodič
revize
b608108593
1 změnil soubory, kde provedl 7 přidání a 2 odebrání
  1. 7 2
      src/video/windows/SDL_windowskeyboard.c

+ 7 - 2
src/video/windows/SDL_windowskeyboard.c

@@ -828,6 +828,11 @@ static void IME_GetCompositionString(SDL_VideoData *videodata, HIMC himc, LPARAM
     }
     }
     length /= sizeof(WCHAR);
     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) &&
     if ((dwLang == LANG_CHT || dwLang == LANG_CHS) &&
         videodata->ime_cursor > 0 &&
         videodata->ime_cursor > 0 &&
         videodata->ime_cursor < (int)(videodata->ime_composition_length / sizeof(WCHAR)) &&
         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_composition[0] = 0;
     videodata->ime_readingstring[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)
 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) {
     } else if (msg == WM_IME_STARTCOMPOSITION) {
         SDL_DebugIMELog("WM_IME_STARTCOMPOSITION");
         SDL_DebugIMELog("WM_IME_STARTCOMPOSITION");
         if (videodata->ime_internal_composition) {
         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
             // Windows may still display a composition dialog even with
             // ISC_SHOWUICOMPOSITIONWINDOW cleared, so trap the message
             // ISC_SHOWUICOMPOSITIONWINDOW cleared, so trap the message
             // here to prevent that (even when the IME is disabled).
             // here to prevent that (even when the IME is disabled).