Repository navigation
Windows: the Korean IME composition caret sits after the syllable (winit#4746) - #673
Merged
echelon merged 2 commits intoOct 10, 2026
Merged
Conversation
…nit#4746)
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>
This was referenced Oct 10, 2026
# Conflicts: # vendor/README.md
Member
|
Merged, thank you! Reading If you haven't already, come join us on Discord: https://discord.gg/artcraft |
This was referenced Oct 10, 2026
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 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.
Summary
With the Microsoft Korean IME on Windows, winit reports the composition's cursor at the start of the syllable (
Ime::Preedit("한", Some((0, 0)))). egui 0.36.2 recognises that exact report on Windows and drops the range (a workaround inegui-winit), so PdfCraft shows no caret at all while Korean is being composed. With this change winit reports the cursor at the end (Some((3, 3))), and egui draws the caret after the syllable.Port of rust-windowing/winit#4746 (reviewed head
3787f3d644) to the vendored winit 0.30.13. It is the same change.PdfCraft impact
Korean composition in every egui text field on Windows: Search, form fields, the JavaScript console, comments.
Root cause
vendor/winit/src/platform_impl/windows/ime.rs,get_composing_text_and_cursor: when a composition has no target clause, winit callsImmGetCompositionStringW(GCS_CURSORPOS)without checking that theWM_IME_COMPOSITIONlParamhasGCS_CURSORPOSset. The Microsoft Korean IME never sets it (lParamis0x6018:GCS_COMPSTR | GCS_COMPATTR | CS_INSERTCHAR | CS_NOMOVECARET), so the read gives 0.Change
WM_IME_COMPOSITIONpasses itslParamon. When there is no target clause, the cursor comes fromGCS_CURSORPOSonly if that flag is set; otherwise it goes at the end of the composition. Firefox reads the cursor the same way, and SDL fixed the same bug by putting it at the end.IMEs that report a target clause or a cursor position (Japanese, Chinese) take the same path as before, and commits are unchanged.
Not included
Nothing else from winit master.
Verification
한now givesPreedit("한", Some((3, 3))),안녕is the same per syllable, the Hanja candidate window opens at the caret, and commits are unchanged.apps/pdfcraft/tests/winit_windows_ime_cursor.rsfails if a re-vendored winit readsGCS_CURSORPOSwithout the flag again.Automated checks
aarch64-apple-darwin,x86_64-pc-windows-msvcandx86_64-unknown-linux-musl(cargo clippy --lib, lints capped to warnings): the warnings are the same as onmainfor all three (the one existingclippy::iter_kv_mapinlinux/x11/event_processor.rs).cargo check --locked -p winitinside the PdfCraft workspace, with PdfCraft's ownCargo.lock, on macOS and on the tree with all nine fixes merged: clean.main(fails);rustfmt --checkandclippy -D warningson it are clean.cargo test --workspaceand workspace clippy (the machine is short of disk space for a full build). CI runs them on Linux and Windows.Risk
The change only affects compositions with no target clause whose IME doesn't set
GCS_CURSORPOS: before, the cursor read as 0 (or as whateverImmGetCompositionStringWreturned); now it is at the end of the text. egui's workaround (egui-winitlib.rs, "Workaround for a bug on Windows wherewinitincorrectly reports the cursor position at the start of the preedit text") still applies to any IME that genuinely reports a cursor at 0; it no longer fires for the Microsoft Korean IME.Revert and removal
This change is independent of the other winit PRs and can be reverted on its own. Drop it, together with the test and README item (3), once PdfCraft uses a winit release that includes rust-windowing/winit#4746 or an equivalent fix.
Merging alongside the other winit PRs
This is one of nine fixes to
vendor/winitsent together: #672 (Wayland IME after a capability change), #673 (Windows Korean IME caret), #674 (Windows maximized start-up), #675 (X11 input context focus), #676 (macOS IME commit state), #677 (macOS stale composition), and, building on #676, #678 (macOS emoji picker), #679 (macOS Korean double space), #680 (macOS first Korean key). Each adds one numbered item to the single winit row invendor/README.md, so they conflict with each other on that one line, and nowhere else (each test is in its own file). The item numbers (2)–(10) are fixed in advance: to resolve, keep every item in numeric order. All nine were merged locally in one tree (only that line conflicted); the combined vendored winit builds for macOS, Windows and Linux with the same clippy output asmain, and all nine tests pass on it.🤖 Generated with Claude Code