Skip to content

Better IME support - #658

Open
shibukawa wants to merge 1 commit into
glfw:masterfrom
shibukawa:feature/add-ime-support
Open

shibukawa wants to merge 1 commit into
glfw:masterfrom
shibukawa:feature/add-ime-support

Conversation

@shibukawa

Copy link
Copy Markdown

Add better IME support (#41) to implement on-the-spot IME conversion. My code is based on #643.

I added the following functions:

  • glfwSetPreeditCallback() : callback function to notify preedit text
  • glfwSetPreeditCursorPos() : teach text cursor position for IME windows
  • glfwGetPreeditCursorPos() : get text cursor position for IME windows

They are not big changes. It keeps backward compatibility about API level.
To use IME feature, UI programmers should implement visualization code for preedit texts.

I implemented platform specific code for Windows/X11/Mac OS X (not Wayland and Mir).

@elmindreda elmindreda self-assigned this Dec 12, 2015
@elmindreda elmindreda added enhancement Feature suggestions and PRs macOS Windows Win32 specific (not Cygwin or WSL) X11 labels Dec 12, 2015
@shibukawa

Copy link
Copy Markdown
Author

I start implementing my text box, I think some features are needed in addition to the above functions:

  • Set/Get current IME status (integer only text box and so on)
  • IME status change callback (commit text when turn off IME)
  • Reset preedit text (reset text when widget focus would changed)

I will add these functions to my branch.

@elmindreda elmindreda changed the title Better IME support for Windows/X11/Mac OS X Better IME support Dec 13, 2015
@elmindreda

Copy link
Copy Markdown
Member

My initial impression is that this looks great! I will review it more closely once it's time for the IME part of 3.2, which should hopefully give you time to land the additional features you mention.

@shibukawa
shibukawa force-pushed the feature/add-ime-support branch 2 times, most recently from 2c847f3 to 41cd4f7 Compare December 16, 2015 15:21
@shibukawa

Copy link
Copy Markdown
Author

I implemented all method I mentioned and I added one test application (ime.c, almost as same as event.c, but IME functions are assigned to mouse buttons).

Current status is:

glfw-screenshot

- Windows works almost perfectly except Google Japanese Input doesn't follow cursor position (MS IME works). - Mac OS X's NSTextInputContext doesn't work on my computer (10.9). So resetting preedit text feature doesn't work. - I tested on Ubuntu 15.10, but XIM (X Input Method) implementation is buggy. Test application can receive preedit text and commited text, but my real application can't. I am still debugging.

XIM is very old standard. I think adding Fcitx option (more modern protocol and most popular one now) is better solution (use Fcitx if it is installed, otherwise use XIM). And Fcitx supports Wayland too (I couldn't find Mir information). How about it?

@elmindreda elmindreda modified the milestone: 3.3 Mar 11, 2016
@elmindreda

Copy link
Copy Markdown
Member

There is quite a range of programming styles in this patch. Did you write this yourself or are parts of it copied from other sources? If so I need to know what licenses they come under.

@elmindreda

Copy link
Copy Markdown
Member

The glfwGetIMEStatus and glfwSetIMEStatus functions should be folded into glfwGetInputMode and glfwSetInputMode.

@elmindreda

Copy link
Copy Markdown
Member

The imm32 library should be dynamically loaded the same way as other non-default libraries.

@shibukawa

Copy link
Copy Markdown
Author

Maybe 50% is my code and 50% is other's. I referred the following Japanese web sites:

Windows: http://www.kumei.ne.jp/c_lang/sdk3/sdk_278.htm
X11: http://homepage3.nifty.com/rio_i/lab/xlib/012xim.htm

I will ask them about sample code's license.

I couldn't find memo about Mac. Of course, I checked MSDN, Apple's document, X11R6 references.

@shibukawa

Copy link
Copy Markdown
Author

I will merge glfw(Get|Set)IMEStatus into glfw(Get|Set)InputMode.

imm32 is provided as static library by Microsoft and it should be bundled with Windows like gdi32.dll. I thinks if(WIN32) is enough to detect imm32.

@shibukawa
shibukawa force-pushed the feature/add-ime-support branch 2 times, most recently from 8d2378f to 66bc5f7 Compare April 6, 2016 15:54
@shibukawa

Copy link
Copy Markdown
Author
  1. I rebased to fix conflict between current master.
  2. I removed glfw(Get|Set)IMEStatus and added new options to glfw(Get|Set)InputMode
  3. Ryo Ichinose (X11 guy) agreed using XIM related code as libpng/zlib license.

Now I am waiting reply from Yasutaka Kumei.

@shibukawa

Copy link
Copy Markdown
Author

Yasutaka Kumei agreed using his code with glfw.

@elmindreda

Copy link
Copy Markdown
Member

Awesome! Thank you!

@elmindreda

Copy link
Copy Markdown
Member

About the imm32 thing, it's not for compatibility with older systems. As you rightly point out, the import library is available everywhere. Rather it's as a convenience for users, just like the current dynamic loading of winmm.

elmindreda pushed a commit that referenced this pull request Dec 5, 2016
@hesiod

hesiod commented Feb 11, 2017

Copy link
Copy Markdown

@elmindreda It appears that you wanted to close this PR with 779b562, but Github failed to realize that, so you probably have to close this PR manually

@dmitshur

dmitshur commented Feb 12, 2017 •

Copy link
Copy Markdown
Collaborator

It appears that you wanted to close this PR with 779b562, but Github failed to realize that, so you probably have to close this PR manually

@hesiod That commit is not yet merged into master branch. When it is, due to its commit message, this PR will be closed.

@elmindreda

Copy link
Copy Markdown
Member

What @shurcooL said. Expect several more revisions to pop up here before it's ready to merge, as it's a big and multi-platform addition.

daipom added a commit to clear-code/glfw that referenced this pull request May 24, 2022
There was a oversight in transplanting shibukawa's fix:
* glfw#658
* shibukawa@d36a164

This made preedit callbacks not being called.
daipom pushed a commit to clear-code/glfw that referenced this pull request May 24, 2022
daipom added a commit to clear-code/glfw that referenced this pull request May 24, 2022
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.
daipom added a commit to clear-code/glfw that referenced this pull request May 24, 2022
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`
daipom added a commit to clear-code/glfw that referenced this pull request May 24, 2022
daipom added a commit to clear-code/glfw that referenced this pull request May 24, 2022
This fix is based on shibukawa's fix:
  glfw#658
  shibukawa@d36a164

This code doesn't work because `get_character_string` is undefined.
We need further work.
daipom added a commit to clear-code/glfw that referenced this pull request May 24, 2022
This fix is based on `tests/ime.c` of shibukawa's fix:
  glfw#658
  shibukawa@d36a164

I simplified and restructured it entirely.
daipom added a commit to clear-code/glfw that referenced this pull request May 24, 2022
There was a oversight in transplanting shibukawa's fix:
* glfw#658
* shibukawa@d36a164

This made preedit callbacks not being called.
daipom pushed a commit to clear-code/glfw that referenced this pull request May 24, 2022
@daipom

daipom commented May 24, 2022

Copy link
Copy Markdown

I would like to continue this fix with #2117.
I have already contacted Mr. @shibukawa .

daipom added a commit to clear-code/glfw that referenced this pull request Jun 13, 2022
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.
daipom added a commit to clear-code/glfw that referenced this pull request Jun 13, 2022
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`
daipom added a commit to clear-code/glfw that referenced this pull request Jun 13, 2022
daipom added a commit to clear-code/glfw that referenced this pull request Jun 13, 2022
This fix is based on shibukawa's fix:
  glfw#658
  shibukawa@d36a164

This code doesn't work because `get_character_string` is undefined.
We need further work.
daipom added a commit to clear-code/glfw that referenced this pull request Jun 13, 2022
This fix is based on `tests/ime.c` of shibukawa's fix:
  glfw#658
  shibukawa@d36a164

I simplified and restructured it entirely.
daipom added a commit to clear-code/glfw that referenced this pull request Jun 13, 2022
There was a oversight in transplanting shibukawa's fix:
* glfw#658
* shibukawa@d36a164

This made preedit callbacks not being called.
daipom pushed a commit to clear-code/glfw that referenced this pull request Jun 13, 2022
daipom added a commit to clear-code/glfw that referenced this pull request Aug 9, 2022
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.
daipom added a commit to clear-code/glfw that referenced this pull request Aug 9, 2022
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`
daipom added a commit to clear-code/glfw that referenced this pull request Aug 9, 2022
daipom added a commit to clear-code/glfw that referenced this pull request Aug 9, 2022
This fix is based on shibukawa's fix:
  glfw#658
  shibukawa@d36a164

This code doesn't work because `get_character_string` is undefined.
We need further work.
daipom added a commit to clear-code/glfw that referenced this pull request Aug 9, 2022
This fix is based on `tests/ime.c` of shibukawa's fix:
  glfw#658
  shibukawa@d36a164

I simplified and restructured it entirely.
daipom added a commit to clear-code/glfw that referenced this pull request Aug 9, 2022
There was a oversight in transplanting shibukawa's fix:
* glfw#658
* shibukawa@d36a164

This made preedit callbacks not being called.
@ashie

ashie commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

It appears that #2130 now fully incorporates the work from this PR, including attribution to the original contributors.

As far as I can tell, there is no remaining work in this PR that is not already represented in #2130. In that sense, #2130 seems to have effectively superseded this PR.

It may therefore make sense to close this PR and continue any future discussion and review efforts on #2130 instead.

Thank you for the original contribution. The work done here laid the foundation for the current effort, and it is good to see it being carried forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Feature suggestions and PRs macOS Windows Win32 specific (not Cygwin or WSL) X11

Projects

None yet

Development

Successfully merging this pull request may close these issues.