Commit 6a36990f authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winex11: Simplify xic_preedit_draw control flow.

parent cbe43429
...@@ -170,22 +170,18 @@ static int xic_preedit_draw( XIC xic, XPointer user, XPointer arg ) ...@@ -170,22 +170,18 @@ static int xic_preedit_draw( XIC xic, XPointer user, XPointer arg )
{ {
XIMPreeditDrawCallbackStruct *params = (void *)arg; XIMPreeditDrawCallbackStruct *params = (void *)arg;
HWND hwnd = (HWND)user; HWND hwnd = (HWND)user;
size_t text_len;
XIMText *text; XIMText *text;
WCHAR *output;
char *str;
int len;
TRACE( "xic %p, hwnd %p, arg %p\n", xic, hwnd, arg ); TRACE( "xic %p, hwnd %p, arg %p\n", xic, hwnd, arg );
if (!params) return 0; if (!params) return 0;
if (!(text = params->text)) if (!(text = params->text)) str = NULL;
xim_update_comp_string( params->chg_first, params->chg_length, NULL, 0 ); else if (!text->encoding_is_wchar) str = text->string.multi_byte;
else
{
size_t text_len;
WCHAR *output;
char *str;
int len;
if (!text->encoding_is_wchar) str = text->string.multi_byte;
else if ((len = wcstombs( NULL, text->string.wide_char, text->length )) < 0) str = NULL; else if ((len = wcstombs( NULL, text->string.wide_char, text->length )) < 0) str = NULL;
else if ((str = malloc( len + 1 ))) else if ((str = malloc( len + 1 )))
{ {
...@@ -193,16 +189,16 @@ static int xic_preedit_draw( XIC xic, XPointer user, XPointer arg ) ...@@ -193,16 +189,16 @@ static int xic_preedit_draw( XIC xic, XPointer user, XPointer arg )
str[len] = 0; str[len] = 0;
} }
text_len = str ? strlen( str ) : 0; if (!str || !(text_len = strlen( str )) || !(output = malloc( text_len * sizeof(WCHAR) )))
if ((output = malloc( text_len * sizeof(WCHAR) ))) xim_update_comp_string( params->chg_first, params->chg_length, NULL, 0 );
else
{ {
text_len = ntdll_umbstowcs( str, text_len, output, text_len ); text_len = ntdll_umbstowcs( str, text_len, output, text_len );
xim_update_comp_string( params->chg_first, params->chg_length, output, text_len ); xim_update_comp_string( params->chg_first, params->chg_length, output, text_len );
free( output ); free( output );
} }
if (str != text->string.multi_byte) free( str ); if (text && str != text->string.multi_byte) free( str );
}
x11drv_client_call( client_ime_set_cursor_pos, params->caret ); x11drv_client_call( client_ime_set_cursor_pos, params->caret );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment