I looked inside the OnMainThread, and perhaps there might be an error in my reply. I'll describe the problematic situation:
Should be fixed with the latest version. It is indeed as you already found an issue with the order of operations with the `IM_SET_TEXT` call. I added `macdrv_ProcessEvents(QS_POSTMESSAGE | QS_SENDMESSAGE)`, which makes this MR equivalent to the previous version, but still feels noticeably better.
Regarding Japanese IME, there are many issues with it currently unfortunately, but these are probably best tackled in different MRs...
In addition to this MR, I tested whether it's possible to drop the IM_SET_TEXT code. It's a proof-of-concept patch and needs cleanup. It seems to work well, including the issue posted above.
Thanks for this, I don't think changing the signature of `ImeProcessKey()` is something we can do, but getting rid of some of these events if possible would be nicer indeed (or just making macdrv event handling much faster in general).