[Bug 60448] New: Committed Japanese text cannot be read from the message loop: IME messages are sent instead of posted, and GCS_RESULTSTR is already empty
http://bugs.winehq.org/show_bug.cgi?id=60448 Bug ID: 60448 Summary: Committed Japanese text cannot be read from the message loop: IME messages are sent instead of posted, and GCS_RESULTSTR is already empty Product: Wine Version: 11.19 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: imm32 Assignee: wine-bugs@list.winehq.org Reporter: kagetaro1986@gmail.com Target Milestone: --- Distribution: --- Created attachment 82263 --> http://bugs.winehq.org/attachment.cgi?id=82263 imetest test program, tools, comparison and logs (Windows 11, Wine unpatched/patched) with terminal output DESCRIPTION Applications that handle WM_IME_COMPOSITION in their message loop (right after PeekMessage) and read the committed text there with ImmGetCompositionString(GCS_RESULTSTR) get no Japanese input on Wine. On Windows 11 (current and previous Microsoft IME), WM_IME_STARTCOMPOSITION, WM_IME_COMPOSITION and WM_IME_ENDCOMPOSITION are posted to the thread queue, and GCS_RESULTSTR returns the committed text when the commit message is retrieved, and until the next composition starts. On Wine, with an X input method: - the messages are sent to the window procedure (ImmGenerateMessage), the message loop never sees them; - each update from the input method replaces the whole composition string; a commit arrives as several updates (result, composition cleared, end of composition), so GCS_RESULTSTR is already empty when the queue has been processed; - the commit message has lParam 0x1800; Windows reports 0x1e00 (GCS_RESULTSTR | GCS_RESULTCLAUSE | GCS_RESULTREADSTR | GCS_RESULTREADCLAUSE). A related case: typing while a conversion is shown commits the converted text and immediately starts a new composition. If the messages are posted but the updates are applied as soon as they arrive (as in a first version of the patch), the new composition replaces the composition string before the application has read the commit, and the converted text is lost. On Windows the commit is read with GCS_RESULTSTR set and the new composition with GCS_RESULTSTR empty. STEPS TO REPRODUCE 1. LC_ALL=ja_JP.UTF-8 XMODIFIERS=@im=fcitx wine imetest32.exe -a -o test.log 2. Switch the input method on, type nihon, Space (convert), Return (commit). 3. Type nihon, Space, then go while the conversion is shown, Return. Actual: every IME message is PROC/sent; the IDLE line after the commit shows an empty RESULT. Expected (Windows 11 logs attached): the IME messages are LOOP (posted); RESULT holds the committed text when the commit message is retrieved; in step 3 the converted text is committed and the new composition is read with an empty RESULT. summarize.py (attached) turns a log into a table; COMPARISON.md has the full comparison. PATCH 0002-imm32-Post-the-IME-messages-and-keep-the-result-stri.patch (attached): - post the messages to the input context window; - queue the updates from the host input method (composition strings and open status changes) and apply them one at a time, in order, once the application has retrieved the IME messages posted for the previous one (checked with PeekMessage(PM_NOREMOVE); retried with a 10 ms timer; an application that never retrieves them only delays the updates by 0.5 s); - keep the result string until a new composition starts; - report GCS_RESULTREADSTR | GCS_RESULTREADCLAUSE with the result; - return FALSE from ImeProcessKey: keys that reach it were not used by the input method (this also fixes the separate report about keys delivered twice as VK_PROCESSKEY and as the real key). With the patch the logs match Windows for all the steps above (32/64-bit, ANSI and Unicode windows). Only winex11/XIM was tested; winemac and winewayland use the same WINE_IME_POST_UPDATE path. Possibly related: bug 35929 (delayed IM input inserts wrong text), bug 55451. ENVIRONMENT - Ubuntu 24.04.5 LTS, x86_64. Interactive tests on KDE Plasma (X11); the logged runs use Xvfb + openbox. - fcitx5 5.1.7 with fcitx5-mozc 2.28.4715.102 (Japanese), XIM frontend, on-the-spot preedit (UseOnTheSpot=True), LC_ALL=ja_JP.UTF-8, XMODIFIERS=@im=fcitx. - Wine 11.19 built from the WineHQ source (configure --enable-archs=i386,x86_64, i.e. the new WoW64 mode), fresh prefix, no DLL overrides when running the test (Mono/Gecko installation skipped while the prefix was created). Same results with Wine 11.19 + Staging. The files involved (dlls/imm32, dlls/win32u/imm.c, dlls/winex11.drv/xim.c) are unchanged in master as of 2026-10-05. - Comparison: Windows 11 Pro 26H2 (build 26300), Microsoft IME (current version, and the previous version where noted), Japanese 106/109 keyboard. TEST PROGRAM imetest.c (attached, standalone, no dependencies) creates one window with default IME handling and a PeekMessage loop, and logs for every IME and keyboard message whether it was taken from the queue (LOOP) or sent to the window procedure (PROC/sent), and what ImmGetCompositionString, ImmGetOpenStatus and ImmGetConversionStatus return at that moment. IDLE lines record the state once the queue is empty. Build: i686-w64-mingw32-gcc -O1 -o imetest32.exe imetest.c -limm32 -lshell32 -mwindows (64-bit: x86_64-w64-mingw32-gcc). Options: -a ANSI window (default Unicode), -recreate, -open, -auto (types the scenario with SendInput; Windows only), -o <log>. On Wine the scenario was typed through XTEST with drive_x11.py (attached), so that the keys go through the X input method like real key presses. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=60448 --- Comment #1 from Kagetaro078 <kagetaro1986@gmail.com> --- Created attachment 82264 --> http://bugs.winehq.org/attachment.cgi?id=82264 imm32: Post the IME messages and keep the result string like Windows. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=60448 --- Comment #2 from Kagetaro078 <kagetaro1986@gmail.com> --- Still the same with Wine 11.19 and current master (dlls/imm32, dlls/win32u/imm.c and dlls/winex11.drv/xim.c are unchanged). I have since moved to Ubuntu 26.04.1 (KDE Plasma 6, Wayland session, Wine on XWayland, fcitx5 XIM frontend); the behaviour is identical there and the attached patch still applies and fixes it. The attached logs were made in Xvfb and are not affected by the desktop change. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
participants (1)
-
WineHQ Bugzilla