[IMM32] Implement ImmWINNLSEnableIME (#4599)
authorKatayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
Tue, 9 Aug 2022 11:09:23 +0000 (20:09 +0900)
committerGitHub <noreply@github.com>
Tue, 9 Aug 2022 11:09:23 +0000 (20:09 +0900)
- Implement imm32!ImmWINNLSEnableIME function.
- Rename CLIENTIMC_UNKNOWN3 flag as CLIENTIMC_DISABLEIME.
- Modify imm32.spec.
CORE-11700

dll/win32/imm32/ime.c
dll/win32/imm32/imm.c
dll/win32/imm32/imm32.spec
win32ss/include/ntuser.h

index 30fc0af..79c4043 100644 (file)
@@ -1993,3 +1993,57 @@ ImmGetImeMenuItemsW(HIMC hIMC, DWORD dwFlags, DWORD dwType,
           hIMC, dwFlags, dwType, lpImeParentMenu, lpImeMenu, dwSize);
     return ImmGetImeMenuItemsAW(hIMC, dwFlags, dwType, lpImeParentMenu, lpImeMenu, dwSize, FALSE);
 }
+
+/***********************************************************************
+ *             ImmWINNLSEnableIME (IMM32.@)
+ */
+BOOL WINAPI ImmWINNLSEnableIME(HWND hWnd, BOOL enable)
+{
+    HIMC hIMC;
+    PCLIENTIMC pClientImc;
+    HWND hImeWnd;
+    BOOL bImeWnd, ret;
+
+    TRACE("(%p, %d)\n", hWnd, enable);
+
+    if (!Imm32IsSystemJapaneseOrKorean())
+    {
+        SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+        return FALSE;
+    }
+
+    hIMC = (HIMC)NtUserGetThreadState(THREADSTATE_DEFAULTINPUTCONTEXT);
+    if (!hIMC)
+        return FALSE;
+
+    pClientImc = ImmLockClientImc(hIMC);
+    if (!pClientImc)
+        return FALSE;
+
+    ret = !(pClientImc->dwFlags & CLIENTIMC_DISABLEIME);
+    if (!!enable == ret)
+    {
+        ImmUnlockClientImc(pClientImc);
+        return ret;
+    }
+
+    if (!IsWindow(hWnd))
+        hWnd = GetFocus();
+
+    hImeWnd = ImmGetDefaultIMEWnd(hWnd);
+    bImeWnd = IsWindow(hImeWnd);
+    if (bImeWnd)
+        ImmSetActiveContext(hWnd, (enable ? NULL : hIMC), FALSE);
+
+    if (enable)
+        pClientImc->dwFlags &= ~CLIENTIMC_DISABLEIME;
+    else
+        pClientImc->dwFlags |= CLIENTIMC_DISABLEIME;
+
+    ImmUnlockClientImc(pClientImc);
+
+    if (bImeWnd)
+        ImmSetActiveContext(hWnd, (enable ? hIMC : NULL), TRUE);
+
+    return ret;
+}
index c4cb95a..94a1afc 100644 (file)
@@ -998,7 +998,7 @@ Quit:
     pClientImc = ImmLockClientImc(hIMC);
     if (pClientImc == NULL)
         return NULL;
-    if ((dwContextFlags & 2) && (pClientImc->dwFlags & CLIENTIMC_UNKNOWN3))
+    if ((dwContextFlags & 2) && (pClientImc->dwFlags & CLIENTIMC_DISABLEIME))
         hIMC = NULL;
     ImmUnlockClientImc(pClientImc);
     return hIMC;
index 0764e8d..78316f2 100644 (file)
 @ stdcall ImmUnlockImeDpi(ptr)
 @ stdcall ImmUnregisterWordA(long str long str)
 @ stdcall ImmUnregisterWordW(long wstr long wstr)
-@ stdcall -stub ImmWINNLSEnableIME(ptr long)
+@ stdcall ImmWINNLSEnableIME(ptr long)
 @ stdcall ImmWINNLSGetEnableStatus(ptr)
 @ stdcall ImmWINNLSGetIMEHotkey(ptr)
index 531d833..924a0be 100644 (file)
@@ -1326,7 +1326,7 @@ C_ASSERT(sizeof(CLIENTIMC) == 0x34);
 #define CLIENTIMC_UNKNOWN5 0x2
 #define CLIENTIMC_UNKNOWN4 0x20
 #define CLIENTIMC_DESTROY 0x40
-#define CLIENTIMC_UNKNOWN3 0x80
+#define CLIENTIMC_DISABLEIME 0x80
 #define CLIENTIMC_UNKNOWN2 0x100
 
 DWORD