From: Attila Fidan dev@print0.net
--- dlls/winewayland.drv/wayland_text_input.c | 32 ++++++++++++++++++++--- dlls/winewayland.drv/waylanddrv.h | 2 ++ 2 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/dlls/winewayland.drv/wayland_text_input.c b/dlls/winewayland.drv/wayland_text_input.c index f69b212a6a8..4237326428a 100644 --- a/dlls/winewayland.drv/wayland_text_input.c +++ b/dlls/winewayland.drv/wayland_text_input.c @@ -76,11 +76,15 @@ static void text_input_leave(void *data, struct zwp_text_input_v3 *zwp_text_inpu struct wl_surface *surface) { struct wayland_text_input *text_input = data; + HWND hwnd; TRACE("data %p, text_input %p, surface %p.\n", data, zwp_text_input_v3, surface);
pthread_mutex_lock(&text_input->mutex); zwp_text_input_v3_disable(text_input->zwp_text_input_v3); zwp_text_input_v3_commit(text_input->zwp_text_input_v3); + assert(text_input->wl_surface); + hwnd = wl_surface_get_user_data(text_input->wl_surface); + post_ime_update(hwnd, 0, NULL, NULL); text_input->wl_surface = NULL; pthread_mutex_unlock(&text_input->mutex); } @@ -88,6 +92,14 @@ static void text_input_leave(void *data, struct zwp_text_input_v3 *zwp_text_inpu static void text_input_preedit_string(void *data, struct zwp_text_input_v3 *zwp_text_input_v3, const char *text, int32_t cursor_begin, int32_t cursor_end) { + struct wayland_text_input *text_input = data; + TRACE("data %p, text_input %p, text %s, cursor_begin %d.\n", data, zwp_text_input_v3, + debugstr_a(text), cursor_begin); + + pthread_mutex_lock(&text_input->mutex); + text_input->preedit_string = strdup(text); + text_input->cursor_begin = cursor_begin; + pthread_mutex_unlock(&text_input->mutex); }
static void text_input_commit_string(void *data, struct zwp_text_input_v3 *zwp_text_input_v3, @@ -110,7 +122,9 @@ static void text_input_done(void *data, struct zwp_text_input_v3 *zwp_text_input uint32_t serial) { struct wayland_text_input *text_input = data; - WCHAR *wide_commit; + DWORD preedit_cursor_pos = 0; + WCHAR *wide_preedit = NULL; + WCHAR *wide_commit = NULL; HWND hwnd; TRACE("data %p, text_input %p, serial %u.\n", data, zwp_text_input_v3, serial);
@@ -119,9 +133,21 @@ static void text_input_done(void *data, struct zwp_text_input_v3 *zwp_text_input hwnd = wl_surface_get_user_data(text_input->wl_surface);
wide_commit = strdupUtoW(text_input->commit_string); - post_ime_update(hwnd, 0, NULL, wide_commit); - free(wide_commit);
+ if ((wide_preedit = strdupUtoW(text_input->preedit_string))) + { + RtlUTF8ToUnicodeN(NULL, 0, &preedit_cursor_pos, text_input->preedit_string, + text_input->cursor_begin); + preedit_cursor_pos /= sizeof(WCHAR); + } + + post_ime_update(hwnd, preedit_cursor_pos, wide_preedit, wide_commit); + + free(wide_preedit); + free(wide_commit); + text_input->cursor_begin = 0; + free(text_input->preedit_string); + text_input->preedit_string = NULL; free(text_input->commit_string); text_input->commit_string = NULL; pthread_mutex_unlock(&text_input->mutex); diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index 9c8ace9f049..97e3db65fec 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -115,6 +115,8 @@ struct wayland_pointer struct wayland_text_input { struct zwp_text_input_v3 *zwp_text_input_v3; + char *preedit_string; + int32_t cursor_begin; char *commit_string; struct wl_surface *wl_surface; pthread_mutex_t mutex;