From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winex11.drv/xim.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/dlls/winex11.drv/xim.c b/dlls/winex11.drv/xim.c index 9f238e0cb83..1637549511b 100644 --- a/dlls/winex11.drv/xim.c +++ b/dlls/winex11.drv/xim.c @@ -270,6 +270,27 @@ static int xic_preedit_caret( XIC xic, XPointer user, XPointer arg ) return 0; }
+static int xic_status_start( XIC xic, XPointer user, XPointer arg ) +{ + HWND hwnd = (HWND)user; + TRACE( "xic %p, hwnd %p, arg %p\n", xic, hwnd, arg ); + return 0; +} + +static int xic_status_done( XIC xic, XPointer user, XPointer arg ) +{ + HWND hwnd = (HWND)user; + TRACE( "xic %p, hwnd %p, arg %p\n", xic, hwnd, arg ); + return 0; +} + +static int xic_status_draw( XIC xic, XPointer user, XPointer arg ) +{ + HWND hwnd = (HWND)user; + TRACE( "xic %p, hwnd %p, arg %p\n", xic, hwnd, arg ); + return 0; +} + NTSTATUS x11drv_xim_reset( void *hwnd ) { XIC ic = X11DRV_get_ic(hwnd); @@ -467,6 +488,9 @@ XIC X11DRV_CreateIC( XIM xim, HWND hwnd, struct x11drv_win_data *data ) XICCallback preedit_draw = {.callback = xic_preedit_draw, .client_data = (XPointer)hwnd}; XICCallback preedit_start = {.callback = xic_preedit_start, .client_data = (XPointer)hwnd}; XICCallback preedit_state_notify = {.callback = xic_preedit_state_notify, .client_data = (XPointer)hwnd}; + XICCallback status_done = {.callback = xic_status_done, .client_data = (XPointer)hwnd}; + XICCallback status_draw = {.callback = xic_status_draw, .client_data = (XPointer)hwnd}; + XICCallback status_start = {.callback = xic_status_start, .client_data = (XPointer)hwnd}; XPoint spot = {0}; XVaNestedList preedit, status; XIC xic; @@ -482,7 +506,11 @@ XIC X11DRV_CreateIC( XIM xim, HWND hwnd, struct x11drv_win_data *data ) XNPreeditStartCallback, &preedit_start, XNPreeditStateNotifyCallback, &preedit_state_notify, XNSpotLocation, &spot, NULL ); - status = XVaCreateNestedList( 0, XNFontSet, fontSet, NULL ); + status = XVaCreateNestedList( 0, XNFontSet, fontSet, + XNStatusStartCallback, &status_start, + XNStatusDoneCallback, &status_done, + XNStatusDrawCallback, &status_draw, + NULL ); xic = XCreateIC( xim, XNInputStyle, ximStyle, XNPreeditAttributes, preedit, XNStatusAttributes, status, XNClientWindow, win, XNFocusWindow, win, XNDestroyCallback, &destroy, NULL ); TRACE( "created XIC %p\n", xic );
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winex11.drv/xim.c | 84 ++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 56 deletions(-)
diff --git a/dlls/winex11.drv/xim.c b/dlls/winex11.drv/xim.c index 1637549511b..e73e019d448 100644 --- a/dlls/winex11.drv/xim.c +++ b/dlls/winex11.drv/xim.c @@ -49,17 +49,8 @@ static DWORD dwCompStringLength = 0; static LPBYTE CompositionString = NULL; static DWORD dwCompStringSize = 0;
-#define STYLE_OFFTHESPOT (XIMPreeditArea | XIMStatusArea) -#define STYLE_OVERTHESPOT (XIMPreeditPosition | XIMStatusNothing) -#define STYLE_ROOT (XIMPreeditNothing | XIMStatusNothing) -/* this uses all the callbacks to utilize full IME support */ -#define STYLE_CALLBACK (XIMPreeditCallbacks | XIMStatusNothing) -/* in order to enable deadkey support */ -#define STYLE_NONE (XIMPreeditNothing | XIMStatusNothing) - -static XIMStyle ximStyle = 0; -static XIMStyle ximStyleRoot = 0; -static XIMStyle ximStyleRequest = STYLE_CALLBACK; +static XIMStyle input_style = 0; +static XIMStyle input_style_req = XIMPreeditCallbacks | XIMStatusCallbacks;
static const char *debugstr_xim_style( XIMStyle style ) { @@ -338,13 +329,6 @@ BOOL xim_init( const WCHAR *input_style ) static const WCHAR overthespotW[] = {'o','v','e','r','t','h','e','s','p','o','t',0}; static const WCHAR rootW[] = {'r','o','o','t',0};
- if (!wcsicmp( input_style, offthespotW )) - ximStyleRequest = STYLE_OFFTHESPOT; - else if (!wcsicmp( input_style, overthespotW )) - ximStyleRequest = STYLE_OVERTHESPOT; - else if (!wcsicmp( input_style, rootW )) - ximStyleRequest = STYLE_ROOT; - if (!XSupportsLocale()) { WARN("X does not support locale.\n"); @@ -355,6 +339,17 @@ BOOL xim_init( const WCHAR *input_style ) WARN("Could not set locale modifiers.\n"); return FALSE; } + + if (!wcsicmp( input_style, offthespotW )) + input_style_req = XIMPreeditArea | XIMStatusArea; + else if (!wcsicmp( input_style, overthespotW )) + input_style_req = XIMPreeditPosition | XIMStatusNothing; + else if (!wcsicmp( input_style, rootW )) + input_style_req = XIMPreeditNothing | XIMStatusNothing; + + TRACE( "requesting %s style %#lx %s\n", debugstr_w(input_style), input_style_req, + debugstr_xim_style( input_style_req ) ); + return TRUE; }
@@ -364,13 +359,12 @@ static void xim_destroy( XIM xim, XPointer user, XPointer arg ); static XIM xim_create( struct x11drv_thread_data *data ) { XIMCallback destroy = {.callback = xim_destroy, .client_data = (XPointer)data}; - Display *display = data->display; - XIMStyle ximStyleNone; - XIMStyles *ximStyles = NULL; + XIMStyle input_style_fallback = XIMPreeditNone | XIMStatusNone; + XIMStyles *styles = NULL; INT i; XIM xim;
- if (!(xim = XOpenIM( display, NULL, NULL, NULL ))) + if (!(xim = XOpenIM( data->display, NULL, NULL, NULL ))) { WARN("Could not open input method.\n"); return NULL; @@ -382,50 +376,28 @@ static XIM xim_create( struct x11drv_thread_data *data ) TRACE( "xim %p, XDisplayOfIM %p, XLocaleOfIM %s\n", xim, XDisplayOfIM( xim ), debugstr_a(XLocaleOfIM( xim )) );
- XGetIMValues(xim, XNQueryInputStyle, &ximStyles, NULL); - if (ximStyles == 0) + XGetIMValues( xim, XNQueryInputStyle, &styles, NULL ); + if (!styles) { WARN( "Could not find supported input style.\n" ); XCloseIM( xim ); return NULL; }
- ximStyleRoot = 0; - ximStyleNone = 0; - ximStyle = 0; - - TRACE( "input styles count %u\n", ximStyles->count_styles ); - for (i = 0; i < ximStyles->count_styles; ++i) + TRACE( "input styles count %u\n", styles->count_styles ); + for (i = 0, input_style = 0; i < styles->count_styles; ++i) { - XIMStyle style = ximStyles->supported_styles[i]; + XIMStyle style = styles->supported_styles[i]; TRACE( " %u: %#lx %s\n", i, style, debugstr_xim_style( style ) );
- if (!ximStyle && (ximStyles->supported_styles[i] == - ximStyleRequest)) - { - ximStyle = ximStyleRequest; - TRACE("Setting Style: ximStyle = ximStyleRequest\n"); - } - else if (!ximStyleRoot &&(ximStyles->supported_styles[i] == - STYLE_ROOT)) - { - ximStyleRoot = STYLE_ROOT; - TRACE("Setting Style: ximStyleRoot = STYLE_ROOT\n"); - } - else if (!ximStyleNone && (ximStyles->supported_styles[i] == - STYLE_NONE)) - { - TRACE("Setting Style: ximStyleNone = STYLE_NONE\n"); - ximStyleNone = STYLE_NONE; - } + if (style == input_style_req) input_style = style; + if (!input_style && (style & input_style_req)) input_style = style; + if (input_style_fallback > style) input_style_fallback = style; } - XFree(ximStyles); - - if (ximStyle == 0) - ximStyle = ximStyleRoot; + XFree(styles);
- if (ximStyle == 0) - ximStyle = ximStyleNone; + if (!input_style) input_style = input_style_fallback; + TRACE( "selected style %#lx %s\n", input_style, debugstr_xim_style( input_style ) );
return xim; } @@ -511,7 +483,7 @@ XIC X11DRV_CreateIC( XIM xim, HWND hwnd, struct x11drv_win_data *data ) XNStatusDoneCallback, &status_done, XNStatusDrawCallback, &status_draw, NULL ); - xic = XCreateIC( xim, XNInputStyle, ximStyle, XNPreeditAttributes, preedit, XNStatusAttributes, status, + xic = XCreateIC( xim, XNInputStyle, input_style, XNPreeditAttributes, preedit, XNStatusAttributes, status, XNClientWindow, win, XNFocusWindow, win, XNDestroyCallback, &destroy, NULL ); TRACE( "created XIC %p\n", xic );
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winex11.drv/xim.c | 55 ++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 32 deletions(-)
diff --git a/dlls/winex11.drv/xim.c b/dlls/winex11.drv/xim.c index e73e019d448..a60ee4b2042 100644 --- a/dlls/winex11.drv/xim.c +++ b/dlls/winex11.drv/xim.c @@ -172,47 +172,38 @@ static int xic_preedit_done( XIC xic, XPointer user, XPointer arg )
static int xic_preedit_draw( XIC xic, XPointer user, XPointer arg ) { - XIMPreeditDrawCallbackStruct *P_DR = (void *)arg; + XIMPreeditDrawCallbackStruct *params = (void *)arg; HWND hwnd = (HWND)user; + XIMText *text;
TRACE( "xic %p, hwnd %p, arg %p\n", xic, hwnd, arg );
- if (P_DR) + if (!params) return 0; + + if (!(text = params->text)) + X11DRV_ImmSetInternalString( params->chg_first, params->chg_length, NULL, 0 ); + else if (!text->encoding_is_wchar) { - int sel = P_DR->chg_first; - int len = P_DR->chg_length; - if (P_DR->text) + size_t text_len; + WCHAR *output; + + text_len = strlen( text->string.multi_byte ); + if ((output = malloc( text_len * sizeof(WCHAR) ))) { - if (! P_DR->text->encoding_is_wchar) - { - size_t text_len; - WCHAR *output; - - TRACE("multibyte\n"); - text_len = strlen( P_DR->text->string.multi_byte ); - if ((output = malloc( text_len * sizeof(WCHAR) ))) - { - text_len = ntdll_umbstowcs( P_DR->text->string.multi_byte, text_len, - output, text_len ); - - X11DRV_ImmSetInternalString( sel, len, output, text_len ); - free( output ); - } - } - else - { - FIXME("wchar PROBIBILY WRONG\n"); - X11DRV_ImmSetInternalString (sel, len, - (LPWSTR)P_DR->text->string.wide_char, - P_DR->text->length); - } + text_len = ntdll_umbstowcs( text->string.multi_byte, text_len, output, text_len ); + X11DRV_ImmSetInternalString( params->chg_first, params->chg_length, output, text_len ); + free( output ); } - else - X11DRV_ImmSetInternalString (sel, len, NULL, 0); - x11drv_client_call( client_ime_set_cursor_pos, P_DR->caret ); + } + else + { + FIXME( "wchar PROBIBILY WRONG\n" ); + X11DRV_ImmSetInternalString( params->chg_first, params->chg_length, + (WCHAR *)text->string.wide_char, text->length ); }
- TRACE("Finished\n"); + x11drv_client_call( client_ime_set_cursor_pos, params->caret ); + return 0; }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winex11.drv/xim.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/dlls/winex11.drv/xim.c b/dlls/winex11.drv/xim.c index a60ee4b2042..219e5b18974 100644 --- a/dlls/winex11.drv/xim.c +++ b/dlls/winex11.drv/xim.c @@ -182,24 +182,30 @@ static int xic_preedit_draw( XIC xic, XPointer user, XPointer arg )
if (!(text = params->text)) X11DRV_ImmSetInternalString( params->chg_first, params->chg_length, NULL, 0 ); - else if (!text->encoding_is_wchar) + 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 ((str = malloc( len + 1 ))) + { + wcstombs( str, text->string.wide_char, len ); + str[len] = 0; + }
- text_len = strlen( text->string.multi_byte ); + text_len = str ? strlen( str ) : 0; if ((output = malloc( text_len * sizeof(WCHAR) ))) { - text_len = ntdll_umbstowcs( text->string.multi_byte, text_len, output, text_len ); + text_len = ntdll_umbstowcs( str, text_len, output, text_len ); X11DRV_ImmSetInternalString( params->chg_first, params->chg_length, output, text_len ); free( output ); } - } - else - { - FIXME( "wchar PROBIBILY WRONG\n" ); - X11DRV_ImmSetInternalString( params->chg_first, params->chg_length, - (WCHAR *)text->string.wide_char, text->length ); + + if (str != text->string.multi_byte) free( str ); }
x11drv_client_call( client_ime_set_cursor_pos, params->caret );
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winex11.drv/xim.c | 67 +++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 34 deletions(-)
diff --git a/dlls/winex11.drv/xim.c b/dlls/winex11.drv/xim.c index 219e5b18974..0251677eef9 100644 --- a/dlls/winex11.drv/xim.c +++ b/dlls/winex11.drv/xim.c @@ -215,46 +215,45 @@ static int xic_preedit_draw( XIC xic, XPointer user, XPointer arg )
static int xic_preedit_caret( XIC xic, XPointer user, XPointer arg ) { - XIMPreeditCaretCallbackStruct *P_C = (void *)arg; + XIMPreeditCaretCallbackStruct *params = (void *)arg; HWND hwnd = (HWND)user; + int pos;
TRACE( "xic %p, hwnd %p, arg %p\n", xic, hwnd, arg );
- if (P_C) + if (!params) return 0; + + pos = x11drv_client_call( client_ime_get_cursor_pos, 0 ); + switch (params->direction) { - int pos = x11drv_client_call( client_ime_get_cursor_pos, 0 ); - TRACE("pos: %d\n", pos); - switch(P_C->direction) - { - case XIMForwardChar: - case XIMForwardWord: - pos++; - break; - case XIMBackwardChar: - case XIMBackwardWord: - pos--; - break; - case XIMLineStart: - pos = 0; - break; - case XIMAbsolutePosition: - pos = P_C->position; - break; - case XIMDontChange: - P_C->position = pos; - return 0; - case XIMCaretUp: - case XIMCaretDown: - case XIMPreviousLine: - case XIMNextLine: - case XIMLineEnd: - FIXME("Not implemented\n"); - break; - } - x11drv_client_call( client_ime_set_cursor_pos, pos ); - P_C->position = pos; + case XIMForwardChar: + case XIMForwardWord: + pos++; + break; + case XIMBackwardChar: + case XIMBackwardWord: + pos--; + break; + case XIMLineStart: + pos = 0; + break; + case XIMAbsolutePosition: + pos = params->position; + break; + case XIMDontChange: + params->position = pos; + return 0; + case XIMCaretUp: + case XIMCaretDown: + case XIMPreviousLine: + case XIMNextLine: + case XIMLineEnd: + FIXME( "Not implemented\n" ); + break; } - TRACE("Finished\n"); + x11drv_client_call( client_ime_set_cursor_pos, pos ); + params->position = pos; + return 0; }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winex11.drv/window.c | 22 ---------------------- dlls/winex11.drv/x11drv.h | 3 +-- dlls/winex11.drv/xim.c | 22 +++++++++++++++++----- 3 files changed, 18 insertions(+), 29 deletions(-)
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index ceaa5552f25..3b49b7e1d08 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -2311,28 +2311,6 @@ Window X11DRV_get_whole_window( HWND hwnd ) }
-/*********************************************************************** - * X11DRV_get_ic - * - * Return the X input context associated with a window - */ -XIC X11DRV_get_ic( HWND hwnd ) -{ - struct x11drv_win_data *data = get_win_data( hwnd ); - XIM xim; - XIC ret = 0; - - if (data) - { - x11drv_thread_data()->last_xic_hwnd = hwnd; - ret = data->xic; - if (!ret && (xim = x11drv_thread_data()->xim)) ret = X11DRV_CreateIC( xim, hwnd, data ); - release_win_data( data ); - } - return ret; -} - - /*********************************************************************** * X11DRV_GetDC (X11DRV.@) */ diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 893099489e3..e7db96f35cb 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -641,7 +641,6 @@ struct x11drv_win_data extern struct x11drv_win_data *get_win_data( HWND hwnd ) DECLSPEC_HIDDEN; extern void release_win_data( struct x11drv_win_data *data ) DECLSPEC_HIDDEN; extern Window X11DRV_get_whole_window( HWND hwnd ) DECLSPEC_HIDDEN; -extern XIC X11DRV_get_ic( HWND hwnd ) DECLSPEC_HIDDEN; extern Window get_dummy_parent(void) DECLSPEC_HIDDEN;
extern void sync_gl_drawable( HWND hwnd, BOOL known_child ) DECLSPEC_HIDDEN; @@ -820,9 +819,9 @@ extern struct x11drv_display_device_handler desktop_handler DECLSPEC_HIDDEN;
/* XIM support */ extern BOOL xim_init( const WCHAR *input_style ) DECLSPEC_HIDDEN; -extern XIC X11DRV_CreateIC( XIM xim, HWND hwnd, struct x11drv_win_data *data ) DECLSPEC_HIDDEN; extern void xim_thread_attach( struct x11drv_thread_data *data ) DECLSPEC_HIDDEN; extern void X11DRV_XIMLookupChars( const char *str, UINT count ) DECLSPEC_HIDDEN; +extern XIC X11DRV_get_ic( HWND hwnd ) DECLSPEC_HIDDEN;
#define XEMBED_MAPPED (1 << 0)
diff --git a/dlls/winex11.drv/xim.c b/dlls/winex11.drv/xim.c index 0251677eef9..b7f5f696ba5 100644 --- a/dlls/winex11.drv/xim.c +++ b/dlls/winex11.drv/xim.c @@ -448,7 +448,7 @@ static BOOL xic_destroy( XIC xic, XPointer user, XPointer arg ) return TRUE; }
-XIC X11DRV_CreateIC( XIM xim, HWND hwnd, struct x11drv_win_data *data ) +static XIC xic_create( XIM xim, HWND hwnd, Window win ) { XICCallback destroy = {.callback = xic_destroy, .client_data = (XPointer)hwnd}; XICCallback preedit_caret = {.callback = xic_preedit_caret, .client_data = (XPointer)hwnd}; @@ -462,10 +462,9 @@ XIC X11DRV_CreateIC( XIM xim, HWND hwnd, struct x11drv_win_data *data ) XPoint spot = {0}; XVaNestedList preedit, status; XIC xic; - Window win = data->whole_window; XFontSet fontSet = x11drv_thread_data()->font_set;
- TRACE( "xim %p, hwnd %p, data %p\n", xim, hwnd, data ); + TRACE( "xim %p, hwnd %p/%lx\n", xim, hwnd, win );
preedit = XVaCreateNestedList( 0, XNFontSet, fontSet, XNPreeditCaretCallback, &preedit_caret, @@ -483,10 +482,23 @@ XIC X11DRV_CreateIC( XIM xim, HWND hwnd, struct x11drv_win_data *data ) XNClientWindow, win, XNFocusWindow, win, XNDestroyCallback, &destroy, NULL ); TRACE( "created XIC %p\n", xic );
- data->xic = xic; - XFree( preedit ); XFree( status );
return xic; } + +XIC X11DRV_get_ic( HWND hwnd ) +{ + struct x11drv_win_data *data; + XIM xim; + XIC ret; + + if (!(data = get_win_data( hwnd ))) return 0; + x11drv_thread_data()->last_xic_hwnd = hwnd; + if (!(ret = data->xic) && (xim = x11drv_thread_data()->xim)) + ret = data->xic = xic_create( xim, hwnd, data->whole_window ); + release_win_data( data ); + + return ret; +}