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