Byeongsik Jeon (@bsjeon) commented about dlls/imm32/ime.c:
+ TRACE( "old_status %u, himc %p, result %u, str %s\n", old_status, himc, result, debugstr_wn(str, len) ); + + if (!(ctx = ImmLockIMC( himc ))) return FALSE; + if ((priv = ImmLockIMCC( ctx->hPrivate ))) + { + old_status = priv->bInComposition; + ImmUnlockIMCC( ctx->hPrivate ); + } + flags = input_context_set_comp_str( ctx, result, str, len ); + ImmUnlockIMC( himc ); + + if (!old_status) ImmSetOpenStatus( himc, TRUE ); + if (!result || !old_status) ime_set_composition_status( himc, hwnd, TRUE ); + ime_send_message( himc, WM_IME_COMPOSITION, len ? str[0] : 0, flags ); + if (result || !old_status) ime_set_composition_status( himc, hwnd, FALSE ); + if (!old_status) ImmSetOpenStatus( himc, FALSE ); In x11drv_time_set_result() and in this code, WM_IME_COMPOSITION(GCS_RESULTSTR) is always followed by WM_IME_ENDCOMPOSITION. And, in this code, WM_IME_COMPOSITION(GCS_COMPSTR) is always preceded by WM_IME_STARTCOMPOSITION.
Is this intended? Overall, the IME message sequences are too dirty. In particular, for Korean input, preedit_string and result_string need to co-operate organically, which leads to a bad situation. Of course, this is an inherited problem from the old code. In my opinion, it makes sense that the x11drv_ime_set_result() code is for case where the input_style is not XIMPreditcallbacks. How about moving some code to xim_set_result_string()? For example, ``` +++ b/dlls/winex11.drv/xim.c @@ -126,7 +126,20 @@ void xim_set_result_string( HWND hwnd, const char *str, UINT count ) len = ntdll_umbstowcs( str, count, output, count ); output[len] = 0; - send_ime_ui_message( hwnd, WM_WINE_IME_SET_COMP_TEXT, FALSE, (LPARAM)output ); + if (input_style & XIMPreeditCallbacks) + { + send_ime_ui_message( hwnd, WM_WINE_IME_SET_COMP_TEXT, FALSE, (LPARAM)output ); + } + else + { + send_ime_ui_message( hwnd, WM_WINE_IME_SET_OPEN_STATUS, TRUE, 0 ); + send_ime_ui_message( hwnd, WM_WINE_IME_SET_COMP_STATUS, TRUE, 0 ); + + send_ime_ui_message( hwnd, WM_WINE_IME_SET_COMP_TEXT, FALSE, (LPARAM)output ); + + send_ime_ui_message( hwnd, WM_WINE_IME_SET_COMP_STATUS, FALSE, 0 ); + send_ime_ui_message( hwnd, WM_WINE_IME_SET_OPEN_STATUS, FALSE, 0 ); + } ``` -- https://gitlab.winehq.org/wine/wine/-/merge_requests/2637#note_30020