https://bugs.winehq.org/show_bug.cgi?id=55027
Bug ID: 55027 Summary: Microsoft Office: IME result string may get doubled when edit is done Product: Wine Version: 8.9 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: winex11.drv Assignee: wine-bugs@winehq.org Reporter: firelzrd@gmail.com Distribution: ---
Created attachment 74582 --> https://bugs.winehq.org/attachment.cgi?id=74582 Bad and Good cases in Excel 2003
The recent (v8.x) IMM32 progress is so remarkable that CJK users may finally think of replacing Windows for using Microsoft Office.
However, in Microsoft Office apps (confirmed in 2003) having done editing IME preedit text by hitting Enter key may actually put the result text doubled (see in the attached video).
My analysis showed that when:
WM_IME_COMPOSITION which has GCS_RESULTREADSTR & GCS_RESULTSTR flags on is sent to complete the edit, and result text is sent, Only in case the problem occurs, right after that:
WM_IME_COMPOSITION which has GCS_COMPSTR & GCS_COMPATTR & GCS_RESULTSTR flags on is sent.
This behavior indicates that xic_preedit_done() and xim_set_result_string() which I found in xim.c are called sometimes in a wrong order.
A: XICCallback preedit_done is called xic_preedit_done is called
B: keyboard.c:X11DRV_KeyEvent xim_set_result_string is called
A is supposed to be called first, and then B should follow. in the good case A happens, then B happens. in the bad case B happens, then A happens.
So I think this problem occurs because XIC callback and X11DRV_KeyEvent are called asynchronously.
I think the solution may be: * In xim_set_result_string(), check if XIC preedit context exists, and if so, ppostpone the sending of WM_IME_COMPOSITION until next xic_preedit_done() is called or * Ignore xic_preedit_done() if xim_set_result_string() was called very recently
Let me hear what you guys think.
Thank you
https://bugs.winehq.org/show_bug.cgi?id=55027
Rémi Bernon rbernon@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |rbernon@codeweavers.com
--- Comment #1 from Rémi Bernon rbernon@codeweavers.com ---
The recent (v8.x) IMM32 progress is so remarkable that CJK users may finally think of replacing Windows for using Microsoft Office.
Thanks, always nice to hear :)
So I think this problem occurs because XIC callback and X11DRV_KeyEvent are called asynchronously.
I think that could be a case where the X11 event merging logic breaks the XIC sequence.
Byeong-Sik Jeon reported the issue before, and I opened https://gitlab.winehq.org/wine/wine/-/merge_requests/2698 but it wasn't merged for some reason.
Could you try the patches there, see if it fixes the issue? If that's the case I'll work on having it merged.
https://bugs.winehq.org/show_bug.cgi?id=55027
--- Comment #2 from Masahito S. firelzrd@gmail.com ---
Could you try the patches there, see if it fixes the issue? If that's the case I'll work on having it merged.
Thanks for the fast reply. Although I crave to test your patch, being a total freshman in WINE development, unfortunately I'm having a hard time building 32-bit WINE on my amd64 Ubuntu installation.
It'd be nice if anyone more skilled can show me how-to ( https://wiki.winehq.org/Building_Biarch_Wine_On_Ubuntu seems out-dated, and it didn't work for me), or test it instead of me.
With great appreciation
https://bugs.winehq.org/show_bug.cgi?id=55027
--- Comment #3 from Masahito S. firelzrd@gmail.com --- A pre-built binary archive was found downloadable from: https://gitlab.winehq.org/rbernon/wine/-/jobs/16789
But unfortunately it was based on WINE 8.6. Since in any versions before 8.9, on-the-spot preedit text didn't work in MSOffice, I suppose that testers will need a binary with Rémi's patch but rebased on top of 8.9+.
https://bugs.winehq.org/show_bug.cgi?id=55027
--- Comment #4 from Masahito S. firelzrd@gmail.com --- I successfully built a patched version on top of 8.10, and ran the same test on it. As much as I tried, now the bad case seems to happen at 100% chance. Certainly the order of the window messages being sent must be this time always opposite. That is a good sign, and we're one more step away from addressing it, aren't we?
https://bugs.winehq.org/show_bug.cgi?id=55027
--- Comment #5 from Masahito S. firelzrd@gmail.com --- Created attachment 74595 --> https://bugs.winehq.org/attachment.cgi?id=74595 Excel 2003 on a patched build #1: Always bad
https://bugs.winehq.org/show_bug.cgi?id=55027
--- Comment #6 from Rémi Bernon rbernon@codeweavers.com --- Eh, yeah that's definitely progress :)
It looks like it's an issue with riched20, I can reproduce the problem with Wine wordpad (but not in notepad). I will investigate.
https://bugs.winehq.org/show_bug.cgi?id=55027
--- Comment #7 from Rémi Bernon rbernon@codeweavers.com --- Created attachment 74598 --> https://bugs.winehq.org/attachment.cgi?id=74598 Possible fix
Actually I think this might be a problem with imm32 and this might fix it?
https://bugs.winehq.org/show_bug.cgi?id=55027
--- Comment #8 from Masahito S. firelzrd@gmail.com --- Created attachment 74600 --> https://bugs.winehq.org/attachment.cgi?id=74600 patches applied in a zip archive
Thank you for your attention. So far no luck. With the attached patch set, it happens 100%. The below is a window message log, and it indicates the window messages are still ordered opposite.
$ WINEDEBUG=+timestamp,message wine ./EXCEL.EXE |& grep WM_IME 4122.265:0150:trace:message:spy_enter_message (0x3009c) L"Microsoft Excel" [0282] WM_IME_NOTIFY dispatched wp=00000010 lp=00000002 4122.265:0150:trace:message:spy_enter_message (0x3009c) DefWindowProc:[0282] WM_IME_NOTIFY wp=00000010 lp=00000002 4122.265:0150:trace:message:spy_enter_message (0xa0072) L"Default IME" [0282] WM_IME_NOTIFY sent from self wp=00000010 lp=00000002 4122.265:0150:trace:message:spy_enter_message (0x40062) L"{Wine IME}" [0282] WM_IME_NOTIFY sent from self wp=00000010 lp=00000002 4122.265:0150:trace:message:spy_enter_message (0x20054) L"{EXCEL6}" [010f] WM_IME_COMPOSITION sent from self wp=00003042 lp=00001800 4122.270:0150:trace:message:spy_exit_message (0x20054) L"{EXCEL6}" [010f] WM_IME_COMPOSITION returned 00000000 4122.270:0150:trace:message:spy_enter_message (0x20054) L"{EXCEL6}" [010f] WM_IME_COMPOSITION sent from self wp=00003042 lp=000001b8 4122.274:0150:trace:message:spy_exit_message (0x20054) L"{EXCEL6}" [010f] WM_IME_COMPOSITION returned 00000000 4122.274:0150:trace:message:spy_exit_message (0x40062) L"{Wine IME}" [0282] WM_IME_NOTIFY returned 00000002 4122.274:0150:trace:message:spy_exit_message (0xa0072) L"Default IME" [0282] WM_IME_NOTIFY returned 00000002 4122.274:0150:trace:message:spy_exit_message (0x3009c) DefWindowProc: [0282] WM_IME_NOTIFY returned 00000002 4122.274:0150:trace:message:spy_exit_message (0x3009c) L"Microsoft Excel" [0282] WM_IME_NOTIFY returned 00000002
https://bugs.winehq.org/show_bug.cgi?id=55027
--- Comment #9 from Rémi Bernon rbernon@codeweavers.com --- You only need to apply the imm32 patch, from Comment 7, not the other ones. At least for me it fixed the issue in wordpad.exe.
https://bugs.winehq.org/show_bug.cgi?id=55027
--- Comment #10 from Masahito S. firelzrd@gmail.com --- (In reply to Rémi Bernon from comment #9)
Thank you! I applied only the imm32 patch from Comment 7. At my side, Wordpad and Excel both behave the same as the untouched 8.10 (in the first video). There might be a slight difference in the probability of problem occurrence, but with not enough samples, I'm not sure. One thing I'm sure is that it's still occurring.
https://bugs.winehq.org/show_bug.cgi?id=55027
Masahito S. firelzrd@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Version|8.9 |8.10 Hardware|x86-64 |x86 Component|winex11.drv |imm32
https://bugs.winehq.org/show_bug.cgi?id=55027
--- Comment #11 from Masahito S. firelzrd@gmail.com --- Created attachment 74603 --> https://bugs.winehq.org/attachment.cgi?id=74603 imm32: When IME composition is done, send WM_IME_COMPOSITION for the composition text before sending it for the result text
Could you please try this one? This fix worked for me, so far this issue happens at 0% chance. It applies on fresh 8.10.
https://bugs.winehq.org/show_bug.cgi?id=55027
Masahito Suzuki firelzrd@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |FIXED
--- Comment #12 from Masahito Suzuki firelzrd@gmail.com --- Now that both in Richedit and Office apps the problem never happens, I consider it to be resolved.
Merge request created. https://gitlab.winehq.org/wine/wine/-/merge_requests/3051
Thank you very much for your kind support, Rémi Bernon, and I sincerely look forward to your continued success in the future.
https://bugs.winehq.org/show_bug.cgi?id=55027
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #13 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 8.11.