Have the IBUS popup display at the cursor position

This commit is contained in:
Kovid Goyal 2018-07-11 16:47:59 +05:30
parent c6c6a18375
commit 21f1fd55f8
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -113,6 +113,16 @@ check_if_special(int key, int mods, int scancode) {
return special;
}
static inline void
update_ime_position(OSWindow *os_window, Window* w, Screen *screen) {
unsigned int cell_width = os_window->fonts_data->cell_width, cell_height = os_window->fonts_data->cell_height;
unsigned int left = w->geometry.left, top = w->geometry.top;
left += screen->cursor->x * cell_width;
top += screen->cursor->y * cell_height;
glfwUpdateIMEState(global_state.callback_os_window->handle, 2, left, top, cell_width, cell_height);
}
void
on_key_input(int key, int scancode, int action, int mods, const char* text, int state) {
Window *w = active_window();
@ -120,6 +130,7 @@ on_key_input(int key, int scancode, int action, int mods, const char* text, int
Screen *screen = w->render_data.screen;
switch(state) {
case 1: // update pre-edit text
update_ime_position(global_state.callback_os_window, w, screen);
return;
case 2: // commit text
if (text && *text) {