Rémi Bernon (@rbernon) commented about dlls/winewayland.drv/wayland_text_input.c:
- commit_len = strlen(text_input->commit_string);
- if (!(output = malloc((commit_len + 1) * sizeof(WCHAR))))
- {
ERR("Failed to allocate memory for wide IME commit string.\n");
goto done;
- }
- len = ntdll_umbstowcs(text_input->commit_string, commit_len, output, commit_len);
- output[len] = 0;
- post_ime_update(hwnd, 0, NULL, output);
- free(output);
+done:
- free(text_input->commit_string);
- text_input->commit_string = NULL;
- pthread_mutex_unlock(&text_input->mutex);
Fwiw doing the same kind of thing for preedit seems to be enough. The builtin IME doesn't show up for some reason, but at least if the application implements its own preedit display, like `wordpad.exe`, we can get preedit strings to appear. This is especially useful for some IME like fcitx-hangul which will not show any host preedit window.
I did something like that here, with additional changes to track preedit_string the same way commit_string is, and it seems to be working:
```suggestion:-28+0 struct wayland_text_input *text_input = data; size_t commit_len, preedit_len; WCHAR *commit, *preedit; DWORD len; HWND hwnd;
TRACE("data %p input %p serial %u\n", data, zwp_text_input_v3, serial);
pthread_mutex_lock(&text_input->mutex); assert(text_input->wl_surface); hwnd = wl_surface_get_user_data(text_input->wl_surface);
if (text_input->serial != serial) goto done;
if (!text_input->commit_string || !(commit_len = strlen(text_input->commit_string))) commit = NULL; else if (!(commit = malloc((commit_len + 1) * sizeof(WCHAR)))) { ERR("Failed to allocate memory for wide IME commit string.\n"); goto done; }
if (!text_input->preedit_string || !(preedit_len = strlen(text_input->preedit_string))) preedit = NULL; else if (!(preedit = malloc((preedit_len + 1) * sizeof(WCHAR)))) { ERR("Failed to allocate memory for wide IME preedit string.\n"); goto done; }
if (commit) { len = ntdll_umbstowcs(text_input->commit_string, commit_len, commit, commit_len); commit[len] = 0; } if (preedit) { len = ntdll_umbstowcs(text_input->preedit_string, preedit_len, preedit, preedit_len); preedit[len] = 0; } post_ime_update(hwnd, 0, preedit, commit); free(preedit); free(commit);
done: free(text_input->commit_string); text_input->commit_string = NULL; free(text_input->preedit_string); text_input->preedit_string = NULL; pthread_mutex_unlock(&text_input->mutex); ```