Quellcode durchsuchen

We should still set the text input area if SDL_DISABLE_WINDOWS_IME is defined

Fixes https://github.com/libsdl-org/SDL/issues/6254
Sam Lantinga vor 9 Monaten
Ursprung
Commit
e47179c4c7
2 geänderte Dateien mit 16 neuen und 11 gelöschten Zeilen
  1. 14 10
      src/video/windows/SDL_windowskeyboard.c
  2. 2 1
      src/video/windows/SDL_windowsvideo.h

+ 14 - 10
src/video/windows/SDL_windowskeyboard.c

@@ -39,10 +39,12 @@
 static int IME_Init(SDL_VideoData *videodata, SDL_Window *window);
 static void IME_Enable(SDL_VideoData *videodata, HWND hwnd);
 static void IME_Disable(SDL_VideoData *videodata, HWND hwnd);
-static void IME_SetTextInputArea(SDL_VideoData *videodata, const SDL_Rect *rect, int cursor);
+static void IME_SetTextInputArea(SDL_VideoData *videodata, HWND hwnd, const SDL_Rect *rect, int cursor);
 static void IME_ClearComposition(SDL_VideoData *videodata);
 static void IME_GetCandidateList(SDL_VideoData *videodata, HWND hwnd);
 static void IME_Quit(SDL_VideoData *videodata);
+#else
+static void IME_SetTextInputArea(SDL_VideoData *videodata, HWND hwnd, const SDL_Rect *rect, int cursor);
 #endif /* !SDL_DISABLE_WINDOWS_IME */
 
 #ifndef MAPVK_VK_TO_VSC
@@ -231,12 +233,10 @@ int WIN_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window)
 
 int WIN_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window)
 {
-#ifndef SDL_DISABLE_WINDOWS_IME
-    SDL_VideoData *data = _this->driverdata;
-
-    IME_SetTextInputArea(data, &window->text_input_rect, window->text_input_cursor);
-#endif /* !SDL_DISABLE_WINDOWS_IME */
+    SDL_VideoData *videodata = _this->driverdata;
+    SDL_WindowData *data = window->driverdata;
 
+    IME_SetTextInputArea(videodata, data->hwnd, &window->text_input_rect, window->text_input_cursor);
     return 0;
 }
 
@@ -645,14 +645,16 @@ static void IME_SetWindow(SDL_VideoData *videodata, SDL_Window *window)
         SDL_zero(videodata->ime_candidate_area);
     }
 
-    IME_SetTextInputArea(videodata, &window->text_input_rect, window->text_input_cursor);
+    IME_SetTextInputArea(videodata, hwnd, &window->text_input_rect, window->text_input_cursor);
 }
 
-static void IME_SetTextInputArea(SDL_VideoData *videodata, const SDL_Rect *rect, int cursor)
+#endif
+
+static void IME_SetTextInputArea(SDL_VideoData *videodata, HWND hwnd, const SDL_Rect *rect, int cursor)
 {
     HIMC himc;
 
-    himc = ImmGetContext(videodata->ime_hwnd_current);
+    himc = ImmGetContext(hwnd);
     if (himc) {
         COMPOSITIONFORM cof;
         CANDIDATEFORM caf;
@@ -690,10 +692,12 @@ static void IME_SetTextInputArea(SDL_VideoData *videodata, const SDL_Rect *rect,
             ImmSetCandidateWindow(himc, &caf);
         }
 
-        ImmReleaseContext(videodata->ime_hwnd_current, himc);
+        ImmReleaseContext(hwnd, himc);
     }
 }
 
+#ifndef SDL_DISABLE_WINDOWS_IME
+
 static void IME_UpdateInputLocale(SDL_VideoData *videodata)
 {
     HKL hklnext = GetKeyboardLayout(0);

+ 2 - 1
src/video/windows/SDL_windowsvideo.h

@@ -420,7 +420,6 @@ struct SDL_VideoData
     Uint32 raw_input_enabled;
 
 #ifndef SDL_DISABLE_WINDOWS_IME
-    SDL_bool ime_com_initialized;
     SDL_bool ime_initialized;
     SDL_bool ime_enabled;
     SDL_bool ime_available;
@@ -444,10 +443,12 @@ struct SDL_VideoData
     DWORD ime_candsel;
     int ime_candlistindexbase;
     SDL_bool ime_horizontal_candidates;
+#endif
 
     COMPOSITIONFORM ime_composition_area;
     CANDIDATEFORM ime_candidate_area;
 
+#ifndef SDL_DISABLE_WINDOWS_IME
     HKL ime_hkl;
     void *ime_himm32;
     /* *INDENT-OFF* */ /* clang-format off */