Commit 800af36d authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winex11: Move NotifyIME to the default IME implementation.

parent 56d0b870
......@@ -83,6 +83,20 @@ static WCHAR *input_context_get_comp_str( INPUTCONTEXT *ctx, BOOL result, UINT *
return text;
}
static void input_context_reset_comp_str( INPUTCONTEXT *ctx )
{
COMPOSITIONSTRING *compstr;
if (!(compstr = ImmLockIMCC( ctx->hCompStr )))
WARN( "Failed to lock input context composition string\n" );
else
{
memset( compstr, 0, sizeof(*compstr) );
compstr->dwSize = sizeof(*compstr);
ImmUnlockIMCC( ctx->hCompStr );
}
}
static HFONT input_context_select_ui_font( INPUTCONTEXT *ctx, HDC hdc )
{
struct ime_private *priv;
......@@ -93,6 +107,47 @@ static HFONT input_context_select_ui_font( INPUTCONTEXT *ctx, HDC hdc )
return font;
}
static void ime_send_message( HIMC himc, UINT message, WPARAM wparam, LPARAM lparam )
{
INPUTCONTEXT *ctx;
TRANSMSG *msgs;
HIMCC himcc;
if (!(ctx = ImmLockIMC( himc ))) return;
if (!(himcc = ImmReSizeIMCC( ctx->hMsgBuf, (ctx->dwNumMsgBuf + 1) * sizeof(*msgs) )))
WARN( "Failed to resize input context message buffer\n" );
else if (!(msgs = ImmLockIMCC( (ctx->hMsgBuf = himcc) )))
WARN( "Failed to lock input context message buffer\n" );
else
{
TRANSMSG msg = {.message = message, .wParam = wparam, .lParam = lparam};
msgs[ctx->dwNumMsgBuf++] = msg;
ImmUnlockIMCC( ctx->hMsgBuf );
}
ImmUnlockIMC( himc );
ImmGenerateMessage( himc );
}
static void ime_set_composition_status( HIMC himc, BOOL composition )
{
struct ime_private *priv;
INPUTCONTEXT *ctx;
UINT msg = 0;
if (!(ctx = ImmLockIMC( himc ))) return;
if ((priv = ImmLockIMCC( ctx->hPrivate )))
{
if (!priv->bInComposition && composition) msg = WM_IME_STARTCOMPOSITION;
else if (priv->bInComposition && !composition) msg = WM_IME_ENDCOMPOSITION;
priv->bInComposition = composition;
ImmUnlockIMCC( ctx->hPrivate );
}
ImmUnlockIMC( himc );
if (msg) ime_send_message( himc, msg, 0, 0 );
}
static void ime_ui_paint( HIMC himc, HWND hwnd )
{
PAINTSTRUCT ps;
......@@ -390,9 +445,88 @@ BOOL WINAPI ImeSetCompositionString( HIMC himc, DWORD index, const void *comp, D
BOOL WINAPI NotifyIME( HIMC himc, DWORD action, DWORD index, DWORD value )
{
FIXME( "himc %p, action %lu, index %lu, value %lu stub!\n", himc, action, index, value );
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
return FALSE;
struct ime_private *priv;
INPUTCONTEXT *ctx;
TRACE( "himc %p, action %#lx, index %#lx, value %#lx stub!\n", himc, action, index, value );
if (!(ctx = ImmLockIMC( himc ))) return FALSE;
switch (action)
{
case NI_CONTEXTUPDATED:
switch (value)
{
case IMC_SETCOMPOSITIONFONT:
if ((priv = ImmLockIMCC( ctx->hPrivate )))
{
if (priv->textfont) DeleteObject( priv->textfont );
priv->textfont = CreateFontIndirectW( &ctx->lfFont.W );
ImmUnlockIMCC( ctx->hPrivate );
}
break;
case IMC_SETOPENSTATUS:
if (!ctx->fOpen)
{
input_context_reset_comp_str( ctx );
ime_set_composition_status( himc, FALSE );
}
NtUserNotifyIMEStatus( ctx->hWnd, ctx->fOpen );
break;
default:
FIXME( "himc %p, action %#lx, index %#lx, value %#lx stub!\n", himc, action, index, value );
break;
}
break;
case NI_COMPOSITIONSTR:
switch (index)
{
case CPS_COMPLETE:
{
COMPOSITIONSTRING *compstr;
if (!(compstr = ImmLockIMCC( ctx->hCompStr )))
WARN( "Failed to lock input context composition string\n" );
else
{
WCHAR wchr = *(WCHAR *)((BYTE *)compstr + compstr->dwCompStrOffset);
COMPOSITIONSTRING tmp = *compstr;
UINT flags = 0;
memset( compstr, 0, sizeof(*compstr) );
compstr->dwSize = tmp.dwSize;
compstr->dwResultStrLen = tmp.dwCompStrLen;
compstr->dwResultStrOffset = tmp.dwCompStrOffset;
compstr->dwResultClauseLen = tmp.dwCompClauseLen;
compstr->dwResultClauseOffset = tmp.dwCompClauseOffset;
ImmUnlockIMCC( ctx->hCompStr );
if (tmp.dwCompStrLen) flags |= GCS_RESULTSTR;
if (tmp.dwCompClauseLen) flags |= GCS_RESULTCLAUSE;
if (flags) ime_send_message( himc, WM_IME_COMPOSITION, wchr, flags );
}
ImmSetOpenStatus( himc, FALSE );
break;
}
case CPS_CANCEL:
input_context_reset_comp_str( ctx );
ImmSetOpenStatus( himc, FALSE );
break;
default:
FIXME( "himc %p, action %#lx, index %#lx, value %#lx stub!\n", himc, action, index, value );
break;
}
break;
default:
FIXME( "himc %p, action %#lx, index %#lx, value %#lx stub!\n", himc, action, index, value );
break;
}
ImmUnlockIMC( himc );
return TRUE;
}
LRESULT WINAPI ImeEscape( HIMC himc, UINT escape, void *data )
......
......@@ -529,108 +529,6 @@ UINT WINAPI ImeToAsciiEx (UINT uVKey, UINT uScanCode, const LPBYTE lpbKeyState,
return 0;
}
BOOL WINAPI NotifyIME(HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue)
{
BOOL bRet = FALSE;
LPINPUTCONTEXT lpIMC;
TRACE("%p %li %li %li\n",hIMC,dwAction,dwIndex,dwValue);
lpIMC = LockRealIMC(hIMC);
if (lpIMC == NULL)
return FALSE;
switch (dwAction)
{
case NI_OPENCANDIDATE: FIXME("NI_OPENCANDIDATE\n"); break;
case NI_CLOSECANDIDATE: FIXME("NI_CLOSECANDIDATE\n"); break;
case NI_SELECTCANDIDATESTR: FIXME("NI_SELECTCANDIDATESTR\n"); break;
case NI_CHANGECANDIDATELIST: FIXME("NI_CHANGECANDIDATELIST\n"); break;
case NI_SETCANDIDATE_PAGESTART: FIXME("NI_SETCANDIDATE_PAGESTART\n"); break;
case NI_SETCANDIDATE_PAGESIZE: FIXME("NI_SETCANDIDATE_PAGESIZE\n"); break;
case NI_CONTEXTUPDATED:
switch (dwValue)
{
case IMC_SETCOMPOSITIONWINDOW: FIXME("IMC_SETCOMPOSITIONWINDOW\n"); break;
case IMC_SETCONVERSIONMODE: FIXME("IMC_SETCONVERSIONMODE\n"); break;
case IMC_SETSENTENCEMODE: FIXME("IMC_SETSENTENCEMODE\n"); break;
case IMC_SETCANDIDATEPOS: FIXME("IMC_SETCANDIDATEPOS\n"); break;
case IMC_SETCOMPOSITIONFONT:
{
LPIMEPRIVATE myPrivate;
TRACE("IMC_SETCOMPOSITIONFONT\n");
myPrivate = ImmLockIMCC(lpIMC->hPrivate);
if (myPrivate->textfont)
{
DeleteObject(myPrivate->textfont);
myPrivate->textfont = NULL;
}
myPrivate->textfont = CreateFontIndirectW(&lpIMC->lfFont.W);
ImmUnlockIMCC(lpIMC->hPrivate);
}
break;
case IMC_SETOPENSTATUS:
if (!lpIMC->fOpen)
{
input_context_reset_comp_str( lpIMC );
ime_set_composition_status( hIMC, FALSE );
}
NtUserNotifyIMEStatus( lpIMC->hWnd, lpIMC->fOpen );
bRet = TRUE;
break;
default: FIXME("Unknown\n"); break;
}
break;
case NI_COMPOSITIONSTR:
switch (dwIndex)
{
case CPS_COMPLETE:
{
COMPOSITIONSTRING *compstr;
if (!(compstr = ImmLockIMCC( lpIMC->hCompStr )))
WARN( "Failed to lock input context composition string\n" );
else
{
WCHAR wchr = *(WCHAR *)((BYTE *)compstr + compstr->dwCompStrOffset);
COMPOSITIONSTRING tmp = *compstr;
UINT flags = 0;
memset( compstr, 0, sizeof(*compstr) );
compstr->dwSize = tmp.dwSize;
compstr->dwResultStrLen = tmp.dwCompStrLen;
compstr->dwResultStrOffset = tmp.dwCompStrOffset;
compstr->dwResultClauseLen = tmp.dwCompClauseLen;
compstr->dwResultClauseOffset = tmp.dwCompClauseOffset;
ImmUnlockIMCC( lpIMC->hCompStr );
if (tmp.dwCompStrLen) flags |= GCS_RESULTSTR;
if (tmp.dwCompClauseLen) flags |= GCS_RESULTCLAUSE;
if (flags) GenerateIMEMessage( hIMC, WM_IME_COMPOSITION, wchr, flags );
}
ImmSetOpenStatus( hIMC, FALSE );
bRet = TRUE;
}
break;
case CPS_CONVERT: FIXME("CPS_CONVERT\n"); break;
case CPS_REVERT: FIXME("CPS_REVERT\n"); break;
case CPS_CANCEL:
input_context_reset_comp_str( lpIMC );
ime_set_composition_status( hIMC, FALSE );
bRet = TRUE;
break;
default: FIXME("Unknown\n"); break;
}
break;
default: FIXME("Unknown Message\n"); break;
}
UnlockRealIMC(hIMC);
return bRet;
}
BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp,
DWORD dwCompLen, LPCVOID lpRead,
DWORD dwReadLen)
......
......@@ -13,6 +13,5 @@
#IME Interface
@ stdcall ImeSelect(long long)
@ stdcall ImeToAsciiEx(long long ptr ptr long long)
@ stdcall NotifyIME(long long long long)
@ stdcall ImeSetCompositionString(long long ptr long ptr long)
@ stdcall ImeProcessKey(long long long ptr)
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