ReactOS 0.4.16-dev-297-gc569aee
keymsg.c File Reference
#include "precomp.h"
#include <jpnvkeys.h>
Include dependency graph for keymsg.c:

Go to the source code of this file.

Macros

#define MSG_COUNT   0x100
 

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 BOOL CALLBACK Imm32SendNotificationProc (_In_ HIMC hIMC, _In_ 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)
 
DWORD WINAPI ImmCallImeConsoleIME (_In_ HWND hWnd, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam, _Out_ LPUINT puVK)
 

Macro Definition Documentation

◆ MSG_COUNT

#define MSG_COUNT   0x100

Function Documentation

◆ Imm32CImeNonImeToggle()

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

Definition at line 68 of file keymsg.c.

69{
71 BOOL fOpen;
72
74 return FALSE;
75
76 if (LOWORD(hKL) != LangID || !ImmIsIME(hKL))
77 {
79 return TRUE;
80 }
81
82 pIC = ImmLockIMC(hIMC);
83 if (IS_NULL_UNEXPECTEDLY(pIC))
84 return TRUE;
85
86 fOpen = pIC->fOpen;
87 ImmUnlockIMC(hIMC);
88
89 if (fOpen)
90 Imm32ImeNonImeToggle(hIMC, hKL, hWnd, TRUE, 0);
91 else
93
94 return TRUE;
95}
HWND hWnd
Definition: settings.c:17
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOL WINAPI ImmIsIME(HKL hKL)
Definition: ime.c:880
BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen)
Definition: ime.c:1466
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1067
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1058
#define IS_NULL_UNEXPECTEDLY(p)
Definition: precomp.h:125
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL APIENTRY Imm32ImeNonImeToggle(HIMC hIMC, HKL hKL, HWND hWnd, BOOL bNowIME, LANGID LangID)
Definition: keymsg.c:18
#define LOWORD(l)
Definition: pedump.c:82
_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:1083

Referenced by Imm32ProcessHotKey().

◆ Imm32CShapeToggle()

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

Definition at line 99 of file keymsg.c.

100{
101 LPINPUTCONTEXT pIC;
102 BOOL fOpen;
103 DWORD dwConversion, dwSentence;
104
105 if (hWnd == NULL || !ImmIsIME(hKL))
106 return FALSE;
107
108 pIC = ImmLockIMC(hIMC);
109 if (IS_NULL_UNEXPECTEDLY(pIC))
110 return TRUE;
111
112 fOpen = pIC->fOpen;
113 if (fOpen)
114 {
115 dwConversion = (pIC->fdwConversion ^ IME_CMODE_FULLSHAPE);
116 dwSentence = pIC->fdwSentence;
117 }
118
119 ImmUnlockIMC(hIMC);
120
121 if (fOpen)
122 ImmSetConversionStatus(hIMC, dwConversion, dwSentence);
123 else
124 ImmSetOpenStatus(hIMC, TRUE);
125
126 return TRUE;
127}
#define NULL
Definition: types.h:112
BOOL WINAPI ImmSetConversionStatus(HIMC hIMC, DWORD fdwConversion, DWORD fdwSentence)
Definition: ime.c:1941
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IME_CMODE_FULLSHAPE
Definition: imm.h:345
DWORD fdwConversion
Definition: immdev.h:133
DWORD fdwSentence
Definition: immdev.h:134

Referenced by Imm32ProcessHotKey().

◆ Imm32CSymbolToggle()

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

Definition at line 130 of file keymsg.c.

131{
132 LPINPUTCONTEXT pIC;
133 BOOL fOpen;
134 DWORD dwConversion, dwSentence;
135
136 if (hWnd == NULL || !ImmIsIME(hKL))
137 return FALSE;
138
139 pIC = ImmLockIMC(hIMC);
140 if (IS_NULL_UNEXPECTEDLY(pIC))
141 return TRUE;
142
143 fOpen = pIC->fOpen;
144 if (fOpen)
145 {
146 dwConversion = (pIC->fdwConversion ^ IME_CMODE_SYMBOL);
147 dwSentence = pIC->fdwSentence;
148 }
149
150 ImmUnlockIMC(hIMC);
151
152 if (fOpen)
153 ImmSetConversionStatus(hIMC, dwConversion, dwSentence);
154 else
155 ImmSetOpenStatus(hIMC, TRUE);
156
157 return TRUE;
158}
#define IME_CMODE_SYMBOL
Definition: imm.h:352

Referenced by Imm32ProcessHotKey().

◆ Imm32ImeNonImeToggle()

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

Definition at line 18 of file keymsg.c.

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

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;
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 {
180 ImmUnlockIMC(hIMC);
181 }
182 }
183
184 return TRUE;
185}
BOOL WINAPI ImmGetOpenStatus(HIMC hIMC)
Definition: ime.c:1443
#define LANGID_JAPANESE
Definition: precomp.h:58
struct INPUTCONTEXTDX * LPINPUTCONTEXTDX
#define INPUTCONTEXTDX_CHANGE_FORCE_OPEN
Definition: immdev.h:185

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 IME_CMODE_NATIVE
Definition: imm.h:337

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 IME_CMODE_HANJACONVERT
Definition: imm.h:348

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}

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
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}
#define WARN(fmt,...)
Definition: precomp.h:61
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:978
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:1007
#define LANGID_CHINESE_SIMPLIFIED
Definition: precomp.h:56
#define IS_CROSS_THREAD_HIMC(hIMC)
Definition: precomp.h:148
#define LANGID_CHINESE_TRADITIONAL
Definition: precomp.h:57
#define IME_HOTKEY_PRIVATE_LAST
Definition: imm.h:221
#define IME_JHOTKEY_CLOSE_OPEN
Definition: imm.h:200
#define IME_KHOTKEY_HANJACONVERT
Definition: imm.h:204
#define IME_THOTKEY_IME_NONIME_TOGGLE
Definition: imm.h:207
#define IME_CHOTKEY_SYMBOL_TOGGLE
Definition: imm.h:197
#define IME_CHOTKEY_IME_NONIME_TOGGLE
Definition: imm.h:195
#define IME_ESC_PRIVATE_HOTKEY
Definition: imm.h:423
#define IME_KHOTKEY_SHAPE_TOGGLE
Definition: imm.h:203
#define IME_THOTKEY_SHAPE_TOGGLE
Definition: imm.h:208
#define IME_HOTKEY_PRIVATE_FIRST
Definition: imm.h:216
#define IME_KHOTKEY_ENGLISH
Definition: imm.h:205
#define IME_THOTKEY_SYMBOL_TOGGLE
Definition: imm.h:209
#define IME_CHOTKEY_SHAPE_TOGGLE
Definition: imm.h:196
BOOL APIENTRY Imm32JCloseOpen(HIMC hIMC, HKL hKL, HWND hWnd)
Definition: keymsg.c:161
BOOL APIENTRY Imm32CSymbolToggle(HIMC hIMC, HKL hKL, HWND hWnd)
Definition: keymsg.c:130
BOOL APIENTRY Imm32CShapeToggle(HIMC hIMC, HKL hKL, HWND hWnd)
Definition: keymsg.c:99
BOOL APIENTRY Imm32KEnglish(HIMC hIMC)
Definition: keymsg.c:229
BOOL APIENTRY Imm32KShapeToggle(HIMC hIMC)
Definition: keymsg.c:188
BOOL APIENTRY Imm32CImeNonImeToggle(HIMC hIMC, HKL hKL, HWND hWnd, LANGID LangID)
Definition: keymsg.c:68
BOOL APIENTRY Imm32KHanjaConvert(HIMC hIMC)
Definition: keymsg.c:211
#define BOOL
Definition: nt_native.h:43
int ret

Referenced by ImmProcessKey(), and ImmSimulateHotKey().

◆ Imm32ProcessRequest()

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

Definition at line 373 of file keymsg.c.

374{
375 HWND hWnd;
376 DWORD ret = 0, dwCharPos, cchCompStr, dwSize;
377 LPVOID pCS, pTempData = pData;
378 LPRECONVERTSTRING pRS;
379 LPIMECHARPOSITION pICP;
380 PCLIENTIMC pClientImc;
381 UINT uCodePage = CP_ACP;
382 BOOL bAnsiWnd = !!(pWnd->state & WNDS_ANSIWINDOWPROC);
383 static const size_t acbData[7 * 2] =
384 {
385 /* UNICODE */
386 sizeof(COMPOSITIONFORM), sizeof(CANDIDATEFORM), sizeof(LOGFONTW),
387 sizeof(RECONVERTSTRING), sizeof(RECONVERTSTRING),
388 sizeof(IMECHARPOSITION), sizeof(RECONVERTSTRING),
389 /* ANSI */
390 sizeof(COMPOSITIONFORM), sizeof(CANDIDATEFORM), sizeof(LOGFONTA),
391 sizeof(RECONVERTSTRING), sizeof(RECONVERTSTRING),
392 sizeof(IMECHARPOSITION), sizeof(RECONVERTSTRING),
393 };
394
395 if (dwCommand == 0 || dwCommand > IMR_DOCUMENTFEED)
396 {
397 ERR("Out of boundary\n");
398 return 0; /* Out of range */
399 }
400
401 dwSize = acbData[bAnsiAPI * 7 + dwCommand - 1];
403 {
404 ERR("\n");
405 return 0; /* Invalid pointer */
406 }
407
408 /* Sanity check */
409 switch (dwCommand)
410 {
411 case IMR_RECONVERTSTRING: case IMR_DOCUMENTFEED:
412 pRS = pData;
413 if (pRS && (pRS->dwVersion != 0 || pRS->dwSize < sizeof(RECONVERTSTRING)))
414 {
415 ERR("Invalid pRS\n");
416 return 0;
417 }
418 break;
419
420 case IMR_CONFIRMRECONVERTSTRING:
421 pRS = pData;
422 if (!pRS || pRS->dwVersion != 0)
423 {
424 ERR("Invalid pRS\n");
425 return 0;
426 }
427 break;
428
429 default:
431 return 0;
432 break;
433 }
434
435 pClientImc = ImmLockClientImc(hIMC);
436 if (pClientImc)
437 {
438 uCodePage = pClientImc->uCodePage;
439 ImmUnlockClientImc(pClientImc);
440 }
441
442 /* Prepare */
443 switch (dwCommand)
444 {
445 case IMR_COMPOSITIONFONT:
446 if (bAnsiAPI == bAnsiWnd)
447 goto DoIt; /* No conversion needed */
448
449 if (bAnsiWnd)
450 pTempData = ImmLocalAlloc(0, sizeof(LOGFONTA));
451 else
452 pTempData = ImmLocalAlloc(0, sizeof(LOGFONTW));
453
454 if (IS_NULL_UNEXPECTEDLY(pTempData))
455 return 0;
456 break;
457
458 case IMR_RECONVERTSTRING: case IMR_CONFIRMRECONVERTSTRING: case IMR_DOCUMENTFEED:
459 if (bAnsiAPI == bAnsiWnd || !pData)
460 goto DoIt; /* No conversion needed */
461
462 if (bAnsiWnd)
464 else
466
467 pTempData = ImmLocalAlloc(0, ret + sizeof(WCHAR));
468 if (IS_NULL_UNEXPECTEDLY(pTempData))
469 return 0;
470
471 pRS = pTempData;
472 pRS->dwSize = ret;
473 pRS->dwVersion = 0;
474
475 if (dwCommand == IMR_CONFIRMRECONVERTSTRING)
476 {
477 if (bAnsiWnd)
478 ret = Imm32ReconvertAnsiFromWide(pTempData, pData, uCodePage);
479 else
480 ret = Imm32ReconvertWideFromAnsi(pTempData, pData, uCodePage);
481 }
482 break;
483
484 case IMR_QUERYCHARPOSITION:
485 if (bAnsiAPI == bAnsiWnd)
486 goto DoIt; /* No conversion needed */
487
488 pICP = pData;
489 dwCharPos = pICP->dwCharPos;
490
491 if (bAnsiAPI)
492 {
493 cchCompStr = ImmGetCompositionStringA(hIMC, GCS_COMPSTR, NULL, 0);
494 if (IS_ZERO_UNEXPECTEDLY(cchCompStr))
495 return 0;
496
497 pCS = ImmLocalAlloc(0, (cchCompStr + 1) * sizeof(CHAR));
498 if (IS_NULL_UNEXPECTEDLY(pCS))
499 return 0;
500
501 ImmGetCompositionStringA(hIMC, GCS_COMPSTR, pCS, cchCompStr);
502 pICP->dwCharPos = IchWideFromAnsi(pICP->dwCharPos, pCS, uCodePage);
503 }
504 else
505 {
506 cchCompStr = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, NULL, 0);
507 if (IS_ZERO_UNEXPECTEDLY(cchCompStr))
508 return 0;
509
510 pCS = ImmLocalAlloc(0, (cchCompStr + 1) * sizeof(WCHAR));
511 if (IS_NULL_UNEXPECTEDLY(pCS))
512 return 0;
513
514 ImmGetCompositionStringW(hIMC, GCS_COMPSTR, pCS, cchCompStr);
515 pICP->dwCharPos = IchAnsiFromWide(pICP->dwCharPos, pCS, uCodePage);
516 }
517
518 ImmLocalFree(pCS);
519 break;
520
521 default:
522 WARN("0x%X\n", dwCommand);
523 break;
524 }
525
526DoIt:
527 /* The main task */
528 hWnd = pWnd->head.h;
529 if (bAnsiWnd)
530 ret = SendMessageA(hWnd, WM_IME_REQUEST, dwCommand, (LPARAM)pTempData);
531 else
532 ret = SendMessageW(hWnd, WM_IME_REQUEST, dwCommand, (LPARAM)pTempData);
533
534 if (bAnsiAPI == bAnsiWnd)
535 goto Quit; /* No conversion needed */
536
537 /* Get back to caller */
538 switch (dwCommand)
539 {
540 case IMR_COMPOSITIONFONT:
541 if (bAnsiAPI)
542 LogFontWideToAnsi(pTempData, pData);
543 else
544 LogFontAnsiToWide(pTempData, pData);
545 break;
546
547 case IMR_RECONVERTSTRING: case IMR_DOCUMENTFEED:
548 if (!ret)
549 break;
550
551 if (ret < sizeof(RECONVERTSTRING))
552 {
553 ret = 0;
554 break;
555 }
556
557 if (pTempData)
558 {
559 if (bAnsiWnd)
560 ret = Imm32ReconvertWideFromAnsi(pData, pTempData, uCodePage);
561 else
562 ret = Imm32ReconvertAnsiFromWide(pData, pTempData, uCodePage);
563 }
564 break;
565
566 case IMR_QUERYCHARPOSITION:
567 pICP->dwCharPos = dwCharPos;
568 break;
569
570 default:
571 WARN("0x%X\n", dwCommand);
572 break;
573 }
574
575Quit:
576 if (pTempData != pData)
577 ImmLocalFree(pTempData);
578 return ret;
579}
#define ERR(fmt,...)
Definition: precomp.h:57
LONG WINAPI ImmGetCompositionStringW(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
Definition: compstr.c:899
LONG WINAPI ImmGetCompositionStringA(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
Definition: compstr.c:856
#define CP_ACP
Definition: compat.h:109
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:984
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:938
VOID APIENTRY LogFontAnsiToWide(const LOGFONTA *plfA, LPLOGFONTW plfW)
Definition: utils.c:299
#define IS_ZERO_UNEXPECTEDLY(p)
Definition: precomp.h:129
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:415
VOID APIENTRY LogFontWideToAnsi(const LOGFONTW *plfW, LPLOGFONTA plfA)
Definition: utils.c:312
#define ImmLocalFree(lpData)
Definition: precomp.h:89
LONG APIENTRY IchWideFromAnsi(LONG cchAnsi, LPCSTR pchAnsi, UINT uCodePage)
Definition: utils.c:252
DWORD APIENTRY Imm32ReconvertAnsiFromWide(LPRECONVERTSTRING pDest, const RECONVERTSTRING *pSrc, UINT uCodePage)
Definition: utils.c:691
LONG APIENTRY IchAnsiFromWide(LONG cchWide, LPCWSTR pchWide, UINT uCodePage)
Definition: utils.c:273
DWORD APIENTRY Imm32ReconvertWideFromAnsi(LPRECONVERTSTRING pDest, const RECONVERTSTRING *pSrc, UINT uCodePage)
Definition: utils.c:628
BOOL NTAPI IsBadWritePtr(IN LPVOID lp, IN UINT_PTR ucb)
Definition: except.c:883
#define GCS_COMPSTR
Definition: imm.h:227
#define WNDS_ANSIWINDOWPROC
Definition: ntuser.h:624
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
THRDESKHEAD head
Definition: ntuser.h:695
DWORD state
Definition: ntuser.h:701
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
#define WM_IME_REQUEST
Definition: winuser.h:1839
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175

Referenced by ImmRequestMessageAW().

◆ Imm32SendNotification()

BOOL APIENTRY Imm32SendNotification ( BOOL  bProcess)

Definition at line 367 of file keymsg.c.

368{
369 return ImmEnumInputContext((bProcess ? -1 : 0), Imm32SendNotificationProc, 0);
370}
BOOL WINAPI ImmEnumInputContext(DWORD dwThreadId, IMCENUMPROC lpfn, LPARAM lParam)
Definition: imm.c:1097
static BOOL CALLBACK Imm32SendNotificationProc(_In_ HIMC hIMC, _In_ LPARAM lParam)
Definition: keymsg.c:334

Referenced by ImmSystemHandler().

◆ Imm32SendNotificationProc()

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

Definition at line 334 of file keymsg.c.

337{
338 HWND hWnd;
340
342
343 pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
344 if (IS_NULL_UNEXPECTEDLY(pIC))
345 return TRUE;
346
347 hWnd = pIC->hWnd;
348 if (!IsWindow(hWnd))
349 goto Quit;
350
351 TRACE("dwChange: 0x%08X\n", pIC->dwChange);
352
358 NtUserNotifyIMEStatus(hWnd, pIC->fOpen, pIC->fdwConversion);
361Quit:
362 pIC->dwChange = 0;
363 ImmUnlockIMC(hIMC); // ??? Windows doesn't unlock here
364 return TRUE;
365}
LPARAM lParam
Definition: combotst.c:139
#define IMN_SETSENTENCEMODE
Definition: imm.h:378
#define IMN_SETOPENSTATUS
Definition: imm.h:379
#define IMN_SETCONVERSIONMODE
Definition: imm.h:377
#define INPUTCONTEXTDX_CHANGE_OPEN
Definition: immdev.h:182
#define INPUTCONTEXTDX_CHANGE_SENTENCE
Definition: immdev.h:184
#define INPUTCONTEXTDX_CHANGE_CONVERSION
Definition: immdev.h:183
DWORD NTAPI NtUserNotifyIMEStatus(HWND hwnd, BOOL fOpen, DWORD dwConversion)
Definition: ime.c:803
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define WM_IME_NOTIFY
Definition: winuser.h:1833

Referenced by Imm32SendNotification().

◆ ImmCallImeConsoleIME()

DWORD WINAPI ImmCallImeConsoleIME ( _In_ HWND  hWnd,
_In_ UINT  uMsg,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam,
_Out_ LPUINT  puVK 
)

Definition at line 1133 of file keymsg.c.

1139{
1140 DWORD dwThreadId, ret = 0;
1141 HKL hKL;
1142 PWND pWnd = NULL;
1143 HIMC hIMC;
1144 PIMEDPI pImeDpi;
1145 UINT uVK;
1146 PIMC pIMC;
1147
1148 switch (uMsg)
1149 {
1150 case WM_KEYDOWN:
1151 case WM_KEYUP:
1152 case WM_SYSKEYDOWN:
1153 case WM_SYSKEYUP:
1154 break;
1155
1156 default:
1157 return 0;
1158 }
1159
1162
1163 if (hWnd && gpsi)
1164 pWnd = ValidateHwndNoErr(hWnd);
1165 if (IS_NULL_UNEXPECTEDLY(pWnd))
1166 return 0;
1167
1168 hIMC = ImmGetContext(hWnd);
1169 if (IS_NULL_UNEXPECTEDLY(hIMC))
1170 return 0;
1171
1172 uVK = *puVK = (wParam & 0xFF);
1173
1175 if (IS_NULL_UNEXPECTEDLY(pIMC))
1176 return 0;
1177
1178 pImeDpi = ImmLockImeDpi(hKL);
1179 if (IS_NULL_UNEXPECTEDLY(pImeDpi))
1180 return 0;
1181
1183 goto Quit;
1184
1185 switch (uVK)
1186 {
1187 case VK_DBE_ROMAN:
1188 case VK_DBE_NOROMAN:
1189 case VK_DBE_HIRAGANA:
1190 case VK_DBE_KATAKANA:
1191 case VK_DBE_CODEINPUT:
1192 case VK_DBE_NOCODEINPUT:
1195 break;
1196
1197 default:
1198 {
1199 if (uMsg == WM_SYSKEYDOWN || uMsg == WM_SYSKEYUP)
1200 {
1201 if (uVK != VK_MENU && uVK != VK_F10)
1202 goto Quit;
1203 }
1204
1205 if (!(pImeDpi->ImeInfo.fdwProperty & IME_PROP_NEED_ALTKEY))
1206 {
1207 if (uVK == VK_MENU || (lParam & MAKELPARAM(0, KF_ALTDOWN)))
1208 goto Quit;
1209 }
1210 }
1211 }
1212
1214
1215Quit:
1216 ImmUnlockImeDpi(pImeDpi);
1217 return ret;
1218}
WPARAM wParam
Definition: combotst.c:138
DWORD HIMC
Definition: dimm.idl:75
HIMC WINAPI ImmGetContext(HWND hWnd)
Definition: imm.c:1045
PSERVERINFO gpsi
Definition: imm.c:18
LPVOID FASTCALL ValidateHandleNoErr(HANDLE hObject, UINT uType)
Definition: utils.c:338
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:84
#define INVALID_HOTKEY_ID
Definition: precomp.h:52
DWORD dwThreadId
Definition: fdebug.c:31
#define IME_PROP_NEED_ALTKEY
Definition: immdev.h:387
#define IME_PROP_IGNORE_UPKEYS
Definition: immdev.h:386
@ TYPE_INPUTCONTEXT
Definition: ntuser.h:57
#define VK_DBE_ROMAN
Definition: jpnvkeys.h:19
#define VK_DBE_HIRAGANA
Definition: jpnvkeys.h:16
#define VK_DBE_CODEINPUT
Definition: jpnvkeys.h:24
#define VK_DBE_NOROMAN
Definition: jpnvkeys.h:20
#define VK_DBE_KATAKANA
Definition: jpnvkeys.h:15
#define VK_DBE_ENTERCONFIGMODE
Definition: jpnvkeys.h:22
#define VK_DBE_ENTERWORDREGISTERMODE
Definition: jpnvkeys.h:21
#define VK_DBE_NOCODEINPUT
Definition: jpnvkeys.h:25
DWORD WINAPI ImmProcessKey(HWND hWnd, HKL hKL, UINT vKey, LPARAM lParam, DWORD dwHotKeyID)
Definition: keymsg.c:715
IMEINFO ImeInfo
Definition: imm32_undoc.h:67
Definition: ntuser.h:694
DWORD fdwProperty
Definition: immdev.h:22
Definition: ntuser.h:199
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
HKL WINAPI GetKeyboardLayout(_In_ DWORD)
#define MAKELPARAM(l, h)
Definition: winuser.h:4011
#define WM_KEYUP
Definition: winuser.h:1719
#define VK_F10
Definition: winuser.h:2267
#define KF_ALTDOWN
Definition: winuser.h:2452
#define KF_UP
Definition: winuser.h:2454
#define WM_SYSKEYUP
Definition: winuser.h:1723
#define WM_KEYDOWN
Definition: winuser.h:1718
#define WM_SYSKEYDOWN
Definition: winuser.h:1722
#define VK_MENU
Definition: winuser.h:2207

◆ ImmGenerateMessage()

BOOL WINAPI ImmGenerateMessage ( HIMC  hIMC)

Definition at line 840 of file keymsg.c.

841{
842 PCLIENTIMC pClientImc;
843 LPINPUTCONTEXT pIC;
844 LPTRANSMSG pMsgs, pTrans = NULL, pItem;
845 HWND hWnd;
846 DWORD dwIndex, dwCount, cbTrans;
847 HIMCC hMsgBuf = NULL;
848 BOOL bAnsi;
849
850 TRACE("(%p)\n", hIMC);
851
852 if (IS_CROSS_THREAD_HIMC(hIMC))
853 return FALSE;
854
855 pClientImc = ImmLockClientImc(hIMC);
856 if (IS_NULL_UNEXPECTEDLY(pClientImc))
857 return FALSE;
858
859 bAnsi = !(pClientImc->dwFlags & CLIENTIMC_WIDE);
860 ImmUnlockClientImc(pClientImc);
861
862 pIC = ImmLockIMC(hIMC);
863 if (IS_NULL_UNEXPECTEDLY(pIC))
864 return FALSE;
865
866 dwCount = pIC->dwNumMsgBuf;
867 if (dwCount == 0)
868 goto Quit;
869
870 hMsgBuf = pIC->hMsgBuf;
871 pMsgs = ImmLockIMCC(hMsgBuf);
872 if (IS_NULL_UNEXPECTEDLY(pMsgs))
873 goto Quit;
874
875 cbTrans = dwCount * sizeof(TRANSMSG);
876 pTrans = ImmLocalAlloc(0, cbTrans);
877 if (IS_NULL_UNEXPECTEDLY(pTrans))
878 goto Quit;
879
880 RtlCopyMemory(pTrans, pMsgs, cbTrans);
881
882#ifdef IMM_WIN3_SUPPORT
883 if (GetWin32ClientInfo()->dwExpWinVer < _WIN32_WINNT_NT4) /* old version (3.x)? */
884 {
886 WORD wLang = PRIMARYLANGID(LangID);
887
888 /* translate the messages if Japanese or Korean */
889 if (wLang == LANG_JAPANESE ||
890 (wLang == LANG_KOREAN && NtUserGetAppImeLevel(pIC->hWnd) == 3))
891 {
892 dwCount = WINNLSTranslateMessage(dwCount, pTrans, hIMC, bAnsi, wLang);
893 }
894 }
895#endif
896
897 /* send them */
898 hWnd = pIC->hWnd;
899 pItem = pTrans;
900 for (dwIndex = 0; dwIndex < dwCount; ++dwIndex, ++pItem)
901 {
902 if (bAnsi)
903 SendMessageA(hWnd, pItem->message, pItem->wParam, pItem->lParam);
904 else
905 SendMessageW(hWnd, pItem->message, pItem->wParam, pItem->lParam);
906 }
907
908Quit:
909 ImmLocalFree(pTrans);
910 if (hMsgBuf)
911 ImmUnlockIMCC(hMsgBuf);
912 pIC->dwNumMsgBuf = 0; /* done */
913 ImmUnlockIMC(hIMC);
914 return TRUE;
915}
DWORD HIMCC
Definition: dimm.idl:76
BOOL WINAPI ImmUnlockIMCC(HIMCC imcc)
Definition: utils.c:1208
LPVOID WINAPI ImmLockIMCC(HIMCC imcc)
Definition: utils.c:1198
LCID WINAPI GetSystemDefaultLCID(void)
Definition: locale.c:1230
unsigned short WORD
Definition: ntddk_ex.h:93
struct _tagTRANSMSG TRANSMSG
#define CLIENTIMC_WIDE
Definition: imm32_undoc.h:142
DWORD NTAPI NtUserGetAppImeLevel(HWND hWnd)
Definition: ime.c:921
#define GetWin32ClientInfo()
Definition: ntuser.h:352
USHORT LANGID
Definition: mui.h:9
#define LANGIDFROMLCID(l)
Definition: nls.h:18
#define LANG_JAPANESE
Definition: nls.h:76
#define PRIMARYLANGID(l)
Definition: nls.h:16
#define LANG_KOREAN
Definition: nls.h:84
#define _WIN32_WINNT_NT4
Definition: sdkddkver.h:20
HIMCC hMsgBuf
Definition: immdev.h:146
DWORD dwNumMsgBuf
Definition: immdev.h:145
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

Referenced by test_ImmMessages(), and test_InvalidIMC().

◆ ImmGetAppCompatFlags()

DWORD WINAPI ImmGetAppCompatFlags ( HIMC  hIMC)

Definition at line 694 of file keymsg.c.

695{
696 PCLIENTIMC pClientIMC;
698
699 TRACE("(%p)\n", hIMC);
700
701 pClientIMC = ImmLockClientImc(hIMC);
702 if (IS_NULL_UNEXPECTEDLY(pClientIMC))
703 return 0;
704
705 dwFlags = pClientIMC->dwCompatFlags;
706 ImmUnlockClientImc(pClientIMC);
707 return (dwFlags | g_aimm_compat_flags);
708}
DWORD g_aimm_compat_flags
Definition: ctf.c:204
DWORD dwCompatFlags
Definition: imm32_undoc.h:123
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

Referenced by ImmProcessKey().

◆ ImmGetHotKey()

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

Definition at line 629 of file keymsg.c.

631{
632 TRACE("(0x%lX, %p, %p, %p)\n", dwHotKey, lpuModifiers, lpuVKey, lphKL);
633 if (lpuModifiers && lpuVKey)
634 return NtUserGetImeHotKey(dwHotKey, lpuModifiers, lpuVKey, lphKL);
635 return FALSE;
636}
BOOL NTAPI NtUserGetImeHotKey(DWORD dwHotKeyId, LPUINT lpuModifiers, LPUINT lpuVirtualKey, LPHKL lphKL)
Definition: ime.c:406

◆ ImmGetVirtualKey()

UINT WINAPI ImmGetVirtualKey ( HWND  hWnd)

Definition at line 671 of file keymsg.c.

672{
673 HIMC hIMC;
676
677 TRACE("(%p)\n", hWnd);
678
679 hIMC = ImmGetContext(hWnd);
680 pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
681 if (IS_NULL_UNEXPECTEDLY(pIC))
682 return ret;
683
684 if (pIC->bNeedsTrans)
685 ret = pIC->nVKey;
686
687 ImmUnlockIMC(hIMC);
688 return ret;
689}
#define VK_PROCESSKEY
Definition: winuser.h:2330

Referenced by ActiveIMMApp_GetVirtualKey().

◆ ImmIsUIMessageA()

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

Definition at line 610 of file keymsg.c.

611{
612 TRACE("(%p, 0x%X, %p, %p)\n", hWndIME, msg, wParam, lParam);
613 return ImmIsUIMessageAW(hWndIME, msg, wParam, lParam, TRUE);
614}
#define msg(x)
Definition: auth_time.c:54
static BOOL APIENTRY ImmIsUIMessageAW(HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam, BOOL bAnsi)
Definition: keymsg.c:310

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_SYSTEM
Definition: undocuser.h:60
#define WM_IME_SETCONTEXT
Definition: winuser.h:1832
#define WM_IME_COMPOSITIONFULL
Definition: winuser.h:1835
#define WM_IME_SELECT
Definition: winuser.h:1836

Referenced by ImmIsUIMessageA(), and ImmIsUIMessageW().

◆ ImmIsUIMessageW()

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

Definition at line 619 of file keymsg.c.

620{
621 TRACE("(%p, 0x%X, %p, %p)\n", hWndIME, msg, wParam, lParam);
622 return ImmIsUIMessageAW(hWndIME, msg, wParam, lParam, FALSE);
623}

Referenced by ActiveIMMApp_IsUIMessageW().

◆ ImmPostMessages()

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

Definition at line 918 of file keymsg.c.

919{
920 DWORD dwIndex;
921 PCLIENTIMC pClientImc;
922 LPTRANSMSG pNewTransMsg = lpTransMsg, pItem;
923 BOOL bAnsi;
924
925 pClientImc = ImmLockClientImc(hIMC);
926 if (IS_NULL_UNEXPECTEDLY(pClientImc))
927 return;
928
929 bAnsi = !(pClientImc->dwFlags & CLIENTIMC_WIDE);
930 ImmUnlockClientImc(pClientImc);
931
932#ifdef IMM_WIN3_SUPPORT
933 if (GetWin32ClientInfo()->dwExpWinVer < _WIN32_WINNT_NT4) /* old version (3.x)? */
934 {
936 WORD Lang = PRIMARYLANGID(LangID);
937
938 /* translate the messages if Japanese or Korean */
939 if (Lang == LANG_JAPANESE ||
940 (Lang == LANG_KOREAN && NtUserGetAppImeLevel(hwnd) == 3))
941 {
942 DWORD cbTransMsg = dwCount * sizeof(TRANSMSG);
943 pNewTransMsg = ImmLocalAlloc(0, cbTransMsg);
944 if (pNewTransMsg)
945 {
946 RtlCopyMemory(pNewTransMsg, lpTransMsg, cbTransMsg);
947 dwCount = WINNLSTranslateMessage(dwCount, pNewTransMsg, hIMC, bAnsi, Lang);
948 }
949 else
950 {
951 pNewTransMsg = lpTransMsg;
952 }
953 }
954 }
955#endif
956
957 /* post them */
958 pItem = pNewTransMsg;
959 for (dwIndex = 0; dwIndex < dwCount; ++dwIndex, ++pItem)
960 {
961 if (bAnsi)
962 PostMessageA(hwnd, pItem->message, pItem->wParam, pItem->lParam);
963 else
964 PostMessageW(hwnd, pItem->message, pItem->wParam, pItem->lParam);
965 }
966
967#ifdef IMM_WIN3_SUPPORT
968 if (pNewTransMsg != lpTransMsg)
969 ImmLocalFree(pNewTransMsg);
970#endif
971}
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
BOOL WINAPI PostMessageA(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by ImmTranslateMessage().

◆ ImmProcessKey()

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

Definition at line 715 of file keymsg.c.

716{
717 DWORD ret = 0;
718 HIMC hIMC;
719 PIMEDPI pImeDpi;
721 BYTE KeyState[256];
722 BOOL bLowWordOnly = FALSE, bSkipThisKey = FALSE, bHotKeyDone = TRUE;
723
724 TRACE("(%p, %p, 0x%X, %p, 0x%lX)\n", hWnd, hKL, vKey, lParam, dwHotKeyID);
725
726 /* Process the key by the IME */
727 hIMC = ImmGetContext(hWnd);
728 pImeDpi = ImmLockImeDpi(hKL);
729 if (pImeDpi)
730 {
731 pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
732 if (pIC)
733 {
734 if ((LOBYTE(vKey) == VK_PACKET) &&
736 {
737 if (ImeDpi_IsUnicode(pImeDpi))
738 {
739 bLowWordOnly = TRUE;
740 }
741 else
742 {
743 if (pIC->fOpen)
745
746 bSkipThisKey = TRUE;
747 }
748 }
749
750 if (!bSkipThisKey && GetKeyboardState(KeyState))
751 {
752 UINT vk = (bLowWordOnly ? LOWORD(vKey) : vKey);
753 if (pImeDpi->ImeProcessKey(hIMC, vk, lParam, KeyState))
754 {
755 pIC->bNeedsTrans = TRUE;
756 pIC->nVKey = vKey;
758 }
759 }
760
761 ImmUnlockIMC(hIMC);
762 }
763
764 ImmUnlockImeDpi(pImeDpi);
765 }
766
767 /* Process the hot-key if necessary */
768 if (!CtfImmIsCiceroStartedInThread()) /* Not Cicero? */
769 {
770 /* Process IMM IME hotkey */
771 if ((dwHotKeyID == INVALID_HOTKEY_ID) || !Imm32ProcessHotKey(hWnd, hIMC, hKL, dwHotKeyID))
772 bHotKeyDone = FALSE;
773 }
774 else if (!CtfImeProcessCicHotkey(hIMC, vKey, lParam)) /* CTF IME not processed the hotkey? */
775 {
776 /* Process IMM IME hotkey */
777 if (!IS_IME_HKL(hKL) ||
778 ((dwHotKeyID == INVALID_HOTKEY_ID) || !Imm32ProcessHotKey(hWnd, hIMC, hKL, dwHotKeyID)))
779 {
780 bHotKeyDone = FALSE;
781 }
782 }
783
784 if (bHotKeyDone && ((vKey != VK_KANJI) || (dwHotKeyID != IME_JHOTKEY_CLOSE_OPEN)))
785 ret |= IPHK_HOTKEY;
786
787 if ((ret & IPHK_PROCESSBYIME) && (ImmGetAppCompatFlags(hIMC) & 0x10000))
788 {
789 /* The key has been processed by IME's ImeProcessKey */
791 if ((PRIMARYLANGID(wLangID) == LANG_KOREAN) &&
792 ((vKey == VK_PROCESSKEY) || (ret & IPHK_HOTKEY)))
793 {
794 /* Korean don't want VK_PROCESSKEY and IME hot-keys */
795 }
796 else
797 {
798 /* Add WM_KEYDOWN:VK_PROCESSKEY message */
800
801 ret &= ~IPHK_PROCESSBYIME;
803 }
804 }
805
806 ImmReleaseContext(hWnd, hIMC);
807 return ret; /* Returns IPHK_... flags */
808}
BOOL WINAPI CtfImmIsCiceroStartedInThread(VOID)
Definition: ctf.c:781
BOOL WINAPI ImmReleaseContext(HWND hWnd, HIMC hIMC)
Definition: imm.c:1086
#define ImeDpi_IsUnicode(pImeDpi)
Definition: precomp.h:150
#define IS_IME_HKL(hKL)
Definition: imm32_undoc.h:20
#define IME_PROP_ACCEPT_WIDE_VKEY
Definition: immdev.h:389
#define LOBYTE(W)
Definition: jmemdos.c:487
BOOL WINAPI ImmTranslateMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lKeyData)
Definition: keymsg.c:977
DWORD WINAPI ImmGetAppCompatFlags(HIMC hIMC)
Definition: keymsg.c:694
BOOL APIENTRY Imm32ProcessHotKey(HWND hWnd, HIMC hIMC, HKL hKL, DWORD dwHotKeyID)
Definition: keymsg.c:251
WORD vk
Definition: input.c:77
EXTERN_C HRESULT WINAPI CtfImeProcessCicHotkey(_In_ HIMC hIMC, _In_ UINT vKey, _In_ LPARAM lParam)
Definition: msctfime.cpp:795
#define IPHK_SKIPTHISKEY
Definition: undocuser.h:142
#define IPHK_HOTKEY
Definition: undocuser.h:139
#define IPHK_PROCESSBYIME
Definition: undocuser.h:140
_Check_return_ BOOL WINAPI GetKeyboardState(_Out_writes_(256) PBYTE lpKeyState)
#define VK_KANJI
Definition: winuser.h:2216
unsigned char BYTE
Definition: xxhash.c:193

Referenced by ImmCallImeConsoleIME(), and User32CallImmProcessKeyFromKernel().

◆ ImmRequestMessageA()

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

Definition at line 1114 of file keymsg.c.

1115{
1116 TRACE("(%p, %p, %p)\n", hIMC, wParam, lParam);
1117 return ImmRequestMessageAW(hIMC, wParam, lParam, TRUE);
1118}
LRESULT APIENTRY ImmRequestMessageAW(HIMC hIMC, WPARAM wParam, LPARAM lParam, BOOL bAnsi)
Definition: keymsg.c:582

Referenced by test_InvalidIMC().

◆ ImmRequestMessageAW()

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

Definition at line 582 of file keymsg.c.

583{
584 LRESULT ret = 0;
585 LPINPUTCONTEXT pIC;
586 HWND hWnd;
587 PWND pWnd = NULL;
588
590 return FALSE;
591
592 pIC = ImmLockIMC(hIMC);
593 if (IS_NULL_UNEXPECTEDLY(pIC))
594 return FALSE;
595
596 hWnd = pIC->hWnd;
597 if (hWnd)
598 pWnd = ValidateHwnd(hWnd);
599
600 if (pWnd && pWnd->head.pti == Imm32CurrentPti())
601 ret = Imm32ProcessRequest(hIMC, pWnd, (DWORD)wParam, (LPVOID)lParam, bAnsi);
602
603 ImmUnlockIMC(hIMC);
604 return ret;
605}
#define ValidateHwnd(hwnd)
Definition: precomp.h:85
PTHREADINFO FASTCALL Imm32CurrentPti(VOID)
Definition: utils.c:19
LRESULT APIENTRY Imm32ProcessRequest(HIMC hIMC, PWND pWnd, DWORD dwCommand, LPVOID pData, BOOL bAnsiAPI)
Definition: keymsg.c:373
LONG_PTR LRESULT
Definition: windef.h:209

Referenced by ImmRequestMessageA(), and ImmRequestMessageW().

◆ ImmRequestMessageW()

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

Definition at line 1123 of file keymsg.c.

1124{
1125 TRACE("(%p, %p, %p)\n", hIMC, wParam, lParam);
1126 return ImmRequestMessageAW(hIMC, wParam, lParam, FALSE);
1127}

◆ ImmSimulateHotKey()

BOOL WINAPI ImmSimulateHotKey ( HWND  hWnd,
DWORD  dwHotKeyID 
)

Definition at line 651 of file keymsg.c.

652{
653 HIMC hIMC;
655 HKL hKL;
656 BOOL ret;
657
658 TRACE("(%p, 0x%lX)\n", hWnd, dwHotKeyID);
659
660 hIMC = ImmGetContext(hWnd);
663 ret = Imm32ProcessHotKey(hWnd, hIMC, hKL, dwHotKeyID);
664 ImmReleaseContext(hWnd, hIMC);
665 return ret;
666}

Referenced by ActiveIMMApp_SimulateHotKey().

◆ ImmSystemHandler()

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

Definition at line 813 of file keymsg.c.

814{
815 TRACE("(%p, %p, %p)\n", hIMC, wParam, lParam);
816
817 switch (wParam)
818 {
821 return 0;
822
825 return 0;
826
827 case IMS_SETLANGBAND:
830
831 default:
832 WARN("%p\n", wParam);
833 return 0;
834 }
835}
LRESULT CtfImmSetLangBand(_In_ HWND hWnd, _In_ BOOL fSet)
Definition: ctf.c:1233
BOOL WINAPI ImmNotifyIME(HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD_PTR dwValue)
Definition: ime.c:907
#define CPS_COMPLETE
Definition: imm.h:178
#define NI_COMPOSITIONSTR
Definition: immdev.h:403
#define IMS_SETLANGBAND
Definition: immdev.h:116
#define IMS_COMPLETECOMPSTR
Definition: immdev.h:114
#define IMS_UNSETLANGBAND
Definition: immdev.h:117
#define IMS_SENDNOTIFICATION
Definition: immdev.h:113
BOOL APIENTRY Imm32SendNotification(BOOL bProcess)
Definition: keymsg.c:367

Referenced by ImeWnd_OnImeSystem().

◆ ImmTranslateMessage()

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

Definition at line 977 of file keymsg.c.

978{
979#define MSG_COUNT 0x100
980 BOOL ret = FALSE;
981 INT kret;
983 PIMEDPI pImeDpi = NULL;
985 LPTRANSMSG pTransMsg;
986 BYTE abKeyState[256];
987 HIMC hIMC;
988 HKL hKL;
989 UINT vk;
990 DWORD dwThreadId, dwCount, cbList;
991 WCHAR wch;
992 WORD wChar;
993
994 TRACE("(%p, 0x%X, %p, %p)\n", hwnd, msg, wParam, lKeyData);
995
996 /* filter the message */
997 switch (msg)
998 {
999 case WM_KEYDOWN: case WM_KEYUP: case WM_SYSKEYDOWN: case WM_SYSKEYUP:
1000 break;
1001 default:
1002 return FALSE;
1003 }
1004
1005 hIMC = ImmGetContext(hwnd);
1006 pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
1007 if (IS_NULL_UNEXPECTEDLY(pIC))
1008 {
1009 ImmReleaseContext(hwnd, hIMC);
1010 return FALSE;
1011 }
1012
1013 if (!pIC->bNeedsTrans) /* is translation needed? */
1014 {
1015 /* directly post them */
1016 dwCount = pIC->dwNumMsgBuf;
1017 if (dwCount == 0)
1018 goto Quit;
1019
1020 pTransMsg = ImmLockIMCC(pIC->hMsgBuf);
1021 if (pTransMsg)
1022 {
1023 ImmPostMessages(hwnd, hIMC, dwCount, pTransMsg);
1024 ImmUnlockIMCC(pIC->hMsgBuf);
1025 ret = TRUE;
1026 }
1027 pIC->dwNumMsgBuf = 0; /* done */
1028 goto Quit;
1029 }
1030 pIC->bNeedsTrans = FALSE; /* clear the flag */
1031
1034 pImeDpi = ImmLockImeDpi(hKL);
1035 if (IS_NULL_UNEXPECTEDLY(pImeDpi))
1036 goto Quit;
1037
1038 if (!GetKeyboardState(abKeyState)) /* get keyboard ON/OFF status */
1039 {
1040 WARN("\n");
1041 goto Quit;
1042 }
1043
1044 /* convert a virtual key if IME_PROP_KBD_CHAR_FIRST */
1045 vk = pIC->nVKey;
1047 {
1048 if (ImeDpi_IsUnicode(pImeDpi))
1049 {
1050 wch = 0;
1051 kret = ToUnicode(vk, HIWORD(lKeyData), abKeyState, &wch, 1, 0);
1052 if (kret == 1)
1053 vk = MAKELONG(LOBYTE(vk), wch);
1054 }
1055 else
1056 {
1057 wChar = 0;
1058 kret = ToAsciiEx(vk, HIWORD(lKeyData), abKeyState, &wChar, 0, hKL);
1059 if (kret > 0)
1060 {
1061 if ((BYTE)vk == VK_PACKET)
1062 {
1063 vk &= 0xFF;
1064 vk |= (wChar << 8);
1065 }
1066 else
1067 {
1068 vk = MAKEWORD(vk, wChar);
1069 }
1070 }
1071 }
1072 }
1073
1074 /* allocate a list */
1075 cbList = offsetof(TRANSMSGLIST, TransMsg) + MSG_COUNT * sizeof(TRANSMSG);
1076 pList = ImmLocalAlloc(0, cbList);
1078 goto Quit;
1079
1080 /* use IME conversion engine and convert the list */
1081 pList->uMsgCount = MSG_COUNT;
1082 kret = pImeDpi->ImeToAsciiEx(vk, HIWORD(lKeyData), abKeyState, pList, 0, hIMC);
1083 if (kret <= 0)
1084 goto Quit;
1085
1086 /* post them */
1087 if (kret <= MSG_COUNT)
1088 {
1089 ImmPostMessages(hwnd, hIMC, kret, pList->TransMsg);
1090 ret = TRUE;
1091 }
1092 else
1093 {
1094 pTransMsg = ImmLockIMCC(pIC->hMsgBuf);
1095 if (IS_NULL_UNEXPECTEDLY(pTransMsg))
1096 goto Quit;
1097 ImmPostMessages(hwnd, hIMC, kret, pTransMsg);
1098 ImmUnlockIMCC(pIC->hMsgBuf);
1099 }
1100
1101Quit:
1103 ImmUnlockImeDpi(pImeDpi);
1104 ImmUnlockIMC(hIMC);
1105 ImmReleaseContext(hwnd, hIMC);
1106 TRACE("ret: %d\n", ret);
1107 return ret;
1108#undef MSG_COUNT
1109}
FxChildList * pList
#define IME_PROP_KBD_CHAR_FIRST
Definition: immdev.h:385
VOID APIENTRY ImmPostMessages(HWND hwnd, HIMC hIMC, DWORD dwCount, LPTRANSMSG lpTransMsg)
Definition: keymsg.c:918
#define MSG_COUNT
#define offsetof(TYPE, MEMBER)
#define MAKEWORD(a, b)
Definition: typedefs.h:248
int32_t INT
Definition: typedefs.h:58
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define HIWORD(l)
Definition: typedefs.h:247
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)
int WINAPI ToAsciiEx(_In_ UINT, _In_ UINT, _In_reads_opt_(256) CONST BYTE *, _Out_ LPWORD, _In_ UINT, _In_opt_ HKL)

Referenced by ImmProcessKey(), and TranslateMessage().

◆ ImmWINNLSGetIMEHotkey()

UINT WINAPI ImmWINNLSGetIMEHotkey ( HWND  hwndIme)

Definition at line 641 of file keymsg.c.

642{
643 TRACE("(%p)\n", hwndIme);
644 UNREFERENCED_PARAMETER(hwndIme);
645 return 0; /* This is correct. This function of Windows just returns zero. */
646}

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( imm  )