Commit dc02e4d1 authored by Kusanagi Kouichi's avatar Kusanagi Kouichi Committed by Alexandre Julliard

winex11.drv: Fix IME status handling.

parent f56e1fcf
......@@ -719,32 +719,21 @@ BOOL WINAPI NotifyIME(HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue)
case IMC_SETOPENSTATUS:
TRACE("IMC_SETOPENSTATUS\n");
/* Indirectly called from XIM callbacks */
if (ImmGetIMCCLockCount(lpIMC->hPrivate) > 0)
bRet = TRUE;
X11DRV_SetPreeditState(lpIMC->hWnd, lpIMC->fOpen);
if (!lpIMC->fOpen)
{
bRet = TRUE;
break;
}
LPIMEPRIVATE myPrivate;
bRet = X11DRV_SetPreeditState(lpIMC->hWnd, lpIMC->fOpen);
if (bRet)
{
if (!lpIMC->fOpen)
myPrivate = ImmLockIMCC(lpIMC->hPrivate);
if (myPrivate->bInComposition)
{
LPIMEPRIVATE myPrivate;
myPrivate = ImmLockIMCC(lpIMC->hPrivate);
if (myPrivate->bInComposition)
{
X11DRV_ForceXIMReset(lpIMC->hWnd);
GenerateIMEMessage(hIMC, WM_IME_ENDCOMPOSITION, 0, 0);
myPrivate->bInComposition = FALSE;
}
ImmUnlockIMCC(lpIMC->hPrivate);
X11DRV_ForceXIMReset(lpIMC->hWnd);
GenerateIMEMessage(hIMC, WM_IME_ENDCOMPOSITION, 0, 0);
myPrivate->bInComposition = FALSE;
}
ImmUnlockIMCC(lpIMC->hPrivate);
}
else
lpIMC->fOpen = !lpIMC->fOpen;
break;
default: FIXME("Unknown\n"); break;
......@@ -957,7 +946,15 @@ DWORD WINAPI ImeGetImeMenuItems(HIMC hIMC, DWORD dwFlags, DWORD dwType,
/* Interfaces to XIM and other parts of winex11drv */
void IME_SetOpenStatus(BOOL fOpen, BOOL force)
void IME_SetOpenStatus(BOOL fOpen)
{
HIMC imc;
imc = RealIMC(FROM_X11);
ImmSetOpenStatus(imc, fOpen);
}
void IME_SetCompositionStatus(BOOL fOpen)
{
HIMC imc;
LPINPUTCONTEXT lpIMC;
......@@ -970,20 +967,18 @@ void IME_SetOpenStatus(BOOL fOpen, BOOL force)
myPrivate = ImmLockIMCC(lpIMC->hPrivate);
if (!fOpen && myPrivate->bInComposition)
if (fOpen && !myPrivate->bInComposition)
{
GenerateIMEMessage(imc, WM_IME_STARTCOMPOSITION, 0, 0);
}
else if (!fOpen && myPrivate->bInComposition)
{
ShowWindow(myPrivate->hwndDefault, SW_HIDE);
ImmDestroyIMCC(lpIMC->hCompStr);
lpIMC->hCompStr = ImeCreateBlankCompStr();
myPrivate->bInComposition = FALSE;
GenerateIMEMessage(imc, WM_IME_ENDCOMPOSITION, 0, 0);
}
if (lpIMC->fOpen && fOpen)
ImmSetOpenStatus(imc, FALSE);
if (fOpen || force)
ImmSetOpenStatus(imc, fOpen);
myPrivate->bInComposition = fOpen;
ImmUnlockIMCC(lpIMC->hPrivate);
ImmUnlockIMC(imc);
......@@ -1059,7 +1054,6 @@ void IME_SetResultString(LPWSTR lpResult, DWORD dwResultLen)
LPINPUTCONTEXT lpIMC;
HIMCC newCompStr;
LPIMEPRIVATE myPrivate;
BOOL fOpen;
imc = RealIMC(FROM_X11);
lpIMC = ImmLockIMC(imc);
......@@ -1071,15 +1065,11 @@ void IME_SetResultString(LPWSTR lpResult, DWORD dwResultLen)
lpIMC->hCompStr = newCompStr;
myPrivate = ImmLockIMCC(lpIMC->hPrivate);
fOpen = lpIMC->fOpen;
ImmSetOpenStatus(imc, TRUE);
if (!myPrivate->bInComposition)
GenerateIMEMessage(imc, WM_IME_STARTCOMPOSITION, 0, 0);
GenerateIMEMessage(imc, WM_IME_COMPOSITION, 0, GCS_RESULTSTR);
if (!myPrivate->bInComposition)
GenerateIMEMessage(imc, WM_IME_ENDCOMPOSITION, 0, 0);
if (!fOpen)
ImmSetOpenStatus(imc, FALSE);
ImmUnlockIMCC(lpIMC->hPrivate);
ImmUnlockIMC(imc);
......
......@@ -289,7 +289,8 @@ extern BOOL destroy_glxpixmap(Display *display, XID glxpixmap) DECLSPEC_HIDDEN;
/* IME support */
extern void IME_UnregisterClasses(void) DECLSPEC_HIDDEN;
extern void IME_SetOpenStatus(BOOL fOpen, BOOL force) DECLSPEC_HIDDEN;
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;
......@@ -716,7 +717,7 @@ extern XIC X11DRV_CreateIC(XIM xim, struct x11drv_win_data *data) DECLSPEC_HIDDE
extern void X11DRV_SetupXIM(void) DECLSPEC_HIDDEN;
extern void X11DRV_XIMLookupChars( const char *str, DWORD count ) DECLSPEC_HIDDEN;
extern void X11DRV_ForceXIMReset(HWND hwnd) DECLSPEC_HIDDEN;
extern BOOL X11DRV_SetPreeditState(HWND hwnd, BOOL fOpen) DECLSPEC_HIDDEN;
extern void X11DRV_SetPreeditState(HWND hwnd, BOOL fOpen) DECLSPEC_HIDDEN;
#define XEMBED_MAPPED (1 << 0)
......
......@@ -129,10 +129,10 @@ static BOOL XIMPreEditStateNotifyCallback(XIC xic, XPointer p, XPointer data)
switch (state)
{
case XIMPreeditEnable:
IME_SetOpenStatus(TRUE, TRUE);
IME_SetOpenStatus(TRUE);
break;
case XIMPreeditDisable:
IME_SetOpenStatus(FALSE, TRUE);
IME_SetOpenStatus(FALSE);
break;
default:
break;
......@@ -143,7 +143,7 @@ static BOOL XIMPreEditStateNotifyCallback(XIC xic, XPointer p, XPointer data)
static int XIMPreEditStartCallback(XIC ic, XPointer client_data, XPointer call_data)
{
TRACE("PreEditStartCallback %p\n",ic);
IME_SetOpenStatus(TRUE, FALSE);
IME_SetCompositionStatus(TRUE);
ximInComposeMode = TRUE;
return -1;
}
......@@ -157,7 +157,7 @@ static void XIMPreEditDoneCallback(XIC ic, XPointer client_data, XPointer call_d
dwCompStringSize = 0;
dwCompStringLength = 0;
CompositionString = NULL;
IME_SetOpenStatus(FALSE, FALSE);
IME_SetCompositionStatus(FALSE);
}
static void XIMPreEditDrawCallback(XIM ic, XPointer client_data,
......@@ -264,48 +264,31 @@ void X11DRV_ForceXIMReset(HWND hwnd)
}
}
BOOL X11DRV_SetPreeditState(HWND hwnd, BOOL fOpen)
void X11DRV_SetPreeditState(HWND hwnd, BOOL fOpen)
{
XIC ic;
XIMPreeditState state;
XVaNestedList attr_set, attr_get;
BOOL ret;
XVaNestedList attr;
ic = X11DRV_get_ic(hwnd);
if (!ic)
return FALSE;
return;
if (fOpen)
state = XIMPreeditEnable;
else
state = XIMPreeditDisable;
ret = FALSE;
wine_tsx11_lock();
attr_set = XVaCreateNestedList(0, XNPreeditState, state, NULL);
if (attr_set == NULL)
goto error1;
attr_get = XVaCreateNestedList(0, XNPreeditState, &state, NULL);
if (attr_get == NULL)
goto error2;
if (XSetICValues(ic, XNPreeditAttributes, attr_set, NULL) != NULL)
goto error3;
/* SCIM claims it supports XNPreeditState, but seems to ignore */
state = XIMPreeditUnKnown;
ret = XGetICValues(ic, XNPreeditAttributes, attr_get, NULL) == NULL &&
((fOpen && state == XIMPreeditEnable) ||
(!fOpen && state == XIMPreeditDisable));
error3:
XFree(attr_get);
error2:
XFree(attr_set);
error1:
attr = XVaCreateNestedList(0, XNPreeditState, state, NULL);
if (attr != NULL)
{
XSetICValues(ic, XNPreeditAttributes, attr, NULL);
XFree(attr);
}
wine_tsx11_unlock();
return ret;
}
......
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