From 52f0ca1ab6cc149c7232d7daa07fcb0d07a0dbb6 Mon Sep 17 00:00:00 2001 From: Daijiro Fukuda Date: Tue, 24 May 2022 10:45:21 +0900 Subject: [PATCH] Add comments and reshape codes --- src/input.c | 11 ++++++++++- src/win32_window.c | 4 ++++ src/x11_window.c | 23 +++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/input.c b/src/input.c index 704913e5..75614a01 100644 --- a/src/input.c +++ b/src/input.c @@ -313,14 +313,23 @@ void _glfwInputChar(_GLFWwindow* window, uint32_t codepoint, int mods, GLFWbool } } +// Notifies shrared code of a preedit event +// void _glfwInputPreedit(_GLFWwindow* window, int focusedBlock) { if (window->callbacks.preedit) { - window->callbacks.preedit((GLFWwindow*) window, window->ntext, window->preeditText, window->nblocks, window->preeditAttributeBlocks, focusedBlock); + window->callbacks.preedit((GLFWwindow*) window, + window->ntext, + window->preeditText, + window->nblocks, + window->preeditAttributeBlocks, + focusedBlock); } } +// Notifies shared code of a IME status event +// void _glfwInputIMEStatus(_GLFWwindow* window) { if (window->callbacks.imestatus) diff --git a/src/win32_window.c b/src/win32_window.c index e8f19c61..444254cd 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -568,6 +568,8 @@ static void maximizeWindowManually(_GLFWwindow* window) SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED); } +// Get preedit texts of Imm32 and path them to preedit-callback +// static GLFWbool getImmPreedit(_GLFWwindow* window) { HIMC hIMC = ImmGetContext(window->win32.handle); @@ -668,6 +670,8 @@ static GLFWbool getImmPreedit(_GLFWwindow* window) return GLFW_TRUE; } +// Commit the result texts of Imm32 to character-callback +// static GLFWbool commitImmResultStr(_GLFWwindow* window) { HIMC hIMC; diff --git a/src/x11_window.c b/src/x11_window.c index 1c6229da..ea8c9fa6 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -556,6 +556,8 @@ static void _ximPreeditDoneCallback(XIC xic, XPointer clientData, XPointer callD } // IME Draw callback +// When using the dafault style: STYLE_OVERTHESPOT, this is not used since applications +// don't need to display preedit texts. // static void _ximPreeditDrawCallback(XIC xic, XPointer clientData, XIMPreeditDrawCallbackStruct *callData) { @@ -678,18 +680,30 @@ static void _ximPreeditCaretCallback(XIC xic, XPointer clientData, XPointer call { } +// IME Status Start callback +// When using the dafault style: STYLE_OVERTHESPOT, this is not used and the IME status +// can not be taken. +// static void _ximStatusStartCallback(XIC xic, XPointer clientData, XPointer callData) { _GLFWwindow* window = (_GLFWwindow*) clientData; window->x11.imeFocus = GLFW_TRUE; } +// IME Status Done callback +// When using the dafault style: STYLE_OVERTHESPOT, this is not used and the IME status +// can not be taken. +// static void _ximStatusDoneCallback(XIC xic, XPointer clientData, XPointer callData) { _GLFWwindow* window = (_GLFWwindow*) clientData; window->x11.imeFocus = GLFW_FALSE; } +// IME Status Draw callback +// When using the dafault style: STYLE_OVERTHESPOT, this is not used and the IME status +// can not be taken. +// static void _ximStatusDrawCallback(XIC xic, XPointer clientData, XIMStatusDrawCallbackStruct* callData) { _GLFWwindow* window = (_GLFWwindow*) clientData; @@ -697,6 +711,8 @@ static void _ximStatusDrawCallback(XIC xic, XPointer clientData, XIMStatusDrawCa } // Create XIM Preedit callback +// When using the dafault style: STYLE_OVERTHESPOT, this is not used since applications +// don't need to display preedit texts. // static XVaNestedList _createXIMPreeditCallbacks(_GLFWwindow* window) { @@ -721,6 +737,8 @@ static XVaNestedList _createXIMPreeditCallbacks(_GLFWwindow* window) } // Create XIM status callback +// When using the dafault style: STYLE_OVERTHESPOT, this is not used and the IME status +// can not be taken. // static XVaNestedList _createXIMStatusCallbacks(_GLFWwindow* window) { @@ -2065,6 +2083,9 @@ void _glfwCreateInputContextX11(_GLFWwindow* window) if (_glfw.x11.imStyle == STYLE_ONTHESPOT) { + // On X11, on-the-spot style is unstable. + // Status callbacks are not called and the preedit cursor position + // can not be changed. XVaNestedList preeditList = _createXIMPreeditCallbacks(window); XVaNestedList statusList = _createXIMStatusCallbacks(window); @@ -3229,6 +3250,8 @@ const char* _glfwGetClipboardStringX11(void) return getSelectionString(_glfw.x11.CLIPBOARD); } +// When using STYLE_ONTHESPOT, this doesn't work and the cursor position can't be updated +// void _glfwUpdatePreeditCursorPosX11(_GLFWwindow* window) { XVaNestedList preedit_attr;