Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIN32: Better support for IME #4

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/win32_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ static GLFWbool loadLibraries(void)
_glfwPlatformGetModuleSymbol(_glfw.win32.imm32.instance, "ImmNotifyIME");
_glfw.win32.imm32.ImmReleaseContext_ = (PFN_ImmReleaseContext)
_glfwPlatformGetModuleSymbol(_glfw.win32.imm32.instance, "ImmReleaseContext");
_glfw.win32.imm32.ImmSetCompositionWindow_ = (PFN_ImmSetCompositionWindow)
_glfwPlatformGetModuleSymbol(_glfw.win32.imm32.instance, "ImmSetCompositionWindow");
_glfw.win32.imm32.ImmSetCandidateWindow_ = (PFN_ImmSetCandidateWindow)
_glfwPlatformGetModuleSymbol(_glfw.win32.imm32.instance, "ImmSetCandidateWindow");
_glfw.win32.imm32.ImmSetOpenStatus_ = (PFN_ImmSetOpenStatus)
Expand Down
3 changes: 3 additions & 0 deletions src/win32_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ typedef UINT (WINAPI * PFN_ImmGetDescriptionW)(HKL,LPWSTR,UINT);
typedef BOOL (WINAPI * PFN_ImmGetOpenStatus)(HIMC);
typedef BOOL (WINAPI * PFN_ImmNotifyIME)(HIMC,DWORD,DWORD,DWORD);
typedef BOOL (WINAPI * PFN_ImmReleaseContext)(HWND,HIMC);
typedef BOOL (WINAPI * PFN_ImmSetCompositionWindow)(HIMC,LPCOMPOSITIONFORM);
typedef BOOL (WINAPI * PFN_ImmSetCandidateWindow)(HIMC,LPCANDIDATEFORM);
typedef BOOL (WINAPI * PFN_ImmSetOpenStatus)(HIMC,BOOL);
#define ImmGetCandidateListW _glfw.win32.imm32.ImmGetCandidateListW_
Expand All @@ -336,6 +337,7 @@ typedef BOOL (WINAPI * PFN_ImmSetOpenStatus)(HIMC,BOOL);
#define ImmGetOpenStatus _glfw.win32.imm32.ImmGetOpenStatus_
#define ImmNotifyIME _glfw.win32.imm32.ImmNotifyIME_
#define ImmReleaseContext _glfw.win32.imm32.ImmReleaseContext_
#define ImmSetCompositionWindow _glfw.win32.imm32.ImmSetCompositionWindow_
#define ImmSetCandidateWindow _glfw.win32.imm32.ImmSetCandidateWindow_
#define ImmSetOpenStatus _glfw.win32.imm32.ImmSetOpenStatus_

Expand Down Expand Up @@ -536,6 +538,7 @@ typedef struct _GLFWlibraryWin32
PFN_ImmGetOpenStatus ImmGetOpenStatus_;
PFN_ImmNotifyIME ImmNotifyIME_;
PFN_ImmReleaseContext ImmReleaseContext_;
PFN_ImmSetCompositionWindow ImmSetCompositionWindow_;
PFN_ImmSetCandidateWindow ImmSetCandidateWindow_;
PFN_ImmSetOpenStatus ImmSetOpenStatus_;
} imm32;
Expand Down
5 changes: 4 additions & 1 deletion src/win32_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -2867,8 +2867,11 @@ void _glfwUpdatePreeditCursorRectangleWin32(_GLFWwindow* window)
int y = preedit->cursorPosY;
int w = preedit->cursorWidth;
int h = preedit->cursorHeight;
CANDIDATEFORM excludeRect = { 0, CFS_EXCLUDE, { x, y }, { x, y, x + w, y + h } };

COMPOSITIONFORM areaRect = { CFS_RECT, { x, y }, { x, y, x + w, y + h } };
ImmSetCompositionWindow(hIMC, &areaRect);

CANDIDATEFORM excludeRect = { 0, CFS_EXCLUDE, { x, y }, { x, y, x + w, y + h } };
ImmSetCandidateWindow(hIMC, &excludeRect);

ImmReleaseContext(hWnd, hIMC);
Expand Down