Skip to content

Commit 97847f2

Browse files
authored
[IMM32] Improve ImmGetImeInfoEx (reactos#3833)
- Rewrite ImmGetImeInfoEx function. - Implement CtfImmIsTextFrameServiceDisabled function. - Modify imm32.spec. CORE-11700
1 parent 5afc324 commit 97847f2

File tree

3 files changed

+50
-9
lines changed

3 files changed

+50
-9
lines changed

dll/win32/imm32/imm.c

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include <ndk/pstypes.h>
4040
#include <ndk/rtlfuncs.h>
4141
#include "../../../win32ss/include/ntuser.h"
42+
#include "../../../win32ss/include/ntwin32.h"
4243
#include <imm32_undoc.h>
4344
#include <strsafe.h>
4445

@@ -3608,29 +3609,67 @@ BOOL WINAPI ImmRegisterClient(PVOID ptr, /* FIXME: should point to SHAREDINFO st
36083609
return TRUE;
36093610
}
36103611

3612+
/***********************************************************************
3613+
* CtfImmIsTextFrameServiceDisabled(IMM32.@)
3614+
*/
3615+
BOOL WINAPI CtfImmIsTextFrameServiceDisabled(VOID)
3616+
{
3617+
PTEB pTeb = NtCurrentTeb();
3618+
if (((PW32CLIENTINFO)pTeb->Win32ClientInfo)->CI_flags & CI_TFSDISABLED)
3619+
return TRUE;
3620+
return FALSE;
3621+
}
3622+
36113623
/***********************************************************************
36123624
* ImmGetImeInfoEx (IMM32.@)
36133625
*/
3626+
3627+
static BOOL APIENTRY Imm32GetImeInfoEx(PIMEINFOEX pImeInfoEx, IMEINFOEXCLASS SearchType)
3628+
{
3629+
return NtUserGetImeInfoEx(pImeInfoEx, SearchType);
3630+
}
3631+
36143632
BOOL WINAPI
36153633
ImmGetImeInfoEx(PIMEINFOEX pImeInfoEx,
36163634
IMEINFOEXCLASS SearchType,
36173635
PVOID pvSearchKey)
36183636
{
3637+
BOOL bDisabled = FALSE;
3638+
HKL hKL;
3639+
PTEB pTeb;
3640+
36193641
switch (SearchType)
36203642
{
36213643
case ImeInfoExKeyboardLayout:
3622-
pImeInfoEx->hkl = *(LPHKL)pvSearchKey;
3623-
if (!IS_IME_HKL(pImeInfoEx->hkl))
3624-
return FALSE;
36253644
break;
36263645

3627-
case ImeInfoExImeFileName:
3628-
lstrcpynW(pImeInfoEx->wszImeFile, (LPWSTR)pvSearchKey,
3629-
ARRAY_SIZE(pImeInfoEx->wszImeFile));
3646+
case ImeInfoExImeWindow:
3647+
bDisabled = CtfImmIsTextFrameServiceDisabled();
3648+
SearchType = ImeInfoExKeyboardLayout;
36303649
break;
36313650

3632-
default:
3633-
return FALSE;
3651+
case ImeInfoExImeFileName:
3652+
StringCchCopyW(pImeInfoEx->wszImeFile, _countof(pImeInfoEx->wszImeFile),
3653+
pvSearchKey);
3654+
goto Quit;
36343655
}
3635-
return NtUserGetImeInfoEx(pImeInfoEx, SearchType);
3656+
3657+
hKL = *(HKL*)pvSearchKey;
3658+
pImeInfoEx->hkl = hKL;
3659+
3660+
if (!IS_IME_HKL(hKL))
3661+
{
3662+
if (g_dwImm32Flags & IMM32_FLAG_CICERO_ENABLED)
3663+
{
3664+
pTeb = NtCurrentTeb();
3665+
if (((PW32CLIENTINFO)pTeb->Win32ClientInfo)->W32ClientInfo[0] & 2)
3666+
return FALSE;
3667+
if (!bDisabled)
3668+
goto Quit;
3669+
}
3670+
return FALSE;
3671+
}
3672+
3673+
Quit:
3674+
return Imm32GetImeInfoEx(pImeInfoEx, SearchType);
36363675
}

dll/win32/imm32/imm32.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@ stdcall CtfImmIsCiceroEnabled()
2+
@ stdcall CtfImmIsTextFrameServiceDisabled()
23
@ stdcall -stub ImmActivateLayout(long)
34
@ stdcall ImmAssociateContext(ptr ptr)
45
@ stdcall ImmAssociateContextEx(ptr ptr long)

win32ss/include/ntuser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ typedef struct _CALLBACKWND
281281
#define CI_CURTHPRHOOK 0x00000010
282282
#define CI_CLASSESREGISTERED 0x00000020
283283
#define CI_IMMACTIVATE 0x00000040
284+
#define CI_TFSDISABLED 0x00000400
284285

285286
typedef struct _CLIENTINFO
286287
{

0 commit comments

Comments
 (0)