ReactOS  0.4.15-dev-5492-g47f3a4e
keymsg.c File Reference
#include "precomp.h"
Include dependency graph for keymsg.c:

Go to the source code of this file.

Classes

struct  IMM_DELAY_SET_LANG_BAND
 

Macros

#define MSG_COUNT   0x100
 

Typedefs

typedef struct IMM_DELAY_SET_LANG_BAND IMM_DELAY_SET_LANG_BAND
 
typedef struct IMM_DELAY_SET_LANG_BANDPIMM_DELAY_SET_LANG_BAND
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (imm)
 
BOOL APIENTRY Imm32ImeNonImeToggle (HIMC hIMC, HKL hKL, HWND hWnd, BOOL bNowIME, LANGID LangID)
 
BOOL APIENTRY Imm32CImeNonImeToggle (HIMC hIMC, HKL hKL, HWND hWnd, LANGID LangID)
 
BOOL APIENTRY Imm32CShapeToggle (HIMC hIMC, HKL hKL, HWND hWnd)
 
BOOL APIENTRY Imm32CSymbolToggle (HIMC hIMC, HKL hKL, HWND hWnd)
 
BOOL APIENTRY Imm32JCloseOpen (HIMC hIMC, HKL hKL, HWND hWnd)
 
BOOL APIENTRY Imm32KShapeToggle (HIMC hIMC)
 
BOOL APIENTRY Imm32KHanjaConvert (HIMC hIMC)
 
BOOL APIENTRY Imm32KEnglish (HIMC hIMC)
 
BOOL APIENTRY Imm32ProcessHotKey (HWND hWnd, HIMC hIMC, HKL hKL, DWORD dwHotKeyID)
 
static BOOL APIENTRY ImmIsUIMessageAW (HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam, BOOL bAnsi)
 
static DWORD APIENTRY Imm32DelaySetLangBandProc (LPVOID arg)
 
LRESULT APIENTRY CtfImmSetLangBand (HWND hWnd, BOOL fSet)
 
static BOOL CALLBACK Imm32SendNotificationProc (HIMC hIMC, LPARAM lParam)
 
BOOL APIENTRY Imm32SendNotification (BOOL bProcess)
 
LRESULT APIENTRY Imm32ProcessRequest (HIMC hIMC, PWND pWnd, DWORD dwCommand, LPVOID pData, BOOL bAnsiAPI)
 
LRESULT APIENTRY ImmRequestMessageAW (HIMC hIMC, WPARAM wParam, LPARAM lParam, BOOL bAnsi)
 
BOOL WINAPI ImmIsUIMessageA (HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam)
 
BOOL WINAPI ImmIsUIMessageW (HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam)
 
BOOL WINAPI ImmGetHotKey (IN DWORD dwHotKey, OUT LPUINT lpuModifiers, OUT LPUINT lpuVKey, OUT LPHKL lphKL)
 
UINT WINAPI ImmWINNLSGetIMEHotkey (HWND hwndIme)
 
BOOL WINAPI ImmSimulateHotKey (HWND hWnd, DWORD dwHotKeyID)
 
UINT WINAPI ImmGetVirtualKey (HWND hWnd)
 
DWORD WINAPI ImmGetAppCompatFlags (HIMC hIMC)
 
DWORD WINAPI ImmProcessKey (HWND hWnd, HKL hKL, UINT vKey, LPARAM lParam, DWORD dwHotKeyID)
 
LRESULT WINAPI ImmSystemHandler (HIMC hIMC, WPARAM wParam, LPARAM lParam)
 
BOOL WINAPI ImmGenerateMessage (HIMC hIMC)
 
VOID APIENTRY ImmPostMessages (HWND hwnd, HIMC hIMC, DWORD dwCount, LPTRANSMSG lpTransMsg)
 
BOOL WINAPI ImmTranslateMessage (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lKeyData)
 
LRESULT WINAPI ImmRequestMessageA (HIMC hIMC, WPARAM wParam, LPARAM lParam)
 
LRESULT WINAPI ImmRequestMessageW (HIMC hIMC, WPARAM wParam, LPARAM lParam)
 
LRESULT WINAPI ImmSendMessageToActiveDefImeWndW (UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Macro Definition Documentation

◆ MSG_COUNT

#define MSG_COUNT   0x100

Typedef Documentation

◆ IMM_DELAY_SET_LANG_BAND

◆ PIMM_DELAY_SET_LANG_BAND

Function Documentation

◆ CtfImmSetLangBand()

LRESULT APIENTRY CtfImmSetLangBand ( HWND  hWnd,
BOOL  fSet 
)

Definition at line 363 of file keymsg.c.

364 {
365  HANDLE hThread;
366  PWND pWnd = NULL;
367  PIMM_DELAY_SET_LANG_BAND pSetBand;
368  DWORD_PTR lResult = 0;
369 
370  if (hWnd && gpsi)
371  pWnd = ValidateHwndNoErr(hWnd);
372 
373  if (IS_NULL_UNEXPECTEDLY(pWnd))
374  return 0;
375 
377  {
379  5000, &lResult);
380  return lResult;
381  }
382 
383  pSetBand = ImmLocalAlloc(0, sizeof(IMM_DELAY_SET_LANG_BAND));
384  if (IS_NULL_UNEXPECTEDLY(pSetBand))
385  return 0;
386 
387  pSetBand->hWnd = hWnd;
388  pSetBand->fSet = fSet;
389 
391  if (hThread)
393  return 0;
394 }
#define CloseHandle
Definition: compat.h:739
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:415
PSERVERINFO gpsi
Definition: imm.c:18
HWND hWnd
Definition: settings.c:17
#define SMTO_ABORTIFHUNG
Definition: winuser.h:1213
static DWORD APIENTRY Imm32DelaySetLangBandProc(LPVOID arg)
Definition: keymsg.c:341
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:84
#define WNDS2_WMCREATEMSGPROCESSED
Definition: ntuser.h:665
#define IS_NULL_UNEXPECTEDLY(p)
Definition: precomp.h:120
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define WM_USER
Definition: winuser.h:1885
Definition: ntuser.h:688
#define NULL
Definition: types.h:112
HANDLE hThread
Definition: wizard.c:28
LRESULT WINAPI SendMessageTimeoutW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM, _In_ UINT, _In_ UINT, _Out_opt_ PDWORD_PTR)
DWORD state2
Definition: ntuser.h:697
#define SMTO_BLOCK
Definition: winuser.h:1214

Referenced by ImmSystemHandler().

◆ Imm32CImeNonImeToggle()

BOOL APIENTRY Imm32CImeNonImeToggle ( HIMC  hIMC,
HKL  hKL,
HWND  hWnd,
LANGID  LangID 
)

Definition at line 67 of file keymsg.c.

68 {
69  LPINPUTCONTEXT pIC;
70  BOOL fOpen;
71 
73  return FALSE;
74 
75  if (LOWORD(hKL) != LangID || !ImmIsIME(hKL))
76  {
77  Imm32ImeNonImeToggle(hIMC, hKL, hWnd, FALSE, LangID);
78  return TRUE;
79  }
80 
81  pIC = ImmLockIMC(hIMC);
82  if (IS_NULL_UNEXPECTEDLY(pIC))
83  return TRUE;
84 
85  fOpen = pIC->fOpen;
86  ImmUnlockIMC(hIMC);
87 
88  if (fOpen)
89  Imm32ImeNonImeToggle(hIMC, hKL, hWnd, TRUE, 0);
90  else
91  ImmSetOpenStatus(hIMC, TRUE);
92 
93  return TRUE;
94 }
#define TRUE
Definition: types.h:120
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1070
HWND hWnd
Definition: settings.c:17
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen)
Definition: ime.c:1475
#define IS_NULL_UNEXPECTEDLY(p)
Definition: precomp.h:120
BOOL WINAPI ImmIsIME(HKL hKL)
Definition: ime.c:880
BOOL APIENTRY Imm32ImeNonImeToggle(HIMC hIMC, HKL hKL, HWND hWnd, BOOL bNowIME, LANGID LangID)
Definition: keymsg.c:17
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
Definition: wdfusb.h:1075
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1079
#define LOWORD(l)
Definition: pedump.c:82

Referenced by Imm32ProcessHotKey().

◆ Imm32CShapeToggle()

BOOL APIENTRY Imm32CShapeToggle ( HIMC  hIMC,
HKL  hKL,
HWND  hWnd 
)

Definition at line 98 of file keymsg.c.

99 {
100  LPINPUTCONTEXT pIC;
101  BOOL fOpen;
102  DWORD dwConversion, dwSentence;
103 
104  if (hWnd == NULL || !ImmIsIME(hKL))
105  return FALSE;
106 
107  pIC = ImmLockIMC(hIMC);
108  if (IS_NULL_UNEXPECTEDLY(pIC))
109  return TRUE;
110 
111  fOpen = pIC->fOpen;
112  if (fOpen)
113  {
114  dwConversion = (pIC->fdwConversion ^ IME_CMODE_FULLSHAPE);
115  dwSentence = pIC->fdwSentence;
116  }
117 
118  ImmUnlockIMC(hIMC);
119 
120  if (fOpen)
121  ImmSetConversionStatus(hIMC, dwConversion, dwSentence);
122  else
123  ImmSetOpenStatus(hIMC, TRUE);
124 
125  return TRUE;
126 }
#define TRUE
Definition: types.h:120
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1070
HWND hWnd
Definition: settings.c:17
DWORD fdwConversion
Definition: immdev.h:60
BOOL WINAPI ImmSetConversionStatus(HIMC hIMC, DWORD fdwConversion, DWORD fdwSentence)
Definition: ime.c:1950
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen)
Definition: ime.c:1475
#define IME_CMODE_FULLSHAPE
Definition: imm.h:493
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IS_NULL_UNEXPECTEDLY(p)
Definition: precomp.h:120
BOOL WINAPI ImmIsIME(HKL hKL)
Definition: ime.c:880
#define NULL
Definition: types.h:112
DWORD fdwSentence
Definition: immdev.h:61
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1079

Referenced by Imm32ProcessHotKey().

◆ Imm32CSymbolToggle()

BOOL APIENTRY Imm32CSymbolToggle ( HIMC  hIMC,
HKL  hKL,
HWND  hWnd 
)

Definition at line 129 of file keymsg.c.

130 {
131  LPINPUTCONTEXT pIC;
132  BOOL fOpen;
133  DWORD dwConversion, dwSentence;
134 
135  if (hWnd == NULL || !ImmIsIME(hKL))
136  return FALSE;
137 
138  pIC = ImmLockIMC(hIMC);
139  if (IS_NULL_UNEXPECTEDLY(pIC))
140  return TRUE;
141 
142  fOpen = pIC->fOpen;
143  if (fOpen)
144  {
145  dwConversion = (pIC->fdwConversion ^ IME_CMODE_SYMBOL);
146  dwSentence = pIC->fdwSentence;
147  }
148 
149  ImmUnlockIMC(hIMC);
150 
151  if (fOpen)
152  ImmSetConversionStatus(hIMC, dwConversion, dwSentence);
153  else
154  ImmSetOpenStatus(hIMC, TRUE);
155 
156  return TRUE;
157 }
#define IME_CMODE_SYMBOL
Definition: imm.h:500
#define TRUE
Definition: types.h:120
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1070
HWND hWnd
Definition: settings.c:17
DWORD fdwConversion
Definition: immdev.h:60
BOOL WINAPI ImmSetConversionStatus(HIMC hIMC, DWORD fdwConversion, DWORD fdwSentence)
Definition: ime.c:1950
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen)
Definition: ime.c:1475
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IS_NULL_UNEXPECTEDLY(p)
Definition: precomp.h:120
BOOL WINAPI ImmIsIME(HKL hKL)
Definition: ime.c:880
#define NULL
Definition: types.h:112
DWORD fdwSentence
Definition: immdev.h:61
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1079

Referenced by Imm32ProcessHotKey().

◆ Imm32DelaySetLangBandProc()

static DWORD APIENTRY Imm32DelaySetLangBandProc ( LPVOID  arg)
static

Definition at line 341 of file keymsg.c.

342 {
343  HWND hwndDefIME;
344  WPARAM wParam;
345  DWORD_PTR lResult;
346  PIMM_DELAY_SET_LANG_BAND pSetBand = arg;
347 
348  Sleep(3000); /* Delay 3 seconds! */
349 
350  hwndDefIME = ImmGetDefaultIMEWnd(pSetBand->hWnd);
351  if (hwndDefIME)
352  {
353  wParam = (pSetBand->fSet ? IMS_SETLANGBAND : IMS_UNSETLANGBAND);
354  SendMessageTimeoutW(hwndDefIME, WM_IME_SYSTEM, wParam, (LPARAM)pSetBand->hWnd,
355  SMTO_BLOCK | SMTO_ABORTIFHUNG, 5000, &lResult);
356  }
357  ImmLocalFree(pSetBand);
358  return FALSE;
359 }
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
void * arg
Definition: msvc.h:10
#define IMS_SETLANGBAND
Definition: immdev.h:46
UINT_PTR WPARAM
Definition: windef.h:207
WPARAM wParam
Definition: combotst.c:138
#define SMTO_ABORTIFHUNG
Definition: winuser.h:1213
#define FALSE
Definition: types.h:117
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_IME_SYSTEM
Definition: undocuser.h:60
#define ImmLocalFree(lpData)
Definition: precomp.h:89
uint32_t DWORD_PTR
Definition: typedefs.h:65
HWND WINAPI ImmGetDefaultIMEWnd(HWND hWnd)
Definition: ime.c:890
LRESULT WINAPI SendMessageTimeoutW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM, _In_ UINT, _In_ UINT, _Out_opt_ PDWORD_PTR)
#define IMS_UNSETLANGBAND
Definition: immdev.h:47
#define SMTO_BLOCK
Definition: winuser.h:1214

Referenced by CtfImmSetLangBand().

◆ Imm32ImeNonImeToggle()

BOOL APIENTRY Imm32ImeNonImeToggle ( HIMC  hIMC,
HKL  hKL,
HWND  hWnd,
BOOL  bNowIME,
LANGID  LangID 
)

Definition at line 17 of file keymsg.c.

18 {
19  HKL hOldKL, LayoutList[32], hFoundKL = NULL;
20  UINT iLayout, nLayoutCount;
21 
22  /* Get the previous layout */
24 
25  /* Get the layout list */
26  nLayoutCount = GetKeyboardLayoutList(_countof(LayoutList), LayoutList);
27 
28  /* Is there hOldKL in the list in the specified language ID? */
29  if (hOldKL && (LangID == 0 || LOWORD(hOldKL) == LangID))
30  {
31  for (iLayout = 0; iLayout < nLayoutCount; ++iLayout)
32  {
33  if (LayoutList[iLayout] == hOldKL)
34  {
35  hFoundKL = hOldKL;
36  break;
37  }
38  }
39  }
40 
41  if (hFoundKL == NULL) /* Not found? */
42  {
43  /* Is there the keyboard layout of another kind in LangID? */
44  for (iLayout = 0; iLayout < nLayoutCount; ++iLayout)
45  {
46  if (bNowIME == ImmIsIME(LayoutList[iLayout])) /* Same kind? */
47  continue;
48 
49  if (LangID == 0 || LangID == LOWORD(LayoutList[iLayout]))
50  {
51  hFoundKL = LayoutList[iLayout];
52  break;
53  }
54  }
55  }
56 
57  if (hFoundKL && hKL != hFoundKL) /* Found and different layout */
58  {
59  PostMessageW(hWnd, WM_INPUTLANGCHANGEREQUEST, 1, (LPARAM)hFoundKL);
60  }
61 
62  return ImmIsIME(hFoundKL);
63 }
DWORD_PTR NTAPI NtUserGetThreadState(DWORD Routine)
Definition: misc.c:232
HWND hWnd
Definition: settings.c:17
LONG_PTR LPARAM
Definition: windef.h:208
UINT WINAPI GetKeyboardLayoutList(_In_ int nBuff, _Out_writes_to_opt_(nBuff, return) HKL FAR *lpList)
#define _countof(array)
Definition: sndvol32.h:68
UINT_PTR HKL
Definition: msctf.idl:101
BOOL WINAPI ImmIsIME(HKL hKL)
Definition: ime.c:880
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
Definition: wdfusb.h:1075
#define LOWORD(l)
Definition: pedump.c:82

Referenced by Imm32CImeNonImeToggle(), and Imm32JCloseOpen().

◆ Imm32JCloseOpen()

BOOL APIENTRY Imm32JCloseOpen ( HIMC  hIMC,
HKL  hKL,
HWND  hWnd 
)

Definition at line 161 of file keymsg.c.

162 {
163  BOOL fOpen;
164  LPINPUTCONTEXTDX pIC;
165 
166  if (LOWORD(hKL) == LANGID_JAPANESE && ImmIsIME(hKL)) /* Japanese IME is selected */
167  {
168  fOpen = ImmGetOpenStatus(hIMC);
169  ImmSetOpenStatus(hIMC, !fOpen);
170  return TRUE;
171  }
172 
173  /* Japanese IME is not selected. Select now */
175  {
176  pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
177  if (pIC)
178  {
179  pIC->dwChange |= INPUTCONTEXTDX_CHANGE_OPEN; /* Notify open change */
180  ImmUnlockIMC(hIMC);
181  }
182  }
183 
184  return TRUE;
185 }
#define LANGID_JAPANESE
Definition: precomp.h:58
BOOL WINAPI ImmGetOpenStatus(HIMC hIMC)
Definition: ime.c:1452
#define TRUE
Definition: types.h:120
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1070
HWND hWnd
Definition: settings.c:17
#define INPUTCONTEXTDX_CHANGE_OPEN
Definition: immdev.h:157
DWORD dwChange
Definition: immdev.h:135
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen)
Definition: ime.c:1475
struct INPUTCONTEXTDX * LPINPUTCONTEXTDX
BOOL WINAPI ImmIsIME(HKL hKL)
Definition: ime.c:880
BOOL APIENTRY Imm32ImeNonImeToggle(HIMC hIMC, HKL hKL, HWND hWnd, BOOL bNowIME, LANGID LangID)
Definition: keymsg.c:17
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1079
#define LOWORD(l)
Definition: pedump.c:82

Referenced by Imm32ProcessHotKey().

◆ Imm32KEnglish()

BOOL APIENTRY Imm32KEnglish ( HIMC  hIMC)

Definition at line 229 of file keymsg.c.

230 {
231  LPINPUTCONTEXT pIC;
232  DWORD dwConversion, dwSentence;
233  BOOL fOpen;
234 
235  pIC = ImmLockIMC(hIMC);
236  if (IS_NULL_UNEXPECTEDLY(pIC))
237  return FALSE;
238 
239  dwConversion = (pIC->fdwConversion ^ IME_CMODE_NATIVE);
240  dwSentence = pIC->fdwSentence;
241  ImmSetConversionStatus(hIMC, dwConversion, dwSentence);
242 
243  fOpen = ((pIC->fdwConversion & (IME_CMODE_FULLSHAPE | IME_CMODE_NATIVE)) != 0);
244  ImmSetOpenStatus(hIMC, fOpen);
245 
246  ImmUnlockIMC(hIMC);
247  return TRUE;
248 }
#define TRUE
Definition: types.h:120
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1070
DWORD fdwConversion
Definition: immdev.h:60
BOOL WINAPI ImmSetConversionStatus(HIMC hIMC, DWORD fdwConversion, DWORD fdwSentence)
Definition: ime.c:1950
#define FALSE
Definition: types.h:117
#define IME_CMODE_NATIVE
Definition: imm.h:485
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen)
Definition: ime.c:1475
#define IME_CMODE_FULLSHAPE
Definition: imm.h:493
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IS_NULL_UNEXPECTEDLY(p)
Definition: precomp.h:120
DWORD fdwSentence
Definition: immdev.h:61
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1079

Referenced by Imm32ProcessHotKey().

◆ Imm32KHanjaConvert()

BOOL APIENTRY Imm32KHanjaConvert ( HIMC  hIMC)

Definition at line 211 of file keymsg.c.

212 {
213  LPINPUTCONTEXT pIC;
214  DWORD dwConversion, dwSentence;
215 
216  pIC = ImmLockIMC(hIMC);
217  if (IS_NULL_UNEXPECTEDLY(pIC))
218  return FALSE;
219 
220  dwConversion = (pIC->fdwConversion ^ IME_CMODE_HANJACONVERT);
221  dwSentence = pIC->fdwSentence;
222  ImmUnlockIMC(hIMC);
223 
224  ImmSetConversionStatus(hIMC, dwConversion, dwSentence);
225  return TRUE;
226 }
#define TRUE
Definition: types.h:120
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1070
DWORD fdwConversion
Definition: immdev.h:60
BOOL WINAPI ImmSetConversionStatus(HIMC hIMC, DWORD fdwConversion, DWORD fdwSentence)
Definition: ime.c:1950
#define FALSE
Definition: types.h:117
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IS_NULL_UNEXPECTEDLY(p)
Definition: precomp.h:120
#define IME_CMODE_HANJACONVERT
Definition: imm.h:496
DWORD fdwSentence
Definition: immdev.h:61
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1079

Referenced by Imm32ProcessHotKey().

◆ Imm32KShapeToggle()

BOOL APIENTRY Imm32KShapeToggle ( HIMC  hIMC)

Definition at line 188 of file keymsg.c.

189 {
190  LPINPUTCONTEXT pIC;
191  DWORD dwConversion, dwSentence;
192 
193  pIC = ImmLockIMC(hIMC);
194  if (IS_NULL_UNEXPECTEDLY(pIC))
195  return FALSE;
196 
197  dwConversion = (pIC->fdwConversion ^ IME_CMODE_FULLSHAPE);
198  dwSentence = pIC->fdwSentence;
199  ImmSetConversionStatus(hIMC, dwConversion, dwSentence);
200 
202  ImmSetOpenStatus(hIMC, TRUE);
203  else
204  ImmSetOpenStatus(hIMC, FALSE);
205 
206  ImmUnlockIMC(hIMC);
207  return TRUE;
208 }
#define TRUE
Definition: types.h:120
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1070
DWORD fdwConversion
Definition: immdev.h:60
BOOL WINAPI ImmSetConversionStatus(HIMC hIMC, DWORD fdwConversion, DWORD fdwSentence)
Definition: ime.c:1950
#define FALSE
Definition: types.h:117
#define IME_CMODE_NATIVE
Definition: imm.h:485
BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen)
Definition: ime.c:1475
#define IME_CMODE_FULLSHAPE
Definition: imm.h:493
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IS_NULL_UNEXPECTEDLY(p)
Definition: precomp.h:120
DWORD fdwSentence
Definition: immdev.h:61
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1079

Referenced by Imm32ProcessHotKey().

◆ Imm32ProcessHotKey()

BOOL APIENTRY Imm32ProcessHotKey ( HWND  hWnd,
HIMC  hIMC,
HKL  hKL,
DWORD  dwHotKeyID 
)

Definition at line 251 of file keymsg.c.

252 {
253  PIMEDPI pImeDpi;
254  BOOL ret;
255 
256  if (hIMC && IS_CROSS_THREAD_HIMC(hIMC))
257  return FALSE;
258 
259  switch (dwHotKeyID)
260  {
263 
265  return Imm32CShapeToggle(hIMC, hKL, hWnd);
266 
268  return Imm32CSymbolToggle(hIMC, hKL, hWnd);
269 
271  return Imm32JCloseOpen(hIMC, hKL, hWnd);
272 
274  return Imm32KShapeToggle(hIMC);
275 
277  return Imm32KHanjaConvert(hIMC);
278 
279  case IME_KHOTKEY_ENGLISH:
280  return Imm32KEnglish(hIMC);
281 
284 
286  return Imm32CShapeToggle(hIMC, hKL, hWnd);
287 
289  return Imm32CSymbolToggle(hIMC, hKL, hWnd);
290 
291  default:
292  WARN("0x%X\n", dwHotKeyID);
293  break;
294  }
295 
296  if (dwHotKeyID < IME_HOTKEY_PRIVATE_FIRST || IME_HOTKEY_PRIVATE_LAST < dwHotKeyID)
297  return FALSE;
298 
299  pImeDpi = ImmLockImeDpi(hKL);
300  if (IS_NULL_UNEXPECTEDLY(pImeDpi))
301  return FALSE;
302 
303  ret = (BOOL)pImeDpi->ImeEscape(hIMC, IME_ESC_PRIVATE_HOTKEY, &dwHotKeyID);
304  ImmUnlockImeDpi(pImeDpi);
305  return ret;
306 }
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:1016
#define IME_CHOTKEY_IME_NONIME_TOGGLE
Definition: imm.h:331
#define LANGID_CHINESE_SIMPLIFIED
Definition: precomp.h:56
#define IS_CROSS_THREAD_HIMC(hIMC)
Definition: precomp.h:143
#define IME_THOTKEY_SHAPE_TOGGLE
Definition: imm.h:344
#define IME_JHOTKEY_CLOSE_OPEN
Definition: imm.h:336
#define IME_KHOTKEY_SHAPE_TOGGLE
Definition: imm.h:339
BOOL APIENTRY Imm32KEnglish(HIMC hIMC)
Definition: keymsg.c:229
#define WARN(fmt,...)
Definition: debug.h:112
#define LANGID_CHINESE_TRADITIONAL
Definition: precomp.h:57
HWND hWnd
Definition: settings.c:17
BOOL APIENTRY Imm32CShapeToggle(HIMC hIMC, HKL hKL, HWND hWnd)
Definition: keymsg.c:98
BOOL APIENTRY Imm32JCloseOpen(HIMC hIMC, HKL hKL, HWND hWnd)
Definition: keymsg.c:161
BOOL APIENTRY Imm32KShapeToggle(HIMC hIMC)
Definition: keymsg.c:188
#define BOOL
Definition: nt_native.h:43
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL APIENTRY Imm32CSymbolToggle(HIMC hIMC, HKL hKL, HWND hWnd)
Definition: keymsg.c:129
#define IME_ESC_PRIVATE_HOTKEY
Definition: imm.h:571
#define IME_KHOTKEY_HANJACONVERT
Definition: imm.h:340
#define IME_THOTKEY_IME_NONIME_TOGGLE
Definition: imm.h:343
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:987
#define IS_NULL_UNEXPECTEDLY(p)
Definition: precomp.h:120
BOOL APIENTRY Imm32CImeNonImeToggle(HIMC hIMC, HKL hKL, HWND hWnd, LANGID LangID)
Definition: keymsg.c:67
#define IME_HOTKEY_PRIVATE_FIRST
Definition: imm.h:352
#define IME_CHOTKEY_SHAPE_TOGGLE
Definition: imm.h:332
int ret
#define IME_HOTKEY_PRIVATE_LAST
Definition: imm.h:357
#define IME_CHOTKEY_SYMBOL_TOGGLE
Definition: imm.h:333
#define IME_THOTKEY_SYMBOL_TOGGLE
Definition: imm.h:345
#define IME_KHOTKEY_ENGLISH
Definition: imm.h:341
BOOL APIENTRY Imm32KHanjaConvert(HIMC hIMC)
Definition: keymsg.c:211

Referenced by ImmProcessKey(), and ImmSimulateHotKey().

◆ Imm32ProcessRequest()

LRESULT APIENTRY Imm32ProcessRequest ( HIMC  hIMC,
PWND  pWnd,
DWORD  dwCommand,
LPVOID  pData,
BOOL  bAnsiAPI 
)

Definition at line 436 of file keymsg.c.

437 {
438  HWND hWnd;
439  DWORD ret = 0, dwCharPos, cchCompStr, dwSize;
440  LPVOID pCS, pTempData = pData;
441  LPRECONVERTSTRING pRS;
442  LPIMECHARPOSITION pICP;
443  PCLIENTIMC pClientImc;
444  UINT uCodePage = CP_ACP;
445  BOOL bAnsiWnd = !!(pWnd->state & WNDS_ANSIWINDOWPROC);
446  static const size_t acbData[7 * 2] =
447  {
448  /* UNICODE */
449  sizeof(COMPOSITIONFORM), sizeof(CANDIDATEFORM), sizeof(LOGFONTW),
450  sizeof(RECONVERTSTRING), sizeof(RECONVERTSTRING),
451  sizeof(IMECHARPOSITION), sizeof(RECONVERTSTRING),
452  /* ANSI */
453  sizeof(COMPOSITIONFORM), sizeof(CANDIDATEFORM), sizeof(LOGFONTA),
454  sizeof(RECONVERTSTRING), sizeof(RECONVERTSTRING),
455  sizeof(IMECHARPOSITION), sizeof(RECONVERTSTRING),
456  };
457 
458  if (dwCommand == 0 || dwCommand > IMR_DOCUMENTFEED)
459  {
460  ERR("Out of boundary\n");
461  return 0; /* Out of range */
462  }
463 
464  dwSize = acbData[bAnsiAPI * 7 + dwCommand - 1];
465  if (pData && IsBadWritePtr(pData, dwSize))
466  {
467  ERR("\n");
468  return 0; /* Invalid pointer */
469  }
470 
471  /* Sanity check */
472  switch (dwCommand)
473  {
475  pRS = pData;
476  if (pRS && (pRS->dwVersion != 0 || pRS->dwSize < sizeof(RECONVERTSTRING)))
477  {
478  ERR("Invalid pRS\n");
479  return 0;
480  }
481  break;
482 
484  pRS = pData;
485  if (!pRS || pRS->dwVersion != 0)
486  {
487  ERR("Invalid pRS\n");
488  return 0;
489  }
490  break;
491 
492  default:
494  return 0;
495  break;
496  }
497 
498  pClientImc = ImmLockClientImc(hIMC);
499  if (pClientImc)
500  {
501  uCodePage = pClientImc->uCodePage;
502  ImmUnlockClientImc(pClientImc);
503  }
504 
505  /* Prepare */
506  switch (dwCommand)
507  {
508  case IMR_COMPOSITIONFONT:
509  if (bAnsiAPI == bAnsiWnd)
510  goto DoIt; /* No conversion needed */
511 
512  if (bAnsiWnd)
513  pTempData = ImmLocalAlloc(0, sizeof(LOGFONTA));
514  else
515  pTempData = ImmLocalAlloc(0, sizeof(LOGFONTW));
516 
517  if (IS_NULL_UNEXPECTEDLY(pTempData))
518  return 0;
519  break;
520 
522  if (bAnsiAPI == bAnsiWnd || !pData)
523  goto DoIt; /* No conversion needed */
524 
525  if (bAnsiWnd)
526  ret = Imm32ReconvertAnsiFromWide(NULL, pData, uCodePage);
527  else
528  ret = Imm32ReconvertWideFromAnsi(NULL, pData, uCodePage);
529 
530  pTempData = ImmLocalAlloc(0, ret + sizeof(WCHAR));
531  if (IS_NULL_UNEXPECTEDLY(pTempData))
532  return 0;
533 
534  pRS = pTempData;
535  pRS->dwSize = ret;
536  pRS->dwVersion = 0;
537 
538  if (dwCommand == IMR_CONFIRMRECONVERTSTRING)
539  {
540  if (bAnsiWnd)
541  ret = Imm32ReconvertAnsiFromWide(pTempData, pData, uCodePage);
542  else
543  ret = Imm32ReconvertWideFromAnsi(pTempData, pData, uCodePage);
544  }
545  break;
546 
548  if (bAnsiAPI == bAnsiWnd)
549  goto DoIt; /* No conversion needed */
550 
551  pICP = pData;
552  dwCharPos = pICP->dwCharPos;
553 
554  if (bAnsiAPI)
555  {
556  cchCompStr = ImmGetCompositionStringA(hIMC, GCS_COMPSTR, NULL, 0);
557  if (IS_ZERO_UNEXPECTEDLY(cchCompStr))
558  return 0;
559 
560  pCS = ImmLocalAlloc(0, (cchCompStr + 1) * sizeof(CHAR));
561  if (IS_NULL_UNEXPECTEDLY(pCS))
562  return 0;
563 
564  ImmGetCompositionStringA(hIMC, GCS_COMPSTR, pCS, cchCompStr);
565  pICP->dwCharPos = IchWideFromAnsi(pICP->dwCharPos, pCS, uCodePage);
566  }
567  else
568  {
569  cchCompStr = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, NULL, 0);
570  if (IS_ZERO_UNEXPECTEDLY(cchCompStr))
571  return 0;
572 
573  pCS = ImmLocalAlloc(0, (cchCompStr + 1) * sizeof(WCHAR));
574  if (IS_NULL_UNEXPECTEDLY(pCS))
575  return 0;
576 
577  ImmGetCompositionStringW(hIMC, GCS_COMPSTR, pCS, cchCompStr);
578  pICP->dwCharPos = IchAnsiFromWide(pICP->dwCharPos, pCS, uCodePage);
579  }
580 
581  ImmLocalFree(pCS);
582  break;
583 
584  default:
585  WARN("0x%X\n", dwCommand);
586  break;
587  }
588 
589 DoIt:
590  /* The main task */
591  hWnd = pWnd->head.h;
592  if (bAnsiWnd)
593  ret = SendMessageA(hWnd, WM_IME_REQUEST, dwCommand, (LPARAM)pTempData);
594  else
595  ret = SendMessageW(hWnd, WM_IME_REQUEST, dwCommand, (LPARAM)pTempData);
596 
597  if (bAnsiAPI == bAnsiWnd)
598  goto Quit; /* No conversion needed */
599 
600  /* Get back to caller */
601  switch (dwCommand)
602  {
603  case IMR_COMPOSITIONFONT:
604  if (bAnsiAPI)
605  LogFontWideToAnsi(pTempData, pData);
606  else
607  LogFontAnsiToWide(pTempData, pData);
608  break;
609 
611  if (!ret)
612  break;
613 
614  if (ret < sizeof(RECONVERTSTRING))
615  {
616  ret = 0;
617  break;
618  }
619 
620  if (pTempData)
621  {
622  if (bAnsiWnd)
623  ret = Imm32ReconvertWideFromAnsi(pData, pTempData, uCodePage);
624  else
625  ret = Imm32ReconvertAnsiFromWide(pData, pTempData, uCodePage);
626  }
627  break;
628 
630  pICP->dwCharPos = dwCharPos;
631  break;
632 
633  default:
634  WARN("0x%X\n", dwCommand);
635  break;
636  }
637 
638 Quit:
639  if (pTempData != pData)
640  ImmLocalFree(pTempData);
641  return ret;
642 }
LONG WINAPI ImmGetCompositionStringA(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
Definition: compstr.c:855
BOOL NTAPI IsBadWritePtr(IN LPVOID lp, IN UINT_PTR ucb)
Definition: except.c:881
DWORD APIENTRY Imm32ReconvertAnsiFromWide(LPRECONVERTSTRING pDest, const RECONVERTSTRING *pSrc, UINT uCodePage)
Definition: utils.c:691
DWORD dwSize
Definition: imm.h:97
struct tagRECONVERTSTRING RECONVERTSTRING
VOID APIENTRY LogFontAnsiToWide(const LOGFONTA *plfA, LPLOGFONTW plfW)
Definition: utils.c:299
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CP_ACP
Definition: compat.h:109
char CHAR
Definition: xmlstorage.h:175
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:415
#define WARN(fmt,...)
Definition: debug.h:112
HWND hWnd
Definition: settings.c:17
DWORD dwVersion
Definition: imm.h:98
DWORD APIENTRY Imm32ReconvertWideFromAnsi(LPRECONVERTSTRING pDest, const RECONVERTSTRING *pSrc, UINT uCodePage)
Definition: utils.c:628
#define IMR_COMPOSITIONFONT
Definition: imm.h:540
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IMR_QUERYCHARPOSITION
Definition: imm.h:543
THRDESKHEAD head
Definition: ntuser.h:690
LONG_PTR LPARAM
Definition: windef.h:208
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:950
#define IMR_RECONVERTSTRING
Definition: imm.h:541
#define WM_IME_REQUEST
Definition: winuser.h:1826
UINT uCodePage
Definition: ntuser.h:1339
#define IMR_CONFIRMRECONVERTSTRING
Definition: imm.h:542
struct _tagCOMPOSITIONFORM COMPOSITIONFORM
LONG WINAPI ImmGetCompositionStringW(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
Definition: compstr.c:898
__wchar_t WCHAR
Definition: xmlstorage.h:180
struct tagLOGFONTW LOGFONTW
VOID APIENTRY LogFontWideToAnsi(const LOGFONTW *plfW, LPLOGFONTA plfA)
Definition: utils.c:312
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IS_NULL_UNEXPECTEDLY(p)
Definition: precomp.h:120
DWORD dwCharPos
Definition: imm.h:141
#define ImmLocalFree(lpData)
Definition: precomp.h:89
int ret
#define IS_ZERO_UNEXPECTEDLY(p)
Definition: precomp.h:124
LONG APIENTRY IchWideFromAnsi(LONG cchAnsi, LPCSTR pchAnsi, UINT uCodePage)
Definition: utils.c:252
struct tagCANDIDATEFORM CANDIDATEFORM
LONG APIENTRY IchAnsiFromWide(LONG cchWide, LPCWSTR pchWide, UINT uCodePage)
Definition: utils.c:273
#define IMR_DOCUMENTFEED
Definition: imm.h:544
#define ERR(fmt,...)
Definition: debug.h:110
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WNDS_ANSIWINDOWPROC
Definition: ntuser.h:619
DWORD state
Definition: ntuser.h:696
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
struct tagIMECHARPOSITION IMECHARPOSITION
#define GCS_COMPSTR
Definition: imm.h:367
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:996

Referenced by ImmRequestMessageAW().

◆ Imm32SendNotification()

BOOL APIENTRY Imm32SendNotification ( BOOL  bProcess)

Definition at line 430 of file keymsg.c.

431 {
432  return ImmEnumInputContext((bProcess ? -1 : 0), Imm32SendNotificationProc, 0);
433 }
BOOL WINAPI ImmEnumInputContext(DWORD dwThreadId, IMCENUMPROC lpfn, LPARAM lParam)
Definition: imm.c:1148
static BOOL CALLBACK Imm32SendNotificationProc(HIMC hIMC, LPARAM lParam)
Definition: keymsg.c:397

Referenced by ImmSystemHandler().

◆ Imm32SendNotificationProc()

static BOOL CALLBACK Imm32SendNotificationProc ( HIMC  hIMC,
LPARAM  lParam 
)
static

Definition at line 397 of file keymsg.c.

398 {
399  HWND hWnd;
400  LPINPUTCONTEXTDX pIC;
401 
402  pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
403  if (IS_NULL_UNEXPECTEDLY(pIC))
404  return TRUE;
405 
406  hWnd = pIC->hWnd;
407  if (hWnd == NULL || !IsWindow(hWnd))
408  {
409  ERR("\n");
410  goto Quit;
411  }
412 
413  TRACE("dwChange: 0x%08X\n", pIC->dwChange);
414 
420  NtUserNotifyIMEStatus(hWnd, pIC->fOpen, pIC->fdwConversion);
423 Quit:
424  pIC->dwChange = 0;
425  ImmUnlockIMC(hIMC); // ??? Windows doesn't unlock here
426  return TRUE;
427 }
#define WM_IME_NOTIFY
Definition: winuser.h:1820
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define TRUE
Definition: types.h:120
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1070
HWND hWnd
Definition: settings.c:17
DWORD NTAPI NtUserNotifyIMEStatus(HWND hwnd, BOOL fOpen, DWORD dwConversion)
Definition: ime.c:814
#define INPUTCONTEXTDX_CHANGE_OPEN
Definition: immdev.h:157
DWORD dwChange
Definition: immdev.h:135
#define IMN_SETOPENSTATUS
Definition: imm.h:528
#define IMN_SETSENTENCEMODE
Definition: imm.h:527
#define TRACE(s)
Definition: solgame.cpp:4
struct INPUTCONTEXTDX * LPINPUTCONTEXTDX
#define IS_NULL_UNEXPECTEDLY(p)
Definition: precomp.h:120
#define ERR(fmt,...)
Definition: debug.h:110
#define INPUTCONTEXTDX_CHANGE_SENTENCE
Definition: immdev.h:159
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IMN_SETCONVERSIONMODE
Definition: imm.h:526
#define NULL
Definition: types.h:112
#define INPUTCONTEXTDX_CHANGE_CONVERSION
Definition: immdev.h:158
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1079

Referenced by Imm32SendNotification().

◆ ImmGenerateMessage()

BOOL WINAPI ImmGenerateMessage ( HIMC  hIMC)

Definition at line 892 of file keymsg.c.

893 {
894  PCLIENTIMC pClientImc;
895  LPINPUTCONTEXT pIC;
896  LPTRANSMSG pMsgs, pTrans = NULL, pItem;
897  HWND hWnd;
898  DWORD dwIndex, dwCount, cbTrans;
899  HIMCC hMsgBuf = NULL;
900  BOOL bAnsi;
901 
902  TRACE("(%p)\n", hIMC);
903 
904  if (IS_CROSS_THREAD_HIMC(hIMC))
905  return FALSE;
906 
907  pClientImc = ImmLockClientImc(hIMC);
908  if (IS_NULL_UNEXPECTEDLY(pClientImc))
909  return FALSE;
910 
911  bAnsi = !(pClientImc->dwFlags & CLIENTIMC_WIDE);
912  ImmUnlockClientImc(pClientImc);
913 
914  pIC = ImmLockIMC(hIMC);
915  if (IS_NULL_UNEXPECTEDLY(pIC))
916  return FALSE;
917 
918  dwCount = pIC->dwNumMsgBuf;
919  if (dwCount == 0)
920  goto Quit;
921 
922  hMsgBuf = pIC->hMsgBuf;
923  pMsgs = ImmLockIMCC(hMsgBuf);
924  if (IS_NULL_UNEXPECTEDLY(pMsgs))
925  goto Quit;
926 
927  cbTrans = dwCount * sizeof(TRANSMSG);
928  pTrans = ImmLocalAlloc(0, cbTrans);
929  if (IS_NULL_UNEXPECTEDLY(pTrans))
930  goto Quit;
931 
932  RtlCopyMemory(pTrans, pMsgs, cbTrans);
933 
934 #ifdef IMM_WIN3_SUPPORT
935  if (GetWin32ClientInfo()->dwExpWinVer < _WIN32_WINNT_NT4) /* old version (3.x)? */
936  {
938  WORD wLang = PRIMARYLANGID(LangID);
939 
940  /* translate the messages if Japanese or Korean */
941  if (wLang == LANG_JAPANESE ||
942  (wLang == LANG_KOREAN && NtUserGetAppImeLevel(pIC->hWnd) == 3))
943  {
944  dwCount = WINNLSTranslateMessage(dwCount, pTrans, hIMC, bAnsi, wLang);
945  }
946  }
947 #endif
948 
949  /* send them */
950  hWnd = pIC->hWnd;
951  pItem = pTrans;
952  for (dwIndex = 0; dwIndex < dwCount; ++dwIndex, ++pItem)
953  {
954  if (bAnsi)
955  SendMessageA(hWnd, pItem->message, pItem->wParam, pItem->lParam);
956  else
957  SendMessageW(hWnd, pItem->message, pItem->wParam, pItem->lParam);
958  }
959 
960 Quit:
961  ImmLocalFree(pTrans);
962  if (hMsgBuf)
963  ImmUnlockIMCC(hMsgBuf);
964  pIC->dwNumMsgBuf = 0; /* done */
965  ImmUnlockIMC(hIMC);
966  return TRUE;
967 }
DWORD HIMCC
Definition: dimm.idl:76
#define IS_CROSS_THREAD_HIMC(hIMC)
Definition: precomp.h:143
#define TRUE
Definition: types.h:120
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1070
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:415
HWND hWnd
Definition: settings.c:17
LPVOID WINAPI ImmLockIMCC(HIMCC imcc)
Definition: utils.c:1198
WORD LANGID
Definition: typedefs.h:81
#define GetWin32ClientInfo()
Definition: ntuser.h:347
#define CLIENTIMC_WIDE
Definition: ntuser.h:1356
#define LANG_JAPANESE
Definition: nls.h:76
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define _WIN32_WINNT_NT4
Definition: sdkddkver.h:20
LCID WINAPI GetSystemDefaultLCID(void)
Definition: lang.c:791
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:950
DWORD NTAPI NtUserGetAppImeLevel(HWND hWnd)
Definition: ime.c:932
#define TRACE(s)
Definition: solgame.cpp:4
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _tagTRANSMSG TRANSMSG
#define IS_NULL_UNEXPECTEDLY(p)
Definition: precomp.h:120
#define ImmLocalFree(lpData)
Definition: precomp.h:89
BOOL WINAPI ImmUnlockIMCC(HIMCC imcc)
Definition: utils.c:1208
HIMCC hMsgBuf
Definition: immdev.h:73
#define LANGIDFROMLCID(l)
Definition: nls.h:18
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
DWORD dwNumMsgBuf
Definition: immdev.h:72
#define NULL
Definition: types.h:112
DWORD dwFlags
Definition: ntuser.h:1336
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define LANG_KOREAN
Definition: nls.h:84
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
Definition: wdfusb.h:1075
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1079
#define PRIMARYLANGID(l)
Definition: nls.h:16
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:996

Referenced by test_ImmMessages(), and test_InvalidIMC().

◆ ImmGetAppCompatFlags()

DWORD WINAPI ImmGetAppCompatFlags ( HIMC  hIMC)

Definition at line 754 of file keymsg.c.

755 {
756  PCLIENTIMC pClientIMC;
757  DWORD dwFlags;
758 
759  pClientIMC = ImmLockClientImc(hIMC);
760  if (IS_NULL_UNEXPECTEDLY(pClientIMC))
761  return 0;
762 
763  dwFlags = pClientIMC->dwCompatFlags;
764  ImmUnlockClientImc(pClientIMC);
765  return dwFlags;
766 }
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:950
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IS_NULL_UNEXPECTEDLY(p)
Definition: precomp.h:120
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
DWORD dwCompatFlags
Definition: ntuser.h:1337
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:996

Referenced by ImmProcessKey().

◆ ImmGetHotKey()

BOOL WINAPI ImmGetHotKey ( IN DWORD  dwHotKey,
OUT LPUINT  lpuModifiers,
OUT LPUINT  lpuVKey,
OUT LPHKL  lphKL 
)

Definition at line 692 of file keymsg.c.

694 {
695  TRACE("(0x%lX, %p, %p, %p)\n", dwHotKey, lpuModifiers, lpuVKey, lphKL);
696  if (lpuModifiers && lpuVKey)
697  return NtUserGetImeHotKey(dwHotKey, lpuModifiers, lpuVKey, lphKL);
698  return FALSE;
699 }
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
BOOL NTAPI NtUserGetImeHotKey(DWORD dwHotKeyId, LPUINT lpuModifiers, LPUINT lpuVirtualKey, LPHKL lphKL)
Definition: ime.c:420

◆ ImmGetVirtualKey()

UINT WINAPI ImmGetVirtualKey ( HWND  hWnd)

Definition at line 734 of file keymsg.c.

735 {
736  HIMC hIMC;
737  LPINPUTCONTEXTDX pIC;
739 
740  TRACE("(%p)\n", hWnd);
741 
742  hIMC = ImmGetContext(hWnd);
743  pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
744  if (IS_NULL_UNEXPECTEDLY(pIC))
745  return ret;
746 
747  if (pIC->bNeedsTrans)
748  ret = pIC->nVKey;
749 
750  ImmUnlockIMC(hIMC);
751  return ret;
752 }
#define VK_PROCESSKEY
Definition: winuser.h:2317
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1070
HWND hWnd
Definition: settings.c:17
BOOL bNeedsTrans
Definition: immdev.h:130
UINT nVKey
Definition: immdev.h:129
DWORD HIMC
Definition: dimm.idl:75
#define TRACE(s)
Definition: solgame.cpp:4
HIMC WINAPI ImmGetContext(HWND hWnd)
Definition: imm.c:1057
struct INPUTCONTEXTDX * LPINPUTCONTEXTDX
#define IS_NULL_UNEXPECTEDLY(p)
Definition: precomp.h:120
int ret
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1079

Referenced by ActiveIMMApp_GetVirtualKey().

◆ ImmIsUIMessageA()

BOOL WINAPI ImmIsUIMessageA ( HWND  hWndIME,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 673 of file keymsg.c.

674 {
675  TRACE("(%p, 0x%X, %p, %p)\n", hWndIME, msg, wParam, lParam);
676  return ImmIsUIMessageAW(hWndIME, msg, wParam, lParam, TRUE);
677 }
#define TRUE
Definition: types.h:120
static BOOL APIENTRY ImmIsUIMessageAW(HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam, BOOL bAnsi)
Definition: keymsg.c:310
WPARAM wParam
Definition: combotst.c:138
#define TRACE(s)
Definition: solgame.cpp:4
#define msg(x)
Definition: auth_time.c:54
LPARAM lParam
Definition: combotst.c:139

Referenced by ActiveIMMApp_IsUIMessageA(), and START_TEST().

◆ ImmIsUIMessageAW()

static BOOL APIENTRY ImmIsUIMessageAW ( HWND  hWndIME,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam,
BOOL  bAnsi 
)
static

Definition at line 310 of file keymsg.c.

311 {
312  switch (msg)
313  {
314  case WM_IME_STARTCOMPOSITION: case WM_IME_ENDCOMPOSITION:
315  case WM_IME_COMPOSITION: case WM_IME_SETCONTEXT: case WM_IME_NOTIFY:
317  break;
318  default:
319  return FALSE;
320  }
321 
322  if (IS_NULL_UNEXPECTEDLY(hWndIME))
323  return TRUE;
324 
325  if (bAnsi)
326  SendMessageA(hWndIME, msg, wParam, lParam);
327  else
328  SendMessageW(hWndIME, msg, wParam, lParam);
329 
330  return TRUE;
331 }
#define WM_IME_NOTIFY
Definition: winuser.h:1820
#define TRUE
Definition: types.h:120
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_IME_SELECT
Definition: winuser.h:1823
#define WM_IME_COMPOSITIONFULL
Definition: winuser.h:1822
WPARAM wParam
Definition: combotst.c:138
#define FALSE
Definition: types.h:117
#define WM_IME_SYSTEM
Definition: undocuser.h:60
#define WM_IME_SETCONTEXT
Definition: winuser.h:1819
#define IS_NULL_UNEXPECTEDLY(p)
Definition: precomp.h:120
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define msg(x)
Definition: auth_time.c:54
LPARAM lParam
Definition: combotst.c:139

Referenced by ImmIsUIMessageA(), and ImmIsUIMessageW().

◆ ImmIsUIMessageW()

BOOL WINAPI ImmIsUIMessageW ( HWND  hWndIME,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 682 of file keymsg.c.

683 {
684  TRACE("(%p, 0x%X, %p, %p)\n", hWndIME, msg, wParam, lParam);
685  return ImmIsUIMessageAW(hWndIME, msg, wParam, lParam, FALSE);
686 }
static BOOL APIENTRY ImmIsUIMessageAW(HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam, BOOL bAnsi)
Definition: keymsg.c:310
WPARAM wParam
Definition: combotst.c:138
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
#define msg(x)
Definition: auth_time.c:54
LPARAM lParam
Definition: combotst.c:139

Referenced by ActiveIMMApp_IsUIMessageW().

◆ ImmPostMessages()

VOID APIENTRY ImmPostMessages ( HWND  hwnd,
HIMC  hIMC,
DWORD  dwCount,
LPTRANSMSG  lpTransMsg 
)

Definition at line 970 of file keymsg.c.

971 {
972  DWORD dwIndex;
973  PCLIENTIMC pClientImc;
974  LPTRANSMSG pNewTransMsg = lpTransMsg, pItem;
975  BOOL bAnsi;
976 
977  pClientImc = ImmLockClientImc(hIMC);
978  if (IS_NULL_UNEXPECTEDLY(pClientImc))
979  return;
980 
981  bAnsi = !(pClientImc->dwFlags & CLIENTIMC_WIDE);
982  ImmUnlockClientImc(pClientImc);
983 
984 #ifdef IMM_WIN3_SUPPORT
985  if (GetWin32ClientInfo()->dwExpWinVer < _WIN32_WINNT_NT4) /* old version (3.x)? */
986  {
988  WORD Lang = PRIMARYLANGID(LangID);
989 
990  /* translate the messages if Japanese or Korean */
991  if (Lang == LANG_JAPANESE ||
992  (Lang == LANG_KOREAN && NtUserGetAppImeLevel(hwnd) == 3))
993  {
994  DWORD cbTransMsg = dwCount * sizeof(TRANSMSG);
995  pNewTransMsg = ImmLocalAlloc(0, cbTransMsg);
996  if (pNewTransMsg)
997  {
998  RtlCopyMemory(pNewTransMsg, lpTransMsg, cbTransMsg);
999  dwCount = WINNLSTranslateMessage(dwCount, pNewTransMsg, hIMC, bAnsi, Lang);
1000  }
1001  else
1002  {
1003  pNewTransMsg = lpTransMsg;
1004  }
1005  }
1006  }
1007 #endif
1008 
1009  /* post them */
1010  pItem = pNewTransMsg;
1011  for (dwIndex = 0; dwIndex < dwCount; ++dwIndex, ++pItem)
1012  {
1013  if (bAnsi)
1014  PostMessageA(hwnd, pItem->message, pItem->wParam, pItem->lParam);
1015  else
1016  PostMessageW(hwnd, pItem->message, pItem->wParam, pItem->lParam);
1017  }
1018 
1019 #ifdef IMM_WIN3_SUPPORT
1020  if (pNewTransMsg != lpTransMsg)
1021  ImmLocalFree(pNewTransMsg);
1022 #endif
1023 }
BOOL WINAPI PostMessageA(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:415
WORD LANGID
Definition: typedefs.h:81
#define GetWin32ClientInfo()
Definition: ntuser.h:347
#define CLIENTIMC_WIDE
Definition: ntuser.h:1356
#define LANG_JAPANESE
Definition: nls.h:76
unsigned int BOOL
Definition: ntddk_ex.h:94
#define _WIN32_WINNT_NT4
Definition: sdkddkver.h:20
LCID WINAPI GetSystemDefaultLCID(void)
Definition: lang.c:791
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:950
DWORD NTAPI NtUserGetAppImeLevel(HWND hWnd)
Definition: ime.c:932
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _tagTRANSMSG TRANSMSG
#define IS_NULL_UNEXPECTEDLY(p)
Definition: precomp.h:120
#define ImmLocalFree(lpData)
Definition: precomp.h:89
#define LANGIDFROMLCID(l)
Definition: nls.h:18
DWORD dwFlags
Definition: ntuser.h:1336
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define LANG_KOREAN
Definition: nls.h:84
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
Definition: wdfusb.h:1075
#define PRIMARYLANGID(l)
Definition: nls.h:16
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:996

Referenced by ImmTranslateMessage().

◆ ImmProcessKey()

DWORD WINAPI ImmProcessKey ( HWND  hWnd,
HKL  hKL,
UINT  vKey,
LPARAM  lParam,
DWORD  dwHotKeyID 
)

Definition at line 773 of file keymsg.c.

774 {
775  DWORD ret = 0;
776  HIMC hIMC;
777  PIMEDPI pImeDpi;
778  LPINPUTCONTEXTDX pIC;
779  BYTE KeyState[256];
780  UINT vk;
781  BOOL bUseIme = TRUE, bSkipThisKey = FALSE, bLowWordOnly = FALSE;
782 
783  TRACE("(%p, %p, 0x%X, %p, 0x%lX)\n", hWnd, hKL, vKey, lParam, dwHotKeyID);
784 
785  hIMC = ImmGetContext(hWnd);
786  pImeDpi = ImmLockImeDpi(hKL);
787  if (pImeDpi)
788  {
789  pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
790  if (pIC)
791  {
792  if (LOBYTE(vKey) == VK_PACKET &&
794  {
795  if (ImeDpi_IsUnicode(pImeDpi))
796  {
797  bLowWordOnly = TRUE;
798  }
799  else
800  {
801  bUseIme = FALSE;
802  if (pIC->fOpen)
803  bSkipThisKey = TRUE;
804  }
805  }
806 
807  if (bUseIme)
808  {
809  if (GetKeyboardState(KeyState))
810  {
811  vk = (bLowWordOnly ? LOWORD(vKey) : vKey);
812  if (pImeDpi->ImeProcessKey(hIMC, vk, lParam, KeyState))
813  {
814  pIC->bNeedsTrans = TRUE;
815  pIC->nVKey = vKey;
817  }
818  }
819  }
820  else if (bSkipThisKey)
821  {
823  }
824 
825  ImmUnlockIMC(hIMC);
826  }
827 
828  ImmUnlockImeDpi(pImeDpi);
829  }
830 
831  if (dwHotKeyID != INVALID_HOTKEY_ID) /* Valid Hot-key */
832  {
833  if (Imm32ProcessHotKey(hWnd, hIMC, hKL, dwHotKeyID))
834  {
835  if (vKey != VK_KANJI || dwHotKeyID != IME_JHOTKEY_CLOSE_OPEN)
836  ret |= IPHK_HOTKEY;
837  }
838  }
839 
840  if ((ret & IPHK_PROCESSBYIME) && (ImmGetAppCompatFlags(hIMC) & 0x10000))
841  {
842  /* The key has been processed by IME's ImeProcessKey */
844  if (PRIMARYLANGID(wLangID) == LANG_KOREAN &&
845  (vKey == VK_PROCESSKEY || (ret & IPHK_HOTKEY)))
846  {
847  /* Korean don't want VK_PROCESSKEY and IME hot-keys */
848  }
849  else
850  {
851  /* Add WM_KEYDOWN:VK_PROCESSKEY message */
855  }
856  }
857 
858  ImmReleaseContext(hWnd, hIMC);
859  return ret; /* Returns IPHK_... flags */
860 }
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:1016
DWORD WINAPI ImmGetAppCompatFlags(HIMC hIMC)
Definition: keymsg.c:754
#define IME_PROP_ACCEPT_WIDE_VKEY
Definition: imm.h:218
IMEINFO ImeInfo
Definition: ntuser.h:1284
#define IME_JHOTKEY_CLOSE_OPEN
Definition: imm.h:336
#define VK_PROCESSKEY
Definition: winuser.h:2317
#define VK_KANJI
Definition: winuser.h:2203
#define LOBYTE(W)
Definition: jmemdos.c:487
#define TRUE
Definition: types.h:120
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1070
WORD vk
Definition: input.c:77
HWND hWnd
Definition: settings.c:17
WORD LANGID
Definition: typedefs.h:81
BOOL WINAPI ImmTranslateMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lKeyData)
Definition: keymsg.c:1029
BOOL APIENTRY Imm32ProcessHotKey(HWND hWnd, HIMC hIMC, HKL hKL, DWORD dwHotKeyID)
Definition: keymsg.c:251
#define IPHK_PROCESSBYIME
Definition: undocuser.h:140
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL bNeedsTrans
Definition: immdev.h:130
UINT nVKey
Definition: immdev.h:129
#define WM_KEYDOWN
Definition: winuser.h:1705
LCID WINAPI GetSystemDefaultLCID(void)
Definition: lang.c:791
DWORD HIMC
Definition: dimm.idl:75
#define TRACE(s)
Definition: solgame.cpp:4
DWORD fdwProperty
Definition: imm.h:158
HIMC WINAPI ImmGetContext(HWND hWnd)
Definition: imm.c:1057
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:987
struct INPUTCONTEXTDX * LPINPUTCONTEXTDX
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ImeDpi_IsUnicode(pImeDpi)
Definition: precomp.h:145
_Check_return_ BOOL WINAPI GetKeyboardState(_Out_writes_(256) PBYTE lpKeyState)
int ret
#define LANGIDFROMLCID(l)
Definition: nls.h:18
unsigned char BYTE
Definition: xxhash.c:193
BOOL WINAPI ImmReleaseContext(HWND hWnd, HIMC hIMC)
Definition: imm.c:1098
#define IPHK_SKIPTHISKEY
Definition: undocuser.h:142
unsigned int UINT
Definition: ndis.h:50
#define IPHK_HOTKEY
Definition: undocuser.h:139
#define LANG_KOREAN
Definition: nls.h:84
#define INVALID_HOTKEY_ID
Definition: precomp.h:52
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1079
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define PRIMARYLANGID(l)
Definition: nls.h:16

Referenced by User32CallImmProcessKeyFromKernel().

◆ ImmRequestMessageA()

LRESULT WINAPI ImmRequestMessageA ( HIMC  hIMC,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1166 of file keymsg.c.

1167 {
1168  TRACE("(%p, %p, %p)\n", hIMC, wParam, lParam);
1169  return ImmRequestMessageAW(hIMC, wParam, lParam, TRUE);
1170 }
#define TRUE
Definition: types.h:120
WPARAM wParam
Definition: combotst.c:138
#define TRACE(s)
Definition: solgame.cpp:4
LRESULT APIENTRY ImmRequestMessageAW(HIMC hIMC, WPARAM wParam, LPARAM lParam, BOOL bAnsi)
Definition: keymsg.c:645
LPARAM lParam
Definition: combotst.c:139

Referenced by test_InvalidIMC().

◆ ImmRequestMessageAW()

LRESULT APIENTRY ImmRequestMessageAW ( HIMC  hIMC,
WPARAM  wParam,
LPARAM  lParam,
BOOL  bAnsi 
)

Definition at line 645 of file keymsg.c.

646 {
647  LRESULT ret = 0;
648  LPINPUTCONTEXT pIC;
649  HWND hWnd;
650  PWND pWnd = NULL;
651 
652  if (IS_NULL_UNEXPECTEDLY(hIMC) || IS_CROSS_THREAD_HIMC(hIMC))
653  return FALSE;
654 
655  pIC = ImmLockIMC(hIMC);
656  if (IS_NULL_UNEXPECTEDLY(pIC))
657  return FALSE;
658 
659  hWnd = pIC->hWnd;
660  if (hWnd)
661  pWnd = ValidateHwnd(hWnd);
662 
663  if (pWnd && pWnd->head.pti == Imm32CurrentPti())
664  ret = Imm32ProcessRequest(hIMC, pWnd, (DWORD)wParam, (LPVOID)lParam, bAnsi);
665 
666  ImmUnlockIMC(hIMC);
667  return ret;
668 }
#define IS_CROSS_THREAD_HIMC(hIMC)
Definition: precomp.h:143
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1070
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
#define FALSE
Definition: types.h:117
THRDESKHEAD head
Definition: ntuser.h:690
LRESULT APIENTRY Imm32ProcessRequest(HIMC hIMC, PWND pWnd, DWORD dwCommand, LPVOID pData, BOOL bAnsiAPI)
Definition: keymsg.c:436
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IS_NULL_UNEXPECTEDLY(p)
Definition: precomp.h:120
int ret
Definition: ntuser.h:688
#define NULL
Definition: types.h:112
LONG_PTR LRESULT
Definition: windef.h:209
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1079
LPARAM lParam
Definition: combotst.c:139
PTHREADINFO FASTCALL Imm32CurrentPti(VOID)
Definition: utils.c:19
#define ValidateHwnd(hwnd)
Definition: precomp.h:85

Referenced by ImmRequestMessageA(), and ImmRequestMessageW().

◆ ImmRequestMessageW()

LRESULT WINAPI ImmRequestMessageW ( HIMC  hIMC,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1175 of file keymsg.c.

1176 {
1177  TRACE("(%p, %p, %p)\n", hIMC, wParam, lParam);
1178  return ImmRequestMessageAW(hIMC, wParam, lParam, FALSE);
1179 }
WPARAM wParam
Definition: combotst.c:138
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
LRESULT APIENTRY ImmRequestMessageAW(HIMC hIMC, WPARAM wParam, LPARAM lParam, BOOL bAnsi)
Definition: keymsg.c:645
LPARAM lParam
Definition: combotst.c:139

◆ ImmSendMessageToActiveDefImeWndW()

LRESULT WINAPI ImmSendMessageToActiveDefImeWndW ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1185 of file keymsg.c.

1186 {
1187  HWND hwndIME;
1188 
1189  if (uMsg != WM_COPYDATA)
1190  return 0;
1191 
1193  if (IS_NULL_UNEXPECTEDLY(hwndIME))
1194  return 0;
1195 
1196  return SendMessageW(hwndIME, uMsg, wParam, lParam);
1197 }
HANDLE HWND
Definition: compat.h:19
WPARAM wParam
Definition: combotst.c:138
DWORD_PTR NTAPI NtUserQueryWindow(HWND hWnd, DWORD Index)
Definition: window.c:4181
#define QUERY_WINDOW_DEFAULT_IME
Definition: ntuser.h:2957
#define WM_COPYDATA
Definition: winuser.h:1654
#define IS_NULL_UNEXPECTEDLY(p)
Definition: precomp.h:120
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LPARAM lParam
Definition: combotst.c:139

◆ ImmSimulateHotKey()

BOOL WINAPI ImmSimulateHotKey ( HWND  hWnd,
DWORD  dwHotKeyID 
)

Definition at line 714 of file keymsg.c.

715 {
716  HIMC hIMC;
718  HKL hKL;
719  BOOL ret;
720 
721  TRACE("(%p, 0x%lX)\n", hWnd, dwHotKeyID);
722 
723  hIMC = ImmGetContext(hWnd);
726  ret = Imm32ProcessHotKey(hWnd, hIMC, hKL, dwHotKeyID);
727  ImmReleaseContext(hWnd, hIMC);
728  return ret;
729 }
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
HWND hWnd
Definition: settings.c:17
BOOL APIENTRY Imm32ProcessHotKey(HWND hWnd, HIMC hIMC, HKL hKL, DWORD dwHotKeyID)
Definition: keymsg.c:251
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD HIMC
Definition: dimm.idl:75
#define TRACE(s)
Definition: solgame.cpp:4
HIMC WINAPI ImmGetContext(HWND hWnd)
Definition: imm.c:1057
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
DWORD dwThreadId
Definition: fdebug.c:31
UINT_PTR HKL
Definition: msctf.idl:101
BOOL WINAPI ImmReleaseContext(HWND hWnd, HIMC hIMC)
Definition: imm.c:1098
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
#define NULL
Definition: types.h:112

Referenced by ActiveIMMApp_SimulateHotKey().

◆ ImmSystemHandler()

LRESULT WINAPI ImmSystemHandler ( HIMC  hIMC,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 865 of file keymsg.c.

866 {
867  TRACE("(%p, %p, %p)\n", hIMC, wParam, lParam);
868 
869  switch (wParam)
870  {
873  return 0;
874 
875  case IMS_COMPLETECOMPSTR:
877  return 0;
878 
879  case IMS_SETLANGBAND:
880  case IMS_UNSETLANGBAND:
882 
883  default:
884  WARN("%p\n", wParam);
885  return 0;
886  }
887 }
#define WARN(fmt,...)
Definition: debug.h:112
LRESULT APIENTRY CtfImmSetLangBand(HWND hWnd, BOOL fSet)
Definition: keymsg.c:363
#define IMS_SETLANGBAND
Definition: immdev.h:46
WPARAM wParam
Definition: combotst.c:138
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CPS_COMPLETE
Definition: imm.h:312
BOOL WINAPI ImmNotifyIME(HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue)
Definition: ime.c:907
#define TRACE(s)
Definition: solgame.cpp:4
#define IMS_COMPLETECOMPSTR
Definition: immdev.h:44
#define IMS_SENDNOTIFICATION
Definition: immdev.h:43
#define NI_COMPOSITIONSTR
Definition: imm.h:298
BOOL APIENTRY Imm32SendNotification(BOOL bProcess)
Definition: keymsg.c:430
#define IMS_UNSETLANGBAND
Definition: immdev.h:47
LPARAM lParam
Definition: combotst.c:139

Referenced by ImeWnd_OnImeSystem().

◆ ImmTranslateMessage()

BOOL WINAPI ImmTranslateMessage ( HWND  hwnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lKeyData 
)

Definition at line 1029 of file keymsg.c.

1030 {
1031 #define MSG_COUNT 0x100
1032  BOOL ret = FALSE;
1033  INT kret;
1034  LPINPUTCONTEXTDX pIC;
1035  PIMEDPI pImeDpi = NULL;
1037  LPTRANSMSG pTransMsg;
1038  BYTE abKeyState[256];
1039  HIMC hIMC;
1040  HKL hKL;
1041  UINT vk;
1042  DWORD dwThreadId, dwCount, cbList;
1043  WCHAR wch;
1044  WORD wChar;
1045 
1046  TRACE("(%p, 0x%X, %p, %p)\n", hwnd, msg, wParam, lKeyData);
1047 
1048  /* filter the message */
1049  switch (msg)
1050  {
1051  case WM_KEYDOWN: case WM_KEYUP: case WM_SYSKEYDOWN: case WM_SYSKEYUP:
1052  break;
1053  default:
1054  return FALSE;
1055  }
1056 
1057  hIMC = ImmGetContext(hwnd);
1058  pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
1059  if (IS_NULL_UNEXPECTEDLY(pIC))
1060  {
1061  ImmReleaseContext(hwnd, hIMC);
1062  return FALSE;
1063  }
1064 
1065  if (!pIC->bNeedsTrans) /* is translation needed? */
1066  {
1067  /* directly post them */
1068  dwCount = pIC->dwNumMsgBuf;
1069  if (dwCount == 0)
1070  goto Quit;
1071 
1072  pTransMsg = ImmLockIMCC(pIC->hMsgBuf);
1073  if (pTransMsg)
1074  {
1075  ImmPostMessages(hwnd, hIMC, dwCount, pTransMsg);
1076  ImmUnlockIMCC(pIC->hMsgBuf);
1077  ret = TRUE;
1078  }
1079  pIC->dwNumMsgBuf = 0; /* done */
1080  goto Quit;
1081  }
1082  pIC->bNeedsTrans = FALSE; /* clear the flag */
1083 
1086  pImeDpi = ImmLockImeDpi(hKL);
1087  if (IS_NULL_UNEXPECTEDLY(pImeDpi))
1088  goto Quit;
1089 
1090  if (!GetKeyboardState(abKeyState)) /* get keyboard ON/OFF status */
1091  {
1092  WARN("\n");
1093  goto Quit;
1094  }
1095 
1096  /* convert a virtual key if IME_PROP_KBD_CHAR_FIRST */
1097  vk = pIC->nVKey;
1099  {
1100  if (ImeDpi_IsUnicode(pImeDpi))
1101  {
1102  wch = 0;
1103  kret = ToUnicode(vk, HIWORD(lKeyData), abKeyState, &wch, 1, 0);
1104  if (kret == 1)
1105  vk = MAKELONG(LOBYTE(vk), wch);
1106  }
1107  else
1108  {
1109  wChar = 0;
1110  kret = ToAsciiEx(vk, HIWORD(lKeyData), abKeyState, &wChar, 0, hKL);
1111  if (kret > 0)
1112  {
1113  if ((BYTE)vk == VK_PACKET)
1114  {
1115  vk &= 0xFF;
1116  vk |= (wChar << 8);
1117  }
1118  else
1119  {
1120  vk = MAKEWORD(vk, wChar);
1121  }
1122  }
1123  }
1124  }
1125 
1126  /* allocate a list */
1127  cbList = offsetof(TRANSMSGLIST, TransMsg) + MSG_COUNT * sizeof(TRANSMSG);
1128  pList = ImmLocalAlloc(0, cbList);
1130  goto Quit;
1131 
1132  /* use IME conversion engine and convert the list */
1133  pList->uMsgCount = MSG_COUNT;
1134  kret = pImeDpi->ImeToAsciiEx(vk, HIWORD(lKeyData), abKeyState, pList, 0, hIMC);
1135  if (kret <= 0)
1136  goto Quit;
1137 
1138  /* post them */
1139  if (kret <= MSG_COUNT)
1140  {
1141  ImmPostMessages(hwnd, hIMC, kret, pList->TransMsg);
1142  ret = TRUE;
1143  }
1144  else
1145  {
1146  pTransMsg = ImmLockIMCC(pIC->hMsgBuf);
1147  if (IS_NULL_UNEXPECTEDLY(pTransMsg))
1148  goto Quit;
1149  ImmPostMessages(hwnd, hIMC, kret, pTransMsg);
1150  ImmUnlockIMCC(pIC->hMsgBuf);
1151  }
1152 
1153 Quit:
1155  ImmUnlockImeDpi(pImeDpi);
1156  ImmUnlockIMC(hIMC);
1157  ImmReleaseContext(hwnd, hIMC);
1158  TRACE("ret: %d\n", ret);
1159  return ret;
1160 #undef MSG_COUNT
1161 }
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:1016
IMEINFO ImeInfo
Definition: ntuser.h:1284
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
#define LOBYTE(W)
Definition: jmemdos.c:487
#define MAKEWORD(a, b)
Definition: typedefs.h:248
#define TRUE
Definition: types.h:120
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1070
#define IME_PROP_KBD_CHAR_FIRST
Definition: imm.h:214
WORD vk
Definition: input.c:77
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:415
#define WARN(fmt,...)
Definition: debug.h:112
LPVOID WINAPI ImmLockIMCC(HIMCC imcc)
Definition: utils.c:1198
int32_t INT
Definition: typedefs.h:58
WPARAM wParam
Definition: combotst.c:138
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
FxChildList * pList
BOOL bNeedsTrans
Definition: immdev.h:130
UINT nVKey
Definition: immdev.h:129
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define offsetof(TYPE, MEMBER)
#define WM_KEYDOWN
Definition: winuser.h:1705
VOID APIENTRY ImmPostMessages(HWND hwnd, HIMC hIMC, DWORD dwCount, LPTRANSMSG lpTransMsg)
Definition: keymsg.c:970
DWORD HIMC
Definition: dimm.idl:75
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD fdwProperty
Definition: imm.h:158
HIMC WINAPI ImmGetContext(HWND hWnd)
Definition: imm.c:1057
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:987
#define WM_KEYUP
Definition: winuser.h:1706
struct INPUTCONTEXTDX * LPINPUTCONTEXTDX
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _tagTRANSMSG TRANSMSG
#define IS_NULL_UNEXPECTEDLY(p)
Definition: precomp.h:120
#define ImeDpi_IsUnicode(pImeDpi)
Definition: precomp.h:145
_Check_return_ BOOL WINAPI GetKeyboardState(_Out_writes_(256) PBYTE lpKeyState)
#define MSG_COUNT
#define ImmLocalFree(lpData)
Definition: precomp.h:89
BOOL WINAPI ImmUnlockIMCC(HIMCC imcc)
Definition: utils.c:1208
int ret
DWORD dwThreadId
Definition: fdebug.c:31
UINT_PTR HKL
Definition: msctf.idl:101
unsigned char BYTE
Definition: xxhash.c:193
int WINAPI ToAsciiEx(_In_ UINT, _In_ UINT, _In_reads_opt_(256) CONST BYTE *, _Out_ LPWORD, _In_ UINT, _In_opt_ HKL)
BOOL WINAPI ImmReleaseContext(HWND hWnd, HIMC hIMC)
Definition: imm.c:1098
#define WM_SYSKEYUP
Definition: winuser.h:1710
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
int WINAPI ToUnicode(_In_ UINT wVirtKey, _In_ UINT wScanCode, _In_reads_bytes_opt_(256) CONST BYTE *lpKeyState, _Out_writes_(cchBuff) LPWSTR pwszBuff, _In_ int cchBuff, _In_ UINT wFlags)
#define msg(x)
Definition: auth_time.c:54
#define WM_SYSKEYDOWN
Definition: winuser.h:1709
#define HIWORD(l)
Definition: typedefs.h:247
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1079

Referenced by ImmProcessKey(), and TranslateMessage().

◆ ImmWINNLSGetIMEHotkey()

UINT WINAPI ImmWINNLSGetIMEHotkey ( HWND  hwndIme)

Definition at line 704 of file keymsg.c.

705 {
706  TRACE("(%p)\n", hwndIme);
707  UNREFERENCED_PARAMETER(hwndIme);
708  return 0; /* This is correct. This function of Windows just returns zero. */
709 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define TRACE(s)
Definition: solgame.cpp:4

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( imm  )