Skip to content

Commit 2f3efb7

Browse files
halx99daipomshibukawaashiexfangfang
committed
Add IME support for all platforms (#3)
* Apply shibukawa's fix of GLFW for Windows This fix is based on shibukawa's fix: glfw#658 shibukawa@d36a164 Some minor coding style changes are made, but not yet follow glfw's one, and some comments doesn't follow recent changes. So further work is needed. Co-authored-by: Yoshiki Shibukawa <yoshiki@shibu.jp> Co-authored-by: Takuro Ashie <ashie@clear-code.com> * Win32: Support IME This commit re-organizes 9d9af13. * Use dynamic load for Imm32. * Generalize platform-specific features to _GLFWplatform. * Add caret-position info to preedit-callback. * Add cursorWidth to preeditCursor and related APIs. * Handle UTF16 data correctly. * Handle GCS_RESULTSTR so that committed texts are processed correctly. * Handle WM_IME_ENDCOMPOSITION to clear preedit. * Handle WM_IME_SETCONTEXT. * https://learn.microsoft.com/en-us/windows/win32/intl/wm-ime-setcontext#remarks * Refactor code shapes and variable names. Co-authored-by: Takuro Ashie <ashie@clear-code.com> * Apply shibukawa's fix of GLFW for MacOS This fix is based on shibukawa's fix: glfw#658 shibukawa@d36a164 Co-authored-by: Yoshiki Shibukawa <yoshiki@shibu.jp> Co-authored-by: Takuro Ashie <ashie@clear-code.com> * macOS: Support IME This commit re-organizes 31b12b7. * Use dynamic load for TIS functions and stop using Carbon. * Generalize platform-specific features to _GLFWplatform. * Add caret-position info to preedit-callback. * Handle UTF16 data correctly. * Implement `firstRectForCharacterRange:actualRange:` to display preedit candidate window correctly. * Suppress _glfwInputKey during preediting. * Ensure preedit cleared after committed. * Fix wrong length of markedRange. * Improve IME status APIs. * Refactor code shapes and variable names. Co-authored-by: Takuro Ashie <ashie@clear-code.com> Co-authored-by: xfangfang <2553041586@qq.com> * Apply shibukawa's fix of GLFW for X11 This fix is based on shibukawa's fix: glfw#658 The differences is the following. * Remove `X_HAVE_UTF8_STRING` branching since the current logic doesn't use it * Replace `XNDestroyCallback` for `XNPreeditAttributes` in `XCreateIC` Co-authored-by: Yoshiki Shibukawa <yoshiki@shibu.jp> Co-authored-by: Takuro Ashie <ashie@clear-code.com> * X11: Support IME This commit re-organizes 6e7f939. * Load missing XIM related function symbols. * Generalize platform-specific features to _GLFWplatform. * Change the defalut input style to over-the-spot style. * Rename `decodeUTF8()` to `_glfwDecodeUTF8()` to make it as internal API. * It will be also needed to implment input method for Wayland. * Refactor code shapes and variable names. About over-the-spot style and on-the-spot style on X11: * In over-the-spot mode, almost all APIs are disabled since applications only need to specify the preedit candidate window position by `glfwSetPreeditCursorPos()`. * We can change the style by enabling `GLFW_X11_ONTHESPOT` init hint, but it has the following problems. * Status APIs don't work because status callbacks don't work. (at least in my ibus environment). * Can't specify the candidate window position. Known problems: * Some keys (arrow, Enter, BackSpace, ...) are passed to applications during preediting. * This will be fixed in PR glfw#1972 : glfw#1972 Co-authored-by: Takuro Ashie <ashie@clear-code.com> * Wayland: Support text_input_unstable_v3 and text_input_unstable_v1 They are wayland protocols to support input methods: https://cgit.freedesktop.org/wayland/wayland-protocols/tree/unstable/text-input/text-input-unstable-v3.xml https://cgit.freedesktop.org/wayland/wayland-protocols/tree/unstable/text-input/text-input-unstable-v1.xml text_input_unstable_v3 is widely supported by major desktop environment on GNU/Linux such as GNOME or KDE. text_input_unstable_v1 isn't so popular but Weston which is the reference Wayland implementation supports only it and doesn't support text_input_unstable_v3 so that we also implement it. * tests: Add tests for IME features Co-authored-by: Takuro Ashie <ashie@clear-code.com> * Apply shibukawa's document fix This fix is from shibukawa's fix: glfw#658 shibukawa@d36a164 * Doc: Improve document about IME features * Add credit new - Daijiro Fukuda - Ryo Ichinose (from glfw#658) - Yasutaka Kumei (from glfw#658) - xfangfang already in the list - Takuro Ashie - Yoshiki Shibukawa * Add change log entries * Win32: Support preedit candidate feature You can use this feature when you need to manage the drawing of the preedit candidates on the application side. * Don't link Fontconfig Load it dynamically instead. * WIN32: Better support for IME --------- Co-authored-by: Daijiro Fukuda <fukuda@clear-code.com> Co-authored-by: Yoshiki Shibukawa <yoshiki@shibu.jp> Co-authored-by: Takuro Ashie <ashie@clear-code.com> Co-authored-by: xfangfang <2553041586@qq.com>
1 parent ddc1926 commit 2f3efb7

30 files changed

Lines changed: 4617 additions & 159 deletions

CONTRIBUTORS.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ video tutorials.
8282
- Jason Francis
8383
- Gerald Franz
8484
- Mário Freitas
85-
- Friz64
85+
- Daijiro Fukuda
8686
- GeO4d
8787
- Marcus Geelnard
8888
- Gegy
@@ -112,6 +112,7 @@ video tutorials.
112112
- Charles Huber
113113
- Brent Huisman
114114
- Florian Hülsmann
115+
- Ryo Ichinose
115116
- illustris
116117
- InKryption
117118
- IntellectualKitty
@@ -131,6 +132,7 @@ video tutorials.
131132
- knokko
132133
- Peter Knut
133134
- Christoph Kubisch
135+
- Yasutaka Kumei
134136
- Yuri Kunde Schlesner
135137
- Rokas Kupstys
136138
- Konstantin Käfer
@@ -298,6 +300,7 @@ video tutorials.
298300
- Andy Williams
299301
- Joel Winarske
300302
- Richard A. Wilkes
303+
- xfangfang
301304
- Tatsuya Yatagawa
302305
- Ryogo Yoshimura
303306
- Lukas Zanner

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,28 @@ information on what to include when reporting a bug.
169169
- [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless`
170170
- [EGL] Allowed native access on Wayland with `GLFW_CONTEXT_CREATION_API` set to
171171
`GLFW_NATIVE_CONTEXT_API` (#2518)
172+
- Added `glfwSetPreeditCallback` function and `GLFWpreeditfun` type for
173+
preedit of input method (#2130)
174+
- Added `glfwSetIMEStatusCallback` function and `GLFWimestatusfun` type for
175+
status of input method (#2130)
176+
- Added `glfwSetPreeditCursorRectangle` function to set the preedit cursor
177+
area that is used to decide the position of the candidate window of input
178+
method (#2130)
179+
- Added `glfwGetPreeditCursorRectangle` function to get the preedit cursor
180+
area (#2130)
181+
- Added `glfwResetPreeditText` function to reset preedit of input method
182+
(#2130)
183+
- Added `glfwSetPreeditCandidateCallback` function and
184+
`GLFWpreeditcandidatefun` type for preedit candidates (#2130)
185+
- Added `glfwGetPreeditCandidate` function to get a preeidt candidate text
186+
(#2130)
187+
- Added `GLFW_IME` input mode for `glfwGetInputMode` and `glfwSetInputMode`
188+
(#2130)
189+
- Added `GLFW_X11_ONTHESPOT` init hint for using on-the-spot input method
190+
style on X11 (#2130)
191+
- Added `GLFW_MANAGE_PREEDIT_CANDIDATE` init hint for displaying preedit
192+
candidates on the application side (supported only on Windows currently)
193+
(#2130)
172194

173195

174196
## Contact

0 commit comments

Comments
 (0)