On Wed May 10 11:00:52 2023 +0000, Byeongsik Jeon wrote:
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. When 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 we will 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 info, 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.
I think these are details to fix later, they are currently broken and this MR doesn't fix it but also doesn't make it worse. For better compatibility and to workaround the host IME quirks, I think it'd be better to simply implement all of this on the PE side.
Some IME like ibus-mozc don't let us hide their completion panel, which causes some duplicate display, but I don't think there's any better solution especially when using the limited XIM API.
Fwiw regarding host IME window positioning, it is in some cases possible to use XNSpotLocation, but it then opens another can of worms with several IME engines which don't support it in a consistent way.