In x11drv_ime_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?
Kind of, composition string updates are indeed preceded by WM_IME_STARTCOMPOSITION but only if the composition status indicates that we were not composing already. I think that wasn't done before and I added it as I think WM_IME_COMPOSITION messages are only supposed to be sent between WM_IME_STARTCOMPOSITION and WM_IME_ENDCOMPOSITION.
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.
I'm not completely sure to see what is wrong here. Usually I think this should get you this kind of message sequence: WM_IME_STARTCOMPOSITION > WM_IME_COMPOSITION(GCS_COMPSTR) (* n) > WM_IME_COMPOSITION(GCS_RESULTSTR) > WM_IME_ENDCOMPOSITION, is this wrong in any way?
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()?
I think we may be missing a reliable open/composing status at this level, and we may end up sending `WM_WINE_IME_SET_COMP_TEXT` messages with a closed IME. Maybe in this case the message should be dropped.