From: Byeongsik Jeon bsjeon@hanmail.net
In winemac.drv, Multiple ime update calls occur during ImeProcessKey. These multiple ime update calls need to be properly merged into ‘data->update’. However, currently win32u/imm.c::post_ime_update() only keeps the last ime update call.
Valid rules are: - The comp_str is discarded when the next ime update call occurs, so it is only valid when the last ime update call has the comp_str. - The result_str is retained even if the next ime update call occurs. - If the next ime update call has the result_str, it is appended after the previous result_str. (e.g. 'r-k-1' or 'r-k-<SPACE>')
Test key sequences are: - "Japanese Romanji" : 'nihongo-<SPACE>-n' - "Korean 2-Set Keyboard" : 'r-k-s-k' - "Korean 2-Set Keyboard" : 'r-k-1" or 'r-k-<SPACE>' --- dlls/win32u/imm.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/dlls/win32u/imm.c b/dlls/win32u/imm.c index 99dc3e5e225..f673693f6a0 100644 --- a/dlls/win32u/imm.c +++ b/dlls/win32u/imm.c @@ -442,6 +442,8 @@ static void post_ime_update( HWND hwnd, UINT cursor_pos, WCHAR *comp_str, WCHAR struct imm_thread_data *data = get_imm_thread_data(); UINT id = -1, comp_len, result_len; struct ime_update *update; + WCHAR *prev_result_str = NULL; + UINT prev_result_len = 0;
TRACE( "hwnd %p, cursor_pos %u, comp_str %s, result_str %s\n", hwnd, cursor_pos, debugstr_w(comp_str), debugstr_w(result_str) ); @@ -449,10 +451,23 @@ static void post_ime_update( HWND hwnd, UINT cursor_pos, WCHAR *comp_str, WCHAR comp_len = comp_str ? wcslen( comp_str ) + 1 : 0; result_len = result_str ? wcslen( result_str ) + 1 : 0;
- if (!(update = malloc( offsetof(struct ime_update, buffer[comp_len + result_len]) ))) return; + if (data->ime_process_vkey && data->update && data->update->result_str) + { + prev_result_str = data->update->result_str; + prev_result_len = result_len ? wcslen( prev_result_str ) + : prev_result_str ? wcslen( prev_result_str ) + 1 : 0; + } + + if (!(update = malloc( offsetof(struct ime_update, + buffer[comp_len + prev_result_len + result_len]) ))) return; update->cursor_pos = cursor_pos; update->comp_str = comp_str ? memcpy( update->buffer, comp_str, comp_len * sizeof(WCHAR) ) : NULL; - update->result_str = result_str ? memcpy( update->buffer + comp_len, result_str, result_len * sizeof(WCHAR) ) : NULL; + update->result_str = result_str ? memcpy( update->buffer + comp_len + prev_result_len, + result_str, result_len * sizeof(WCHAR) ) + : NULL; + if (prev_result_len) + update->result_str = memcpy( update->buffer + comp_len, + prev_result_str, prev_result_len * sizeof(WCHAR) );
if (!(update->vkey = data->ime_process_vkey)) {