mirror of
https://github.com/glfw/glfw.git
synced 2025-06-14 19:52:14 +00:00
Win32: Add preedit commit logic
Make committed preedit data output to `character` callback, which is set at `glfwSetCharCallback`.
This commit is contained in:
parent
853b68fed7
commit
4cdabc29f2
@ -636,6 +636,37 @@ static GLFWbool getImmPreedit(_GLFWwindow* window)
|
|||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GLFWbool commitImmPreedit(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
HIMC hIMC;
|
||||||
|
LONG preeditBytes;
|
||||||
|
|
||||||
|
if (!window->callbacks.character)
|
||||||
|
return GLFW_FALSE;
|
||||||
|
|
||||||
|
hIMC = ImmGetContext(window->win32.handle);
|
||||||
|
// get preedit data sizes
|
||||||
|
preeditBytes = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
|
||||||
|
|
||||||
|
if (preeditBytes > 0)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int length = preeditBytes / sizeof(WCHAR);
|
||||||
|
LPWSTR buffer = _glfw_calloc(preeditBytes, 1);
|
||||||
|
|
||||||
|
// get preedit data
|
||||||
|
ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, buffer, preeditBytes);
|
||||||
|
|
||||||
|
for (i = 0; i < length; i++)
|
||||||
|
window->callbacks.character((GLFWwindow*) window, buffer[i]);
|
||||||
|
|
||||||
|
_glfw_free(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImmReleaseContext(window->win32.handle, hIMC);
|
||||||
|
return GLFW_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
// Window callback function (handles window messages)
|
// Window callback function (handles window messages)
|
||||||
//
|
//
|
||||||
static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
@ -937,6 +968,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
|||||||
window->nblocks = 0;
|
window->nblocks = 0;
|
||||||
window->ntext = 0;
|
window->ntext = 0;
|
||||||
_glfwInputPreedit(window, 0);
|
_glfwInputPreedit(window, 0);
|
||||||
|
commitImmPreedit(window);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
if (lParam & GCS_COMPSTR)
|
if (lParam & GCS_COMPSTR)
|
||||||
|
Loading…
Reference in New Issue
Block a user