Is there a problem with implementing this using WM_IME_INTERNAL?
We need to copy the string allocated from winex11 to some memory that is accessible to the win32 side. EM_REPLACESEL does that already and using WM_IME_INTERNAL we would have to add more code to do the same thing.
There may be some other ways such as notifying the IME then calling back into winex11 to get the string but I think it's more convoluted.
Another topic,
code works, but the hwnd used by the xic callback function is not valid, so it would be nice if it could be cleaned up. Is this because you don't like to use get_focus()?
I'm not sure to understand what you mean by invalid? get_focus could return a different window than the one which received the input event and I think we should follow X11 target window. Especially as I think that ultimately input events should be listened to in a separate thread.