Added: Support for showing the IME Candidate Window on Windows
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
diff --git a/include/SDL_hints.h b/include/SDL_hints.h
index 3d5216c..2c4818c 100644
--- a/include/SDL_hints.h
+++ b/include/SDL_hints.h
@@ -558,6 +558,15 @@ extern "C" {
#define SDL_HINT_IME_INTERNAL_EDITING "SDL_IME_INTERNAL_EDITING"
/**
+ * \brief A variable to control whether certain IMEs should show native UI components (such as the Candidate List) instead of suppressing them.
+ *
+ * The variable can be set to the following values:
+ * "0" - Native UI components are not display. (default)
+ * "1" - Native UI components are displayed.
+ */
+#define SDL_HINT_IME_SHOW_UI "SDL_IME_SHOW_UI"
+
+/**
* \brief A variable controlling whether the home indicator bar on iPhone X
* should be hidden.
*
diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c
index 52d2bbe..c5b1db2 100644
--- a/src/video/windows/SDL_windowskeyboard.c
+++ b/src/video/windows/SDL_windowskeyboard.c
@@ -23,6 +23,7 @@
#if SDL_VIDEO_DRIVER_WINDOWS
#include "SDL_windowsvideo.h"
+#include "SDL_hints.h"
#include "../../events/SDL_keyboard_c.h"
#include "../../events/scancodes_windows.h"
@@ -245,15 +246,23 @@ WIN_SetTextInputRect(_THIS, SDL_Rect *rect)
himc = ImmGetContext(videodata->ime_hwnd_current);
if (himc)
{
- COMPOSITIONFORM cf;
+ CANDIDATEFORM cf;
+ cf.dwIndex = 0;
+ cf.dwStyle = CFS_POINT;
cf.ptCurrentPos.x = videodata->ime_rect.x;
cf.ptCurrentPos.y = videodata->ime_rect.y;
- cf.dwStyle = CFS_FORCE_POSITION;
- ImmSetCompositionWindow(himc, &cf);
+
+ ImmSetCandidateWindow(himc, &cf);
ImmReleaseContext(videodata->ime_hwnd_current, himc);
}
}
+static SDL_bool
+WIN_ShouldShowNativeUI()
+{
+ return SDL_GetHintBoolean(SDL_HINT_IME_SHOW_UI, SDL_FALSE);
+}
+
#ifdef SDL_DISABLE_WINDOWS_IME
@@ -371,7 +380,10 @@ IME_Init(SDL_VideoData *videodata, HWND hwnd)
videodata->ime_available = SDL_TRUE;
IME_UpdateInputLocale(videodata);
IME_SetupAPI(videodata);
- videodata->ime_uiless = UILess_SetupSinks(videodata);
+ if (WIN_ShouldShowNativeUI())
+ videodata->ime_uiless = SDL_FALSE;
+ else
+ videodata->ime_uiless = UILess_SetupSinks(videodata);
IME_UpdateInputLocale(videodata);
IME_Disable(videodata, hwnd);
}