-
Notifications
You must be signed in to change notification settings - Fork 9
/
Windows_IME_Patch.patch
72 lines (69 loc) · 2.15 KB
/
Windows_IME_Patch.patch
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
72
--- a/src/video/windows/SDL_windowskeyboard.c
+++ a/src/video/windows/SDL_windowskeyboard.c
@@ -229,28 +229,37 @@
}
void
+WIN_UpdateTextInputRect(SDL_VideoData *videodata)
+{
+ HIMC himc = ImmGetContext(videodata->ime_hwnd_current);
+ if (!himc)
+ return;
+
+ CANDIDATEFORM cf;
+ cf.dwIndex = 0;
+ cf.dwStyle = CFS_EXCLUDE;
+ cf.ptCurrentPos.x = videodata->ime_rect.x;
+ cf.ptCurrentPos.y = videodata->ime_rect.y;
+ cf.rcArea.left = videodata->ime_rect.x;
+ cf.rcArea.top = videodata->ime_rect.y;
+ cf.rcArea.right = videodata->ime_rect.x + videodata->ime_rect.w;
+ cf.rcArea.bottom = videodata->ime_rect.y + videodata->ime_rect.h;
+ ImmSetCandidateWindow(himc, &cf);
+
+ ImmReleaseContext(videodata->ime_hwnd_current, himc);
+}
+
+void
WIN_SetTextInputRect(_THIS, SDL_Rect *rect)
{
- SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
- HIMC himc = 0;
-
if (!rect) {
SDL_InvalidParamError("rect");
return;
}
+ SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
videodata->ime_rect = *rect;
-
- himc = ImmGetContext(videodata->ime_hwnd_current);
- if (himc)
- {
- COMPOSITIONFORM cf;
- cf.ptCurrentPos.x = videodata->ime_rect.x;
- cf.ptCurrentPos.y = videodata->ime_rect.y;
- cf.dwStyle = CFS_FORCE_POSITION;
- ImmSetCompositionWindow(himc, &cf);
- ImmReleaseContext(videodata->ime_hwnd_current, himc);
- }
+ WIN_UpdateTextInputRect(videodata);
}
#ifdef SDL_DISABLE_WINDOWS_IME
@@ -370,7 +379,8 @@
videodata->ime_available = SDL_TRUE;
IME_UpdateInputLocale(videodata);
IME_SetupAPI(videodata);
- videodata->ime_uiless = UILess_SetupSinks(videodata);
+ // FIXME: the implementation of UILess IME is incomplete so we disable it by commenting this out:
+ //videodata->ime_uiless = UILess_SetupSinks(videodata);
IME_UpdateInputLocale(videodata);
IME_Disable(videodata, hwnd);
}
@@ -882,6 +892,7 @@
*lParam = 0;
break;
case WM_IME_STARTCOMPOSITION:
+ WIN_UpdateTextInputRect(videodata);
trap = SDL_TRUE;
break;
case WM_IME_COMPOSITION: