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

Fixes https://github.com/libsdl-org/SDL/issues/6254
This commit is contained in:
Sam Lantinga
2024-06-28 18:00:48 -07:00
parent 9332de9f25
commit e47179c4c7
2 changed files with 16 additions and 11 deletions

View File

@@ -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);

View File

@@ -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 */