Repository navigation
Windows: place IME cursor at the end when GCS_CURSORPOS is not reported - #4746
Open
seunghan91 wants to merge 1 commit into
Open
seunghan91 wants to merge 1 commit into
seunghan91 wants to merge 1 commit into
Conversation
1 task done
echelon
added a commit
to storytold/pdfcraft
that referenced
this pull request
Oct 10, 2026
…nit#4746) (#673) When a composition has no target clause, winit 0.30.13 reads the cursor with ImmGetCompositionStringW(GCS_CURSORPOS) without checking that the WM_IME_COMPOSITION lParam has GCS_CURSORPOS set. The Microsoft Korean IME never sets it (lParam 0x6018), so the read gives 0 and winit reports Ime::Preedit("한", Some((0, 0))). egui 0.36.2 recognises that exact report on Windows and drops the range, so PdfCraft draws no caret while Korean is being composed. vendor/winit now reads GCS_CURSORPOS only when the flag says the IME set it and otherwise puts the cursor at the end of the composition, as rust-windowing/winit#4746 does on winit master (Firefox and SDL do the same). IMEs that report a cursor or a target clause (Japanese, Chinese) are unchanged. A test fails if a re-vendored winit loses the patch. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Brandon Thomas <echelon@gmail.com>
krichelj
pushed a commit
to krichelj/pdfcraft
that referenced
this pull request
Oct 11, 2026
…nit#4746) (storytold#673) When a composition has no target clause, winit 0.30.13 reads the cursor with ImmGetCompositionStringW(GCS_CURSORPOS) without checking that the WM_IME_COMPOSITION lParam has GCS_CURSORPOS set. The Microsoft Korean IME never sets it (lParam 0x6018), so the read gives 0 and winit reports Ime::Preedit("한", Some((0, 0))). egui 0.36.2 recognises that exact report on Windows and drops the range, so PdfCraft draws no caret while Korean is being composed. vendor/winit now reads GCS_CURSORPOS only when the flag says the IME set it and otherwise puts the cursor at the end of the composition, as rust-windowing/winit#4746 does on winit master (Firefox and SDL do the same). IMEs that report a cursor or a target clause (Japanese, Chinese) are unchanged. A test fails if a re-vendored winit loses the patch. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Brandon Thomas <echelon@gmail.com>
This was referenced Oct 12, 2026
seunghan91
force-pushed
the
fix/win32-ime-cursor-without-cursorpos
branch
from
October 21, 2026 09:14
3787f3d to
63f7546
Compare
Author
richerfu
pushed a commit
to richerfu/winit
that referenced
this pull request
Nov 2, 2026
Port of rust-windowing#4746. Originally "M15.1: fix Windows Korean IME caret" in storytold/wordcraft#787 (same change as storytold/pdfcraft vendor/winit).
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With the Microsoft Korean IME,
Ime::Preeditalways has the cursor atSome((0, 0)), so applications draw the caret before the syllable being composed (e.g.|한instead of한|). It also moves the IME candidate window to the start of the composition when the app positions it at the caret.The IME never sets
GCS_CURSORPOSin theWM_IME_COMPOSITIONlParam: during composition it is always0x6018(GCS_COMPSTR | GCS_COMPATTR | CS_INSERTCHAR | CS_NOMOVECARET). It doesn't mark a target clause either. winit then falls back toImmGetCompositionStringW(GCS_CURSORPOS)without checking the flag, gets 0, and reports the start of the composition.This passes the lParam to
get_composing_text_and_cursor. When there is no target clause, it readsGCS_CURSORPOSonly if the flag is set; otherwise it puts the cursor at the end of the composition. IMEs that report a cursor position or a target clause are unaffected. Firefox also reads the cursor only whenGCS_CURSORPOSis set. SDL fixed the same issue by placing the cursor at the end (8e6fed2, b608108).Imeevents, 2 runs per case. Composing한now givesPreedit("한", Some((3, 3)))instead ofSome((0, 0)), and the caret is drawn after the syllable.안녕behaves the same per syllable. The Hanja candidate window now opens at the caret. Commits are unchanged.cargo check/clippy -p winit-win32 --target x86_64-pc-windows-msvconmaster.changelogmodule if knowledge of this change could be valuable to users