From: Byeongsik Jeon bsjeon@hanmail.net
This patch fixes a Japanese input issue in MS Office Visual Basic and Mery text editor ime inline mode. The following was considered:
1. Japanese ime: the result string message is always placed between WM_IME_STARTCOMPOSITION and WM_IME_ENDCOMPOSITION. Currently in Wine, the result string message follows WM_IME_ENDCOMPOSITION.
dlls/imm32/tests/imm32.c::test_nihongo_no().
2. Chinese ime: same as Japanese ime.
3. Korean ime: mostly the same, but there are some cases where it is not (e.g. CPS_COMPLETE, 'r-k-RETURN'). However, I haven't found any problem even if it behave like Japanese ime message order.
3. zero-length preedit string: as in MR !3115 commit d1f9aae, the message followed by WM_IME_ENDCOMPOSITION. Currently in Wine, it is associated with WM_IME_STARTCOMPOSITION.
4. zero-length result string: ignore. --- dlls/imm32/ime.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-)
diff --git a/dlls/imm32/ime.c b/dlls/imm32/ime.c index d7ffc3de115..f71833ab02d 100644 --- a/dlls/imm32/ime.c +++ b/dlls/imm32/ime.c @@ -561,26 +561,45 @@ UINT WINAPI ImeToAsciiEx( UINT vkey, UINT vsc, BYTE *state, TRANSMSGLIST *msgs, if (status) WARN( "WINE_IME_TO_ASCII_EX returned status %#lx\n", status ); else { - TRANSMSG status_msg = {.message = ime_set_composition_status( himc, !!compstr->dwCompStrOffset )}; - if (status_msg.message) msgs->TransMsg[count++] = status_msg; + if (compstr->dwCompStrLen || compstr->dwResultStrLen) + { + TRANSMSG msg = {.message = ime_set_composition_status( himc, TRUE )}; + if (msg.message == WM_IME_STARTCOMPOSITION) msgs->TransMsg[count++] = msg; + }
- if (compstr->dwResultStrOffset) + if (compstr->dwResultStrLen) { const WCHAR *result = (WCHAR *)((BYTE *)compstr + compstr->dwResultStrOffset); TRANSMSG msg = {.message = WM_IME_COMPOSITION, .wParam = result[0], .lParam = GCS_RESULTSTR}; - if (compstr->dwResultClauseOffset) msg.lParam |= GCS_RESULTCLAUSE; + if (compstr->dwResultClauseLen) msg.lParam |= GCS_RESULTCLAUSE; msgs->TransMsg[count++] = msg; }
- if (compstr->dwCompStrOffset) + if (compstr->dwCompStrLen) { const WCHAR *comp = (WCHAR *)((BYTE *)compstr + compstr->dwCompStrOffset); TRANSMSG msg = {.message = WM_IME_COMPOSITION, .wParam = comp[0], .lParam = GCS_COMPSTR | GCS_CURSORPOS | GCS_DELTASTART}; - if (compstr->dwCompAttrOffset) msg.lParam |= GCS_COMPATTR; - if (compstr->dwCompClauseOffset) msg.lParam |= GCS_COMPCLAUSE; + if (compstr->dwCompAttrLen) msg.lParam |= GCS_COMPATTR; + if (compstr->dwCompClauseLen) msg.lParam |= GCS_COMPCLAUSE; else msg.lParam |= CS_INSERTCHAR|CS_NOMOVECARET; msgs->TransMsg[count++] = msg; } + else + { + static const TRANSMSG empty_msg = + { + .message = WM_IME_COMPOSITION, + .wParam = 0x1b, + .lParam = GCS_CURSORPOS | GCS_DELTASTART | GCS_COMPSTR | GCS_COMPATTR | GCS_COMPCLAUSE | + GCS_COMPREADSTR | GCS_COMPREADATTR | GCS_COMPREADCLAUSE + }; + TRANSMSG status_msg = {.message = ime_set_composition_status( himc, FALSE )}; + if (status_msg.message == WM_IME_ENDCOMPOSITION) + { + if (!compstr->dwResultStrLen) msgs->TransMsg[count++] = empty_msg; + msgs->TransMsg[count++] = status_msg; + } + }
if (!key_consumed) {