Signed-off-by: Byeongsik Jeon bsjeon@hanmail.net --- v2: rework. minimize change from e4d94e48138f v3: no changes v4: no changes
preedit start:: preedit draw:: caret 1 chg_first 0 chg_length 0 string 'ㄱ' preedit draw:: caret 1 chg_first 0 chg_length 1 string '가' preedit draw:: caret 1 chg_first 0 chg_length 1 string '간' preedit draw:: caret 0 chg_first 0 chg_length 1 NULL <== HERE preedit done:: lookup chars:: keycode 0 string 3 '가' <== IME_SetResultString preedit start:: preedit draw:: caret 1 chg_first 0 chg_length 0 string '나'
Some xim server generate the "events" that erase the "preedit draw" string before "lookup chars". These translates to WM_IME_ messages. In this case, the corresponding action of IME_SetResultString() is not required. I tried to reduce the side effects because I can't test the issue of e4d94e48138f .
dlls/winex11.drv/ime.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/dlls/winex11.drv/ime.c b/dlls/winex11.drv/ime.c index c1584930861..1e50d187f19 100644 --- a/dlls/winex11.drv/ime.c +++ b/dlls/winex11.drv/ime.c @@ -1022,15 +1022,21 @@ void IME_SetResultString(LPWSTR lpResult, DWORD dwResultLen) HIMCC newCompStr; LPIMEPRIVATE myPrivate; BOOL inComp; + LPBYTE compdata; + DWORD compstr_len;
imc = RealIMC(FROM_X11); lpIMC = ImmLockIMC(imc); if (lpIMC == NULL) return;
- newCompStr = updateCompStr(lpIMC->hCompStr, NULL, 0); - ImmDestroyIMCC(lpIMC->hCompStr); - lpIMC->hCompStr = newCompStr; + if (lpIMC->hCompStr && (compdata = ImmLockIMCC( lpIMC->hCompStr )) && + (compstr_len = ((LPCOMPOSITIONSTRING)compdata)->dwCompStrLen)) + { + newCompStr = updateCompStr( lpIMC->hCompStr, NULL, 0 ); + ImmDestroyIMCC( lpIMC->hCompStr ); + lpIMC->hCompStr = newCompStr; + }
newCompStr = updateResultStr(lpIMC->hCompStr, lpResult, dwResultLen); ImmDestroyIMCC(lpIMC->hCompStr); @@ -1040,7 +1046,7 @@ void IME_SetResultString(LPWSTR lpResult, DWORD dwResultLen) inComp = myPrivate->bInComposition; ImmUnlockIMCC(lpIMC->hPrivate);
- if (!inComp) + if (!inComp && compstr_len) { ImmSetOpenStatus(imc, TRUE); GenerateIMEMessage(imc, WM_IME_STARTCOMPOSITION, 0, 0); @@ -1050,7 +1056,7 @@ void IME_SetResultString(LPWSTR lpResult, DWORD dwResultLen) GenerateIMEMessage(imc, WM_IME_COMPOSITION, lpResult[0], GCS_RESULTSTR|GCS_RESULTCLAUSE); GenerateIMEMessage(imc, WM_IME_ENDCOMPOSITION, 0, 0);
- if (!inComp) + if (!inComp && compstr_len) ImmSetOpenStatus(imc, FALSE);
ImmUnlockIMC(imc);