On Wed May 10 10:26:35 2023 +0000, Rémi Bernon wrote:
Fwiw on winex11 XmbResetIC is usually broken and doesn't do the right thing, and XNPreeditState also doesn't have any effect with many XIM backends. We also pass the focused HWND to them, which ends up with X11DRV_get_ic failing most of the time as it's not the top-level window. I kept the calls, but I don't think they are very useful. This could be changed later, either by dropping them entirely, or maybe by sending an artificial Escape key press to XIM through a XFilterEvent call. As far as I can see this is the only way to force some IME, like IBus, to close their composition window without generating a result.
In ibus-hangul, the ESC key works as 'reset ic' and 'conversion mode change(hangul to english)'.
I report the results of my further investigation.
UIM:
It works exactly as per the Xlib specification. XmbResetIC returns a string, no additional xic callbacks.
fcitx5, ibus-anthy: ``` preedit_draw with empty_string preedit_done ``` Raises a callback to clear the client-side preedit buffer.
ibus-hangul, ibus-mozc: ``` preedit_draw with empty_string predit_done result_string ``` Treats the return of a string as an XIC callback.
After researching the developer's webpage, it seems that this is more intentional than just a bug - the story is too complicated to tell here.
I've written a workaround patch that takes these patterns into account. However, I am investigating if there is a better solution. As I've been looking at the ibus API, I expect to see this issue in the Wine ibus ime driver in the future. In any case, I think I'll need some workaround code.
Strictly speaking:
CPS_COMPLETE, CPS_CANCEL should be actions that use or discard the XmbResetIC() return string. For example, if we type 'N-I-H-O-N-G-O', and 'reset ic' is called after the 'N', we might think it should return an empty string because the 'N' is meaningless at this point. This should be decided on the IME side, so we shouldn't use a preedit_string that has already arrived.
This is why both CPS_COMPLETE and CPS_CANCEL exist. However, due to the current XmbResetIC behavior, we are not able to proceed with this discussion.
ImmSetCandidateWindow or IMC_SETCANDIDATEPOS :
The Xlib API does not provide functions for candidate strings, the candidate window is drawn by the xim server. Therefore, it is recommended to modify the value of xic XNPreeditAttributes::XNSpotLocation.
In this case, we need X11DRV_get_ic to work well.