Jacek Caban : imm32: Select default IME when creating its data.
Alexandre Julliard
julliard at winehq.org
Fri Jul 15 14:44:42 CDT 2022
Module: wine
Branch: master
Commit: 51f414bdc2dcb07b97570ebffec96369e9e2086f
URL: https://gitlab.winehq.org/wine/wine/-/commit/51f414bdc2dcb07b97570ebffec96369e9e2086f
Author: Jacek Caban <jacek at codeweavers.com>
Date: Fri Jul 15 12:50:30 2022 +0200
imm32: Select default IME when creating its data.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53348
---
dlls/imm32/imm.c | 55 +++++++++++++++++++++++++------------------------------
1 file changed, 25 insertions(+), 30 deletions(-)
diff --git a/dlls/imm32/imm.c b/dlls/imm32/imm.c
index 89541612ea2..bfbf3b2ad78 100644
--- a/dlls/imm32/imm.c
+++ b/dlls/imm32/imm.c
@@ -806,7 +806,7 @@ BOOL WINAPI ImmConfigureIMEW(
return FALSE;
}
-static InputContextData *alloc_input_context_data(void)
+static InputContextData *create_input_context(HIMC default_imc)
{
InputContextData *new_context;
LPGUIDELINE gl;
@@ -816,6 +816,7 @@ static InputContextData *alloc_input_context_data(void)
new_context = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(InputContextData));
/* Load the IME */
+ new_context->threadDefault = !!default_imc;
new_context->immKbd = IMM_GetImmHkl(GetKeyboardLayout(0));
if (!new_context->immKbd->hIME)
@@ -848,6 +849,27 @@ static InputContextData *alloc_input_context_data(void)
new_context->IMC.fdwConversion = new_context->immKbd->imeInfo.fdwConversionCaps;
new_context->IMC.fdwSentence = new_context->immKbd->imeInfo.fdwSentenceCaps;
+ if (!default_imc)
+ new_context->handle = NtUserCreateInputContext((UINT_PTR)new_context);
+ else if (NtUserUpdateInputContext(default_imc, NtUserInputContextClientPtr, (UINT_PTR)new_context))
+ new_context->handle = default_imc;
+ if (!new_context->handle)
+ {
+ free_input_context_data(new_context);
+ return 0;
+ }
+
+ if (!new_context->immKbd->pImeSelect(new_context->handle, TRUE))
+ {
+ TRACE("Selection of IME failed\n");
+ IMM_DestroyContext(new_context);
+ return 0;
+ }
+ new_context->threadID = GetCurrentThreadId();
+ SendMessageW(GetFocus(), WM_IME_SELECT, TRUE, (LPARAM)new_context->immKbd);
+
+ new_context->immKbd->uSelected++;
+ TRACE("Created context %p\n", new_context);
return new_context;
}
@@ -856,16 +878,7 @@ static InputContextData* get_imc_data(HIMC handle)
InputContextData *ret;
if ((ret = query_imc_data(handle)) || !handle) return ret;
- if (!(ret = alloc_input_context_data())) return NULL;
- ret->threadID = NtUserQueryInputContext(handle, NtUserInputContextThreadId);
- ret->handle = handle;
- ret->threadDefault = TRUE;
- if (!NtUserUpdateInputContext(handle, NtUserInputContextClientPtr, (UINT_PTR)ret))
- {
- free_input_context_data(ret);
- return NULL;
- }
- return ret;
+ return create_input_context(handle);
}
/***********************************************************************
@@ -875,25 +888,7 @@ HIMC WINAPI ImmCreateContext(void)
{
InputContextData *new_context;
- if (!(new_context = alloc_input_context_data())) return 0;
- if (!(new_context->handle = NtUserCreateInputContext((UINT_PTR)new_context)))
- {
- free_input_context_data(new_context);
- return 0;
- }
-
- if (!new_context->immKbd->pImeSelect(new_context->handle, TRUE))
- {
- TRACE("Selection of IME failed\n");
- IMM_DestroyContext(new_context);
- return 0;
- }
- new_context->threadID = GetCurrentThreadId();
- SendMessageW(GetFocus(), WM_IME_SELECT, TRUE, (LPARAM)new_context->immKbd);
-
- new_context->immKbd->uSelected++;
- TRACE("Created context %p\n",new_context);
-
+ if (!(new_context = create_input_context(0))) return 0;
return new_context->handle;
}
More information about the wine-cvs
mailing list