winex11: Use unixlib interface for IME calls.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2022-05-03 23:10:15 +02:00 committed by Alexandre Julliard
parent 040d1f9bbd
commit 6290d0599d
5 changed files with 66 additions and 52 deletions

View File

@ -133,6 +133,11 @@ static const callback_func callback_funcs[] =
x11drv_clipboard_init,
x11drv_dnd_drop_event,
x11drv_dnd_leave_event,
x11drv_ime_get_cursor_pos,
x11drv_ime_set_composition_status,
x11drv_ime_set_cursor_pos,
x11drv_ime_set_open_status,
x11drv_ime_update_association,
};
C_ASSERT( ARRAYSIZE(callback_funcs) == client_funcs_count );
@ -150,6 +155,8 @@ static const kernel_callback kernel_callbacks[] =
x11drv_dnd_enter_event,
x11drv_dnd_position_event,
x11drv_dnd_post_drop,
x11drv_ime_set_composition_string,
x11drv_ime_set_result,
};
C_ASSERT( NtUserDriverCallbackFirst + ARRAYSIZE(kernel_callbacks) == client_func_last );

View File

@ -916,15 +916,16 @@ DWORD WINAPI ImeGetImeMenuItems(HIMC hIMC, DWORD dwFlags, DWORD dwType,
/* Interfaces to XIM and other parts of winex11drv */
void IME_SetOpenStatus(BOOL fOpen)
NTSTATUS x11drv_ime_set_open_status( UINT open )
{
HIMC imc;
imc = RealIMC(FROM_X11);
ImmSetOpenStatus(imc, fOpen);
ImmSetOpenStatus(imc, open);
return 0;
}
void IME_SetCompositionStatus(BOOL fOpen)
NTSTATUS x11drv_ime_set_composition_status( UINT open )
{
HIMC imc;
LPINPUTCONTEXT lpIMC;
@ -933,28 +934,29 @@ void IME_SetCompositionStatus(BOOL fOpen)
imc = RealIMC(FROM_X11);
lpIMC = ImmLockIMC(imc);
if (lpIMC == NULL)
return;
return 0;
myPrivate = ImmLockIMCC(lpIMC->hPrivate);
if (fOpen && !myPrivate->bInComposition)
if (open && !myPrivate->bInComposition)
{
GenerateIMEMessage(imc, WM_IME_STARTCOMPOSITION, 0, 0);
}
else if (!fOpen && myPrivate->bInComposition)
else if (!open && myPrivate->bInComposition)
{
ShowWindow(myPrivate->hwndDefault, SW_HIDE);
ImmDestroyIMCC(lpIMC->hCompStr);
lpIMC->hCompStr = ImeCreateBlankCompStr();
GenerateIMEMessage(imc, WM_IME_ENDCOMPOSITION, 0, 0);
}
myPrivate->bInComposition = fOpen;
myPrivate->bInComposition = open;
ImmUnlockIMCC(lpIMC->hPrivate);
ImmUnlockIMC(imc);
return 0;
}
INT IME_GetCursorPos(void)
NTSTATUS x11drv_ime_get_cursor_pos( UINT arg )
{
LPINPUTCONTEXT lpIMC;
INT rc = 0;
@ -974,68 +976,73 @@ INT IME_GetCursorPos(void)
return rc;
}
void IME_SetCursorPos(DWORD pos)
NTSTATUS x11drv_ime_set_cursor_pos( UINT pos )
{
LPINPUTCONTEXT lpIMC;
LPCOMPOSITIONSTRING compstr;
if (!hSelectedFrom)
return;
return 0;
lpIMC = LockRealIMC(FROM_X11);
if (!lpIMC)
return;
return 0;
compstr = ImmLockIMCC(lpIMC->hCompStr);
if (!compstr)
{
UnlockRealIMC(FROM_X11);
return;
return 0;
}
compstr->dwCursorPos = pos;
ImmUnlockIMCC(lpIMC->hCompStr);
UnlockRealIMC(FROM_X11);
GenerateIMEMessage(FROM_X11, WM_IME_COMPOSITION, pos, GCS_CURSORPOS);
return;
return 0;
}
void IME_UpdateAssociation(HWND focus)
NTSTATUS x11drv_ime_update_association( UINT arg )
{
HWND focus = UlongToHandle( arg );
ImmGetContext(focus);
if (!focus || !hSelectedFrom)
return;
ImmAssociateContext(focus,RealIMC(FROM_X11));
if (focus && hSelectedFrom)
ImmAssociateContext(focus,RealIMC(FROM_X11));
return 0;
}
BOOL IME_SetCompositionString(DWORD dwIndex, LPCVOID lpComp, DWORD dwCompLen,
LPCVOID lpRead, DWORD dwReadLen)
NTSTATUS WINAPI x11drv_ime_set_composition_string( void *param, ULONG size )
{
return ImeSetCompositionString(FROM_X11, dwIndex, lpComp, dwCompLen,
lpRead, dwReadLen);
return ImeSetCompositionString(FROM_X11, SCS_SETSTR, param, size, NULL, 0);
}
void IME_SetResultString(LPWSTR lpResult, DWORD dwResultLen)
NTSTATUS WINAPI x11drv_ime_set_result( void *params, ULONG len )
{
WCHAR *lpResult = params;
HIMC imc;
LPINPUTCONTEXT lpIMC;
HIMCC newCompStr;
LPIMEPRIVATE myPrivate;
BOOL inComp;
HWND focus;
len /= sizeof(WCHAR);
if ((focus = GetFocus()))
x11drv_ime_update_association( HandleToUlong( focus ));
imc = RealIMC(FROM_X11);
lpIMC = ImmLockIMC(imc);
if (lpIMC == NULL)
return;
return 0;
newCompStr = updateCompStr(lpIMC->hCompStr, NULL, 0);
ImmDestroyIMCC(lpIMC->hCompStr);
lpIMC->hCompStr = newCompStr;
newCompStr = updateResultStr(lpIMC->hCompStr, lpResult, dwResultLen);
newCompStr = updateResultStr(lpIMC->hCompStr, lpResult, len);
ImmDestroyIMCC(lpIMC->hCompStr);
lpIMC->hCompStr = newCompStr;
@ -1057,6 +1064,7 @@ void IME_SetResultString(LPWSTR lpResult, DWORD dwResultLen)
ImmSetOpenStatus(imc, FALSE);
ImmUnlockIMC(imc);
return 0;
}
/*****

View File

@ -75,6 +75,8 @@ enum x11drv_client_funcs
client_func_dnd_enter_event,
client_func_dnd_position_event,
client_func_dnd_post_drop,
client_func_ime_set_composition_string,
client_func_ime_set_result,
client_func_last
};
@ -86,6 +88,11 @@ enum client_callback
client_clipboard_init,
client_dnd_drop_event,
client_dnd_leave_event,
client_ime_get_cursor_pos,
client_ime_set_composition_status,
client_ime_set_cursor_pos,
client_ime_set_open_status,
client_ime_update_association,
client_funcs_count
};

View File

@ -284,18 +284,6 @@ extern const struct gdi_dc_funcs *X11DRV_XRender_Init(void) DECLSPEC_HIDDEN;
extern struct opengl_funcs *get_glx_driver(UINT) DECLSPEC_HIDDEN;
extern const struct vulkan_funcs *get_vulkan_driver(UINT) DECLSPEC_HIDDEN;
/* IME support */
extern void IME_SetOpenStatus(BOOL fOpen) DECLSPEC_HIDDEN;
extern void IME_SetCompositionStatus(BOOL fOpen) DECLSPEC_HIDDEN;
extern INT IME_GetCursorPos(void) DECLSPEC_HIDDEN;
extern void IME_SetCursorPos(DWORD pos) DECLSPEC_HIDDEN;
extern void IME_UpdateAssociation(HWND focus) DECLSPEC_HIDDEN;
extern BOOL IME_SetCompositionString(DWORD dwIndex, LPCVOID lpComp,
DWORD dwCompLen, LPCVOID lpRead,
DWORD dwReadLen) DECLSPEC_HIDDEN;
extern void IME_SetResultString(LPWSTR lpResult, DWORD dwResultlen) DECLSPEC_HIDDEN;
extern struct format_entry *import_xdnd_selection( Display *display, Window win, Atom selection,
Atom *targets, UINT count,
size_t *size ) DECLSPEC_HIDDEN;
@ -849,9 +837,16 @@ extern NTSTATUS x11drv_xim_reset( void *arg ) DECLSPEC_HIDDEN;
extern NTSTATUS WINAPI x11drv_dnd_enter_event( void *params, ULONG size ) DECLSPEC_HIDDEN;
extern NTSTATUS WINAPI x11drv_dnd_position_event( void *params, ULONG size ) DECLSPEC_HIDDEN;
extern NTSTATUS WINAPI x11drv_dnd_post_drop( void *data, ULONG size ) DECLSPEC_HIDDEN;
extern NTSTATUS WINAPI x11drv_ime_set_composition_string( void *params, ULONG size ) DECLSPEC_HIDDEN;
extern NTSTATUS WINAPI x11drv_ime_set_result( void *params, ULONG size ) DECLSPEC_HIDDEN;
extern NTSTATUS x11drv_dnd_drop_event( UINT arg ) DECLSPEC_HIDDEN;
extern NTSTATUS x11drv_dnd_leave_event( UINT arg ) DECLSPEC_HIDDEN;
extern NTSTATUS x11drv_ime_get_cursor_pos( UINT arg ) DECLSPEC_HIDDEN;
extern NTSTATUS x11drv_ime_set_composition_status( UINT arg ) DECLSPEC_HIDDEN;
extern NTSTATUS x11drv_ime_set_cursor_pos( UINT pos ) DECLSPEC_HIDDEN;
extern NTSTATUS x11drv_ime_set_open_status( UINT open ) DECLSPEC_HIDDEN;
extern NTSTATUS x11drv_ime_update_association( UINT arg ) DECLSPEC_HIDDEN;
extern NTSTATUS x11drv_client_func( enum x11drv_client_funcs func, const void *params,

View File

@ -89,25 +89,21 @@ static void X11DRV_ImmSetInternalString(DWORD dwOffset,
if (lpComp) memcpy(ptr_new, lpComp, byte_length);
dwCompStringLength += byte_expansion;
IME_SetCompositionString(SCS_SETSTR, CompositionString,
dwCompStringLength, NULL, 0);
x11drv_client_func( client_func_ime_set_composition_string,
CompositionString, dwCompStringLength );
}
void X11DRV_XIMLookupChars( const char *str, DWORD count )
{
WCHAR *output;
DWORD len;
HWND focus;
TRACE("%p %u\n", str, count);
if (!(output = malloc( count * sizeof(WCHAR) ))) return;
len = ntdll_umbstowcs( str, count, output, count );
if ((focus = GetFocus()))
IME_UpdateAssociation(focus);
IME_SetResultString( output, len );
x11drv_client_func( client_func_ime_set_result, output, len * sizeof(WCHAR) );
free( output );
}
@ -120,21 +116,22 @@ static BOOL XIMPreEditStateNotifyCallback(XIC xic, XPointer p, XPointer data)
switch (state)
{
case XIMPreeditEnable:
IME_SetOpenStatus(TRUE);
x11drv_client_call( client_ime_set_open_status, TRUE );
break;
case XIMPreeditDisable:
IME_SetOpenStatus(FALSE);
x11drv_client_call( client_ime_set_open_status, FALSE );
break;
default:
break;
}
return TRUE;
}
static int XIMPreEditStartCallback(XIC ic, XPointer client_data, XPointer call_data)
{
TRACE("PreEditStartCallback %p\n",ic);
IME_SetCompositionStatus(TRUE);
x11drv_client_call( client_ime_set_composition_status, TRUE );
ximInComposeMode = TRUE;
return -1;
}
@ -148,7 +145,7 @@ static void XIMPreEditDoneCallback(XIC ic, XPointer client_data, XPointer call_d
dwCompStringSize = 0;
dwCompStringLength = 0;
CompositionString = NULL;
IME_SetCompositionStatus(FALSE);
x11drv_client_call( client_ime_set_composition_status, FALSE );
}
static void XIMPreEditDrawCallback(XIM ic, XPointer client_data,
@ -188,7 +185,7 @@ static void XIMPreEditDrawCallback(XIM ic, XPointer client_data,
}
else
X11DRV_ImmSetInternalString (sel, len, NULL, 0);
IME_SetCursorPos(P_DR->caret);
x11drv_client_call( client_ime_set_cursor_pos, P_DR->caret );
}
TRACE("Finished\n");
}
@ -200,7 +197,7 @@ static void XIMPreEditCaretCallback(XIC ic, XPointer client_data,
if (P_C)
{
int pos = IME_GetCursorPos();
int pos = x11drv_client_call( client_ime_get_cursor_pos, 0 );
TRACE("pos: %d\n", pos);
switch(P_C->direction)
{
@ -229,7 +226,7 @@ static void XIMPreEditCaretCallback(XIC ic, XPointer client_data,
FIXME("Not implemented\n");
break;
}
IME_SetCursorPos(pos);
x11drv_client_call( client_ime_set_cursor_pos, pos );
P_C->position = pos;
}
TRACE("Finished\n");
@ -423,7 +420,7 @@ static BOOL open_xim( Display *display )
else
thread_data->font_set = NULL;
IME_UpdateAssociation(NULL);
x11drv_client_call( client_ime_update_association, 0 );
return TRUE;
}