https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9adc538c9c79ef735a75f…
commit 9adc538c9c79ef735a75f76f3c02d8830fcd3cd7
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Fri Oct 1 03:02:56 2021 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Fri Oct 1 03:02:56 2021 +0900
[IMM32] Rewrite ImmSetActiveContext (#3982)
- Re-implement ImmSetActiveContext function.
- Modify NtUserNotifyIMEStatus prototype.
- Improve ImmSetConversionStatus and ImmSetOpenStatus functions.
CORE-11700
---
dll/win32/imm32/ime.c | 7 ++--
dll/win32/imm32/imm.c | 97 +++++++++++++++++++++++++++++++++++++++++++++--
win32ss/include/ntuser.h | 7 ++--
win32ss/user/ntuser/ime.c | 8 +---
4 files changed, 103 insertions(+), 16 deletions(-)
diff --git a/dll/win32/imm32/ime.c b/dll/win32/imm32/ime.c
index 3eeb7169b22..b1b31ce9eeb 100644
--- a/dll/win32/imm32/ime.c
+++ b/dll/win32/imm32/ime.c
@@ -911,7 +911,7 @@ BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen)
{
Imm32NotifyAction(hIMC, hWnd, NI_CONTEXTUPDATED, 0,
IMC_SETOPENSTATUS, IMN_SETOPENSTATUS, 0);
- NtUserNotifyIMEStatus(hWnd, hIMC, dwConversion);
+ NtUserNotifyIMEStatus(hWnd, fOpen, dwConversion);
}
return TRUE;
@@ -1346,7 +1346,7 @@ BOOL WINAPI ImmSetConversionStatus(HIMC hIMC, DWORD fdwConversion,
DWORD fdwSent
HKL hKL;
LPINPUTCONTEXT pIC;
DWORD dwOldConversion, dwOldSentence;
- BOOL fConversionChange = FALSE, fSentenceChange = FALSE, fUseCicero = FALSE;
+ BOOL fOpen = FALSE, fConversionChange = FALSE, fSentenceChange = FALSE, fUseCicero =
FALSE;
HWND hWnd;
TRACE("(%p, 0x%lX, 0x%lX)\n", hIMC, fdwConversion, fdwSentence);
@@ -1377,6 +1377,7 @@ BOOL WINAPI ImmSetConversionStatus(HIMC hIMC, DWORD fdwConversion,
DWORD fdwSent
}
hWnd = pIC->hWnd;
+ fOpen = pIC->fOpen;
ImmUnlockIMC(hIMC);
if (fConversionChange || fUseCicero)
@@ -1384,7 +1385,7 @@ BOOL WINAPI ImmSetConversionStatus(HIMC hIMC, DWORD fdwConversion,
DWORD fdwSent
Imm32NotifyAction(hIMC, hWnd, NI_CONTEXTUPDATED, dwOldConversion,
IMC_SETCONVERSIONMODE, IMN_SETCONVERSIONMODE, 0);
if (fConversionChange)
- NtUserNotifyIMEStatus(hWnd, hIMC, fdwConversion);
+ NtUserNotifyIMEStatus(hWnd, fOpen, fdwConversion);
}
if (fSentenceChange || fUseCicero)
diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c
index ab97e052c9a..07eb129bffc 100644
--- a/dll/win32/imm32/imm.c
+++ b/dll/win32/imm32/imm.c
@@ -169,6 +169,11 @@ static InputContextData* get_imc_data(HIMC hIMC)
return data;
}
+static VOID APIENTRY Imm32CiceroSetActiveContext(HIMC hIMC, BOOL fActive, HWND hWnd, HKL
hKL)
+{
+ FIXME("We have to do something\n");
+}
+
/***********************************************************************
* ImmAssociateContext (IMM32.@)
*/
@@ -1314,10 +1319,96 @@ BOOL WINAPI ImmEnumInputContext(DWORD dwThreadId, IMCENUMPROC
lpfn, LPARAM lPara
/***********************************************************************
* ImmSetActiveContext(IMM32.@)
*/
-BOOL WINAPI ImmSetActiveContext(HWND hwnd, HIMC hIMC, BOOL fFlag)
+BOOL WINAPI ImmSetActiveContext(HWND hWnd, HIMC hIMC, BOOL fActive)
{
- FIXME("(%p, %p, %d): stub\n", hwnd, hIMC, fFlag);
- return FALSE;
+ PCLIENTIMC pClientImc;
+ LPINPUTCONTEXTDX pIC;
+ PIMEDPI pImeDpi;
+ HKL hKL;
+ BOOL fOpen = FALSE;
+ DWORD dwConversion = 0, iShow = ISC_SHOWUIALL;
+ HWND hwndDefIME;
+
+ TRACE("(%p, %p, %d)\n", hWnd, hIMC, fActive);
+
+ if (!Imm32IsImmMode())
+ return FALSE;
+
+ pClientImc = ImmLockClientImc(hIMC);
+
+ if (!fActive)
+ {
+ if (pClientImc)
+ pClientImc->dwFlags &= ~CLIENTIMC_UNKNOWN4;
+ }
+ else if (hIMC)
+ {
+ if (!pClientImc)
+ return FALSE;
+
+ pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
+ if (!pIC)
+ {
+ ImmUnlockClientImc(pClientImc);
+ return FALSE;
+ }
+
+ pIC->hWnd = hWnd;
+ pClientImc->dwFlags |= CLIENTIMC_UNKNOWN5;
+
+ if (pIC->dwUIFlags & 2)
+ iShow = (ISC_SHOWUIGUIDELINE | ISC_SHOWUIALLCANDIDATEWINDOW);
+
+ fOpen = pIC->fOpen;
+ dwConversion = pIC->fdwConversion;
+
+ ImmUnlockIMC(hIMC);
+ }
+ else
+ {
+ hIMC = Imm32GetContextEx(hWnd, TRUE);
+ pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
+ if (pIC)
+ {
+ pIC->hWnd = hWnd;
+ ImmUnlockIMC(hIMC);
+ }
+ hIMC = NULL;
+ }
+
+ hKL = GetKeyboardLayout(0);
+
+ if (Imm32IsCiceroMode() && !Imm32Is16BitMode())
+ {
+ Imm32CiceroSetActiveContext(hIMC, fActive, hWnd, hKL);
+ hKL = GetKeyboardLayout(0);
+ }
+
+ pImeDpi = ImmLockImeDpi(hKL);
+ if (pImeDpi)
+ {
+ if (IS_IME_HKL(hKL))
+ pImeDpi->ImeSetActiveContext(hIMC, fActive);
+ ImmUnlockImeDpi(pImeDpi);
+ }
+
+ if (IsWindow(hWnd))
+ {
+ SendMessageW(hWnd, WM_IME_SETCONTEXT, fActive, iShow);
+ if (fActive)
+ NtUserNotifyIMEStatus(hWnd, fOpen, dwConversion);
+ }
+ else if (!fActive)
+ {
+ hwndDefIME = ImmGetDefaultIMEWnd(NULL);
+ if (hwndDefIME)
+ SendMessageW(hwndDefIME, WM_IME_SETCONTEXT, 0, iShow);
+ }
+
+ if (pClientImc)
+ ImmUnlockClientImc(pClientImc);
+
+ return TRUE;
}
/***********************************************************************
diff --git a/win32ss/include/ntuser.h b/win32ss/include/ntuser.h
index 7afe6906fba..a6a45af167b 100644
--- a/win32ss/include/ntuser.h
+++ b/win32ss/include/ntuser.h
@@ -1312,6 +1312,8 @@ C_ASSERT(sizeof(CLIENTIMC) == 0x34);
/* flags for CLIENTIMC */
#define CLIENTIMC_WIDE 0x1
+#define CLIENTIMC_UNKNOWN5 0x2
+#define CLIENTIMC_UNKNOWN4 0x20
#define CLIENTIMC_UNKNOWN1 0x40
#define CLIENTIMC_UNKNOWN3 0x80
#define CLIENTIMC_UNKNOWN2 0x100
@@ -2769,10 +2771,7 @@ NtUserMoveWindow(
DWORD
NTAPI
-NtUserNotifyIMEStatus(
- HWND hwnd,
- HIMC hIMC,
- DWORD dwConversion);
+NtUserNotifyIMEStatus(HWND hwnd, BOOL fOpen, DWORD dwConversion);
BOOL
NTAPI
diff --git a/win32ss/user/ntuser/ime.c b/win32ss/user/ntuser/ime.c
index 031dc09ec64..1d84609186c 100644
--- a/win32ss/user/ntuser/ime.c
+++ b/win32ss/user/ntuser/ime.c
@@ -49,16 +49,12 @@ NtUserGetImeHotKey(IN DWORD dwHotKey,
DWORD
APIENTRY
-NtUserNotifyIMEStatus(
- HWND hwnd,
- HIMC hIMC,
- DWORD dwConversion)
+NtUserNotifyIMEStatus(HWND hwnd, BOOL fOpen, DWORD dwConversion)
{
- TRACE("NtUserNotifyIMEStatus(%p, %p, 0x%lX)\n", hwnd, hIMC, dwConversion);
+ TRACE("NtUserNotifyIMEStatus(%p, %d, 0x%lX)\n", hwnd, fOpen,
dwConversion);
return 0;
}
-
DWORD
APIENTRY
NtUserSetImeHotKey(