Skip to content

Commit 0c57adf

Browse files
xfangfangashie
authored andcommitted
WIN32: Better support for IME
1 parent 7ae1427 commit 0c57adf

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

src/win32_init.c

+2
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ static GLFWbool loadLibraries(void)
186186
_glfwPlatformGetModuleSymbol(_glfw.win32.imm32.instance, "ImmNotifyIME");
187187
_glfw.win32.imm32.ImmReleaseContext_ = (PFN_ImmReleaseContext)
188188
_glfwPlatformGetModuleSymbol(_glfw.win32.imm32.instance, "ImmReleaseContext");
189+
_glfw.win32.imm32.ImmSetCompositionWindow_ = (PFN_ImmSetCompositionWindow)
190+
_glfwPlatformGetModuleSymbol(_glfw.win32.imm32.instance, "ImmSetCompositionWindow");
189191
_glfw.win32.imm32.ImmSetCandidateWindow_ = (PFN_ImmSetCandidateWindow)
190192
_glfwPlatformGetModuleSymbol(_glfw.win32.imm32.instance, "ImmSetCandidateWindow");
191193
_glfw.win32.imm32.ImmSetOpenStatus_ = (PFN_ImmSetOpenStatus)

src/win32_platform.h

+3
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ typedef UINT (WINAPI * PFN_ImmGetDescriptionW)(HKL,LPWSTR,UINT);
326326
typedef BOOL (WINAPI * PFN_ImmGetOpenStatus)(HIMC);
327327
typedef BOOL (WINAPI * PFN_ImmNotifyIME)(HIMC,DWORD,DWORD,DWORD);
328328
typedef BOOL (WINAPI * PFN_ImmReleaseContext)(HWND,HIMC);
329+
typedef BOOL (WINAPI * PFN_ImmSetCompositionWindow)(HIMC,LPCOMPOSITIONFORM);
329330
typedef BOOL (WINAPI * PFN_ImmSetCandidateWindow)(HIMC,LPCANDIDATEFORM);
330331
typedef BOOL (WINAPI * PFN_ImmSetOpenStatus)(HIMC,BOOL);
331332
#define ImmGetCandidateListW _glfw.win32.imm32.ImmGetCandidateListW_
@@ -336,6 +337,7 @@ typedef BOOL (WINAPI * PFN_ImmSetOpenStatus)(HIMC,BOOL);
336337
#define ImmGetOpenStatus _glfw.win32.imm32.ImmGetOpenStatus_
337338
#define ImmNotifyIME _glfw.win32.imm32.ImmNotifyIME_
338339
#define ImmReleaseContext _glfw.win32.imm32.ImmReleaseContext_
340+
#define ImmSetCompositionWindow _glfw.win32.imm32.ImmSetCompositionWindow_
339341
#define ImmSetCandidateWindow _glfw.win32.imm32.ImmSetCandidateWindow_
340342
#define ImmSetOpenStatus _glfw.win32.imm32.ImmSetOpenStatus_
341343

@@ -536,6 +538,7 @@ typedef struct _GLFWlibraryWin32
536538
PFN_ImmGetOpenStatus ImmGetOpenStatus_;
537539
PFN_ImmNotifyIME ImmNotifyIME_;
538540
PFN_ImmReleaseContext ImmReleaseContext_;
541+
PFN_ImmSetCompositionWindow ImmSetCompositionWindow_;
539542
PFN_ImmSetCandidateWindow ImmSetCandidateWindow_;
540543
PFN_ImmSetOpenStatus ImmSetOpenStatus_;
541544
} imm32;

src/win32_window.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -2867,8 +2867,11 @@ void _glfwUpdatePreeditCursorRectangleWin32(_GLFWwindow* window)
28672867
int y = preedit->cursorPosY;
28682868
int w = preedit->cursorWidth;
28692869
int h = preedit->cursorHeight;
2870-
CANDIDATEFORM excludeRect = { 0, CFS_EXCLUDE, { x, y }, { x, y, x + w, y + h } };
28712870

2871+
COMPOSITIONFORM areaRect = { CFS_RECT, { x, y }, { x, y, x + w, y + h } };
2872+
ImmSetCompositionWindow(hIMC, &areaRect);
2873+
2874+
CANDIDATEFORM excludeRect = { 0, CFS_EXCLUDE, { x, y }, { x, y, x + w, y + h } };
28722875
ImmSetCandidateWindow(hIMC, &excludeRect);
28732876

28742877
ImmReleaseContext(hWnd, hIMC);

0 commit comments

Comments
 (0)