Skip to content

Commit

Permalink
We should still set the text input area if SDL_DISABLE_WINDOWS_IME is…
Browse files Browse the repository at this point in the history
… defined

Fixes libsdl-org#6254
  • Loading branch information
slouken committed Jun 29, 2024
1 parent 9332de9 commit 422e0cf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
24 changes: 14 additions & 10 deletions src/video/windows/SDL_windowskeyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/video/windows/SDL_windowsvideo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 */
Expand Down

0 comments on commit 422e0cf

Please sign in to comment.