ReactOS  0.4.15-dev-5452-g3c95c95
keymsg.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS IMM32
3  * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4  * PURPOSE: Implementing IMM32 keys and messages
5  * COPYRIGHT: Copyright 1998 Patrik Stridvall
6  * Copyright 2002, 2003, 2007 CodeWeavers, Aric Stewart
7  * Copyright 2017 James Tabor <james.tabor@reactos.org>
8  * Copyright 2018 Amine Khaldi <amine.khaldi@reactos.org>
9  * Copyright 2020-2021 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
10  */
11 
12 #include "precomp.h"
13 
15 
16 /* Win: IMENonIMEToggle */
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 }
64 
65 /* Open or close the IME on Chinese or Taiwanese */
66 /* Win: CIMENonIMEToggle */
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 }
95 
96 /* Toggle shape mode on Chinese or Taiwanese */
97 /* Win: TShapeToggle */
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 }
127 
128 /* Win: CSymbolToggle */
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 }
158 
159 /* Open or close Japanese IME */
160 /* Win: JCloseOpen */
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 }
186 
187 /* Win: KShapeToggle */
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 }
209 
210 /* Win: KHanjaConvert */
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 }
227 
228 /* Win: KEnglishHangul */
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 }
249 
250 /* Win: HotKeyIDDispatcher */
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 }
307 
308 /* Win: ImmIsUIMessageWorker */
309 static BOOL APIENTRY
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 }
332 
334 {
338 
339 /* Sends a message to set the language band with delay. */
340 /* Win: DelaySetLangBand */
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 }
360 
361 /* Updates the language band. */
362 /* Win: CtfImmSetLangBand */
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 }
395 
396 /* Win: SendNotificationProc */
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 }
428 
429 /* Win: ImmSendNotification */
431 {
432  return ImmEnumInputContext((bProcess ? -1 : 0), Imm32SendNotificationProc, 0);
433 }
434 
436 Imm32ProcessRequest(HIMC hIMC, PWND pWnd, DWORD dwCommand, LPVOID pData, BOOL bAnsiAPI)
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 }
643 
644 /* Win: ImmRequestMessageWorker */
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 }
669 
670 /***********************************************************************
671  * ImmIsUIMessageA (IMM32.@)
672  */
674 {
675  TRACE("(%p, 0x%X, %p, %p)\n", hWndIME, msg, wParam, lParam);
676  return ImmIsUIMessageAW(hWndIME, msg, wParam, lParam, TRUE);
677 }
678 
679 /***********************************************************************
680  * ImmIsUIMessageW (IMM32.@)
681  */
683 {
684  TRACE("(%p, 0x%X, %p, %p)\n", hWndIME, msg, wParam, lParam);
685  return ImmIsUIMessageAW(hWndIME, msg, wParam, lParam, FALSE);
686 }
687 
688 /***********************************************************************
689  * ImmGetHotKey(IMM32.@)
690  */
691 BOOL WINAPI
692 ImmGetHotKey(IN DWORD dwHotKey, OUT LPUINT lpuModifiers, OUT LPUINT lpuVKey,
693  OUT LPHKL lphKL)
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 }
700 
701 /***********************************************************************
702  * ImmWINNLSGetIMEHotkey (IMM32.@)
703  */
705 {
706  TRACE("(%p)\n", hwndIme);
707  UNREFERENCED_PARAMETER(hwndIme);
708  return 0; /* This is correct. This function of Windows just returns zero. */
709 }
710 
711 /***********************************************************************
712  * ImmSimulateHotKey (IMM32.@)
713  */
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 }
730 
731 /***********************************************************************
732  * ImmGetVirtualKey (IMM32.@)
733  */
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 }
753 
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 }
767 
768 /***********************************************************************
769  * ImmProcessKey(IMM32.@)
770  * ( Undocumented, called from user32.dll )
771  */
773 ImmProcessKey(HWND hWnd, HKL hKL, UINT vKey, LPARAM lParam, DWORD dwHotKeyID)
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 }
861 
862 /***********************************************************************
863  * ImmSystemHandler(IMM32.@)
864  */
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 }
888 
889 /***********************************************************************
890  * ImmGenerateMessage(IMM32.@)
891  */
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 }
968 
970 ImmPostMessages(HWND hwnd, HIMC hIMC, DWORD dwCount, LPTRANSMSG lpTransMsg)
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 }
1024 
1025 /***********************************************************************
1026  * ImmTranslateMessage(IMM32.@)
1027  * ( Undocumented, call internally and from user32.dll )
1028  */
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 }
1162 
1163 /***********************************************************************
1164  * ImmRequestMessageA(IMM32.@)
1165  */
1167 {
1168  TRACE("(%p, %p, %p)\n", hIMC, wParam, lParam);
1169  return ImmRequestMessageAW(hIMC, wParam, lParam, TRUE);
1170 }
1171 
1172 /***********************************************************************
1173  * ImmRequestMessageW(IMM32.@)
1174  */
1176 {
1177  TRACE("(%p, %p, %p)\n", hIMC, wParam, lParam);
1178  return ImmRequestMessageAW(hIMC, wParam, lParam, FALSE);
1179 }
1180 
1181 /***********************************************************************
1182  * ImmSendMessageToActiveDefImeWndW (IMM32.@)
1183  */
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 }
#define LANGID_JAPANESE
Definition: precomp.h:58
DWORD HIMCC
Definition: dimm.idl:76
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
BOOL WINAPI ImmEnumInputContext(DWORD dwThreadId, IMCENUMPROC lpfn, LPARAM lParam)
Definition: imm.c:1148
#define IME_CMODE_SYMBOL
Definition: imm.h:500
#define IS_CROSS_THREAD_HIMC(hIMC)
Definition: precomp.h:143
#define WM_IME_NOTIFY
Definition: winuser.h:1820
#define IN
Definition: typedefs.h:39
#define IME_THOTKEY_SHAPE_TOGGLE
Definition: imm.h:344
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
LONG WINAPI ImmGetCompositionStringA(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
Definition: compstr.c:855
#define IME_JHOTKEY_CLOSE_OPEN
Definition: imm.h:336
#define CloseHandle
Definition: compat.h:739
#define VK_PROCESSKEY
Definition: winuser.h:2317
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
LRESULT WINAPI ImmSendMessageToActiveDefImeWndW(UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: keymsg.c:1185
#define VK_KANJI
Definition: winuser.h:2203
DWORD_PTR NTAPI NtUserGetThreadState(DWORD Routine)
Definition: misc.c:232
BOOL NTAPI IsBadWritePtr(IN LPVOID lp, IN UINT_PTR ucb)
Definition: except.c:881
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
DWORD APIENTRY Imm32ReconvertAnsiFromWide(LPRECONVERTSTRING pDest, const RECONVERTSTRING *pSrc, UINT uCodePage)
Definition: utils.c:691
BOOL WINAPI IsWindow(_In_opt_ HWND)
DWORD dwSize
Definition: imm.h:97
#define LOBYTE(W)
Definition: jmemdos.c:487
BOOL WINAPI ImmGetOpenStatus(HIMC hIMC)
Definition: ime.c:1452
#define IME_KHOTKEY_SHAPE_TOGGLE
Definition: imm.h:339
struct tagRECONVERTSTRING RECONVERTSTRING
#define MAKEWORD(a, b)
Definition: typedefs.h:248
VOID APIENTRY LogFontAnsiToWide(const LOGFONTA *plfA, LPLOGFONTW plfW)
Definition: utils.c:299
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
BOOL WINAPI PostMessageA(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1070
#define CP_ACP
Definition: compat.h:109
#define IME_PROP_KBD_CHAR_FIRST
Definition: imm.h:214
BOOL APIENTRY Imm32KEnglish(HIMC hIMC)
Definition: keymsg.c:229
static BOOL APIENTRY ImmIsUIMessageAW(HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam, BOOL bAnsi)
Definition: keymsg.c:310
WORD vk
Definition: input.c:77
char CHAR
Definition: xmlstorage.h:175
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:415
#define WARN(fmt,...)
Definition: debug.h:112
#define LANGID_CHINESE_TRADITIONAL
Definition: precomp.h:57
#define CALLBACK
Definition: compat.h:35
PSERVERINFO gpsi
Definition: imm.c:18
HWND hWnd
Definition: settings.c:17
LPVOID WINAPI ImmLockIMCC(HIMCC imcc)
Definition: utils.c:1198
LRESULT APIENTRY CtfImmSetLangBand(HWND hWnd, BOOL fSet)
Definition: keymsg.c:363
DWORD NTAPI NtUserNotifyIMEStatus(HWND hwnd, BOOL fOpen, DWORD dwConversion)
Definition: ime.c:814
HANDLE HWND
Definition: compat.h:19
#define WM_IME_SELECT
Definition: winuser.h:1823
uint32_t * LPUINT
Definition: typedefs.h:59
BOOL APIENTRY Imm32CShapeToggle(HIMC hIMC, HKL hKL, HWND hWnd)
Definition: keymsg.c:98
#define INPUTCONTEXTDX_CHANGE_OPEN
Definition: immdev.h:157
void * arg
Definition: msvc.h:10
#define IMS_SETLANGBAND
Definition: immdev.h:46
UINT_PTR WPARAM
Definition: windef.h:207
struct IMM_DELAY_SET_LANG_BAND IMM_DELAY_SET_LANG_BAND
WORD LANGID
Definition: typedefs.h:81
#define GetWin32ClientInfo()
Definition: ntuser.h:347
DWORD fdwConversion
Definition: immdev.h:60
DWORD dwChange
Definition: immdev.h:135
BOOL APIENTRY Imm32JCloseOpen(HIMC hIMC, HKL hKL, HWND hWnd)
Definition: keymsg.c:161
BOOL APIENTRY Imm32KShapeToggle(HIMC hIMC)
Definition: keymsg.c:188
BOOL WINAPI ImmTranslateMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lKeyData)
Definition: keymsg.c:1029
DWORD dwVersion
Definition: imm.h:98
#define BOOL
Definition: nt_native.h:43
BOOL APIENTRY Imm32ProcessHotKey(HWND hWnd, HIMC hIMC, HKL hKL, DWORD dwHotKeyID)
Definition: keymsg.c:251
BOOL WINAPI ImmSetConversionStatus(HIMC hIMC, DWORD fdwConversion, DWORD fdwSentence)
Definition: ime.c:1950
#define WM_IME_COMPOSITIONFULL
Definition: winuser.h:1822
int32_t INT
Definition: typedefs.h:58
DWORD APIENTRY Imm32ReconvertWideFromAnsi(LPRECONVERTSTRING pDest, const RECONVERTSTRING *pSrc, UINT uCodePage)
Definition: utils.c:628
WPARAM wParam
Definition: combotst.c:138
BOOL WINAPI ImmGetHotKey(IN DWORD dwHotKey, OUT LPUINT lpuModifiers, OUT LPUINT lpuVKey, OUT LPHKL lphKL)
Definition: keymsg.c:692
#define SMTO_ABORTIFHUNG
Definition: winuser.h:1213
static DWORD APIENTRY Imm32DelaySetLangBandProc(LPVOID arg)
Definition: keymsg.c:341
#define IPHK_PROCESSBYIME
Definition: undocuser.h:140
DWORD_PTR NTAPI NtUserQueryWindow(HWND hWnd, DWORD Index)
Definition: window.c:4181
#define CLIENTIMC_WIDE
Definition: ntuser.h:1356
#define IMR_COMPOSITIONFONT
Definition: imm.h:540
#define IMN_SETOPENSTATUS
Definition: imm.h:528
#define LANG_JAPANESE
Definition: nls.h:76
#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
FxChildList * pList
#define CPS_COMPLETE
Definition: imm.h:312
BOOL bNeedsTrans
Definition: immdev.h:130
BOOL WINAPI ImmIsUIMessageA(HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: keymsg.c:673
UINT nVKey
Definition: immdev.h:129
BOOL APIENTRY Imm32CSymbolToggle(HIMC hIMC, HKL hKL, HWND hWnd)
Definition: keymsg.c:129
#define IMR_QUERYCHARPOSITION
Definition: imm.h:543
THRDESKHEAD head
Definition: ntuser.h:690
#define MAKELONG(a, b)
Definition: typedefs.h:249
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 IMN_SETSENTENCEMODE
Definition: imm.h:527
#define offsetof(TYPE, MEMBER)
#define _WIN32_WINNT_NT4
Definition: sdkddkver.h:20
#define WM_KEYDOWN
Definition: winuser.h:1705
LONG_PTR LPARAM
Definition: windef.h:208
LCID WINAPI GetSystemDefaultLCID(void)
Definition: lang.c:791
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:950
DWORD WINAPI ImmProcessKey(HWND hWnd, HKL hKL, UINT vKey, LPARAM lParam, DWORD dwHotKeyID)
Definition: keymsg.c:773
VOID APIENTRY ImmPostMessages(HWND hwnd, HIMC hIMC, DWORD dwCount, LPTRANSMSG lpTransMsg)
Definition: keymsg.c:970
#define IMR_RECONVERTSTRING
Definition: imm.h:541
#define IME_ESC_PRIVATE_HOTKEY
Definition: imm.h:571
#define WM_IME_REQUEST
Definition: winuser.h:1826
#define WM_IME_SYSTEM
Definition: undocuser.h:60
DWORD HIMC
Definition: dimm.idl:75
UINT uCodePage
Definition: ntuser.h:1339
#define QUERY_WINDOW_DEFAULT_IME
Definition: ntuser.h:2957
#define IMR_CONFIRMRECONVERTSTRING
Definition: imm.h:542
DWORD NTAPI NtUserGetAppImeLevel(HWND hWnd)
Definition: ime.c:932
#define WM_COPYDATA
Definition: winuser.h:1654
UINT WINAPI ImmGetVirtualKey(HWND hWnd)
Definition: keymsg.c:734
BOOL WINAPI ImmNotifyIME(HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue)
Definition: ime.c:907
#define TRACE(s)
Definition: solgame.cpp:4
struct _tagCOMPOSITIONFORM COMPOSITIONFORM
LRESULT APIENTRY Imm32ProcessRequest(HIMC hIMC, PWND pWnd, DWORD dwCommand, LPVOID pData, BOOL bAnsiAPI)
Definition: keymsg.c:436
LONG WINAPI ImmGetCompositionStringW(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
Definition: compstr.c:898
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define IME_KHOTKEY_HANJACONVERT
Definition: imm.h:340
struct tagLOGFONTW LOGFONTW
#define IME_CMODE_FULLSHAPE
Definition: imm.h:493
UINT WINAPI GetKeyboardLayoutList(_In_ int nBuff, _Out_writes_to_opt_(nBuff, return) HKL FAR *lpList)
#define IME_THOTKEY_IME_NONIME_TOGGLE
Definition: imm.h:343
DWORD fdwProperty
Definition: imm.h:158
#define WM_IME_SETCONTEXT
Definition: winuser.h:1819
#define _countof(array)
Definition: sndvol32.h:68
#define IMS_COMPLETECOMPSTR
Definition: immdev.h:44
HIMC WINAPI ImmGetContext(HWND hWnd)
Definition: imm.c:1057
#define IMS_SENDNOTIFICATION
Definition: immdev.h:43
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:84
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:987
#define NI_COMPOSITIONSTR
Definition: imm.h:298
#define WINAPI
Definition: msvc.h:6
#define WM_KEYUP
Definition: winuser.h:1706
struct INPUTCONTEXTDX * LPINPUTCONTEXTDX
unsigned short WORD
Definition: ntddk_ex.h:93
VOID APIENTRY LogFontWideToAnsi(const LOGFONTW *plfW, LPLOGFONTA plfA)
Definition: utils.c:312
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WNDS2_WMCREATEMSGPROCESSED
Definition: ntuser.h:665
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)
BOOL APIENTRY Imm32CImeNonImeToggle(HIMC hIMC, HKL hKL, HWND hWnd, LANGID LangID)
Definition: keymsg.c:67
#define IME_HOTKEY_PRIVATE_FIRST
Definition: imm.h:352
DWORD dwCharPos
Definition: imm.h:141
#define MSG_COUNT
#define IME_CHOTKEY_SHAPE_TOGGLE
Definition: imm.h:332
#define ImmLocalFree(lpData)
Definition: precomp.h:89
BOOL WINAPI ImmUnlockIMCC(HIMCC imcc)
Definition: utils.c:1208
int ret
DWORD dwThreadId
Definition: fdebug.c:31
#define IME_HOTKEY_PRIVATE_LAST
Definition: imm.h:357
HIMCC hMsgBuf
Definition: immdev.h:73
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define IS_ZERO_UNEXPECTEDLY(p)
Definition: precomp.h:124
#define IME_CHOTKEY_SYMBOL_TOGGLE
Definition: imm.h:333
LONG APIENTRY IchWideFromAnsi(LONG cchAnsi, LPCSTR pchAnsi, UINT uCodePage)
Definition: utils.c:252
#define LANGIDFROMLCID(l)
Definition: nls.h:18
BOOL WINAPI ImmGenerateMessage(HIMC hIMC)
Definition: keymsg.c:892
struct tagCANDIDATEFORM CANDIDATEFORM
LONG APIENTRY IchAnsiFromWide(LONG cchWide, LPCWSTR pchWide, UINT uCodePage)
Definition: utils.c:273
UINT_PTR HKL
Definition: msctf.idl:101
uint32_t DWORD_PTR
Definition: typedefs.h:65
LRESULT APIENTRY ImmRequestMessageAW(HIMC hIMC, WPARAM wParam, LPARAM lParam, BOOL bAnsi)
Definition: keymsg.c:645
#define IME_THOTKEY_SYMBOL_TOGGLE
Definition: imm.h:345
unsigned char BYTE
Definition: xxhash.c:193
#define WM_USER
Definition: winuser.h:1885
int WINAPI ToAsciiEx(_In_ UINT, _In_ UINT, _In_reads_opt_(256) CONST BYTE *, _Out_ LPWORD, _In_ UINT, _In_opt_ HKL)
BOOL WINAPI ImmIsIME(HKL hKL)
Definition: ime.c:880
#define IME_CMODE_HANJACONVERT
Definition: imm.h:496
BOOL WINAPI ImmReleaseContext(HWND hWnd, HIMC hIMC)
Definition: imm.c:1098
LRESULT WINAPI ImmSystemHandler(HIMC hIMC, WPARAM wParam, LPARAM lParam)
Definition: keymsg.c:865
#define IMR_DOCUMENTFEED
Definition: imm.h:544
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:688
#define INPUTCONTEXTDX_CHANGE_SENTENCE
Definition: immdev.h:159
BOOL NTAPI NtUserGetImeHotKey(DWORD dwHotKeyId, LPUINT lpuModifiers, LPUINT lpuVirtualKey, LPHKL lphKL)
Definition: ime.c:420
HWND WINAPI ImmGetDefaultIMEWnd(HWND hWnd)
Definition: ime.c:890
BOOL APIENTRY Imm32SendNotification(BOOL bProcess)
Definition: keymsg.c:430
LRESULT WINAPI ImmRequestMessageW(HIMC hIMC, WPARAM wParam, LPARAM lParam)
Definition: keymsg.c:1175
#define WM_SYSKEYUP
Definition: winuser.h:1710
#define IPHK_SKIPTHISKEY
Definition: undocuser.h:142
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IMN_SETCONVERSIONMODE
Definition: imm.h:526
#define WNDS_ANSIWINDOWPROC
Definition: ntuser.h:619
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
DWORD state
Definition: ntuser.h:696
DWORD dwNumMsgBuf
Definition: immdev.h:72
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
DWORD fdwSentence
Definition: immdev.h:61
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)
BOOL WINAPI ImmIsUIMessageW(HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: keymsg.c:682
HANDLE hThread
Definition: wizard.c:28
BOOL APIENTRY Imm32ImeNonImeToggle(HIMC hIMC, HKL hKL, HWND hWnd, BOOL bNowIME, LANGID LangID)
Definition: keymsg.c:17
LRESULT WINAPI SendMessageTimeoutW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM, _In_ UINT, _In_ UINT, _Out_opt_ PDWORD_PTR)
#define IME_KHOTKEY_ENGLISH
Definition: imm.h:341
#define IPHK_HOTKEY
Definition: undocuser.h:139
DWORD dwFlags
Definition: ntuser.h:1336
BOOL WINAPI ImmSimulateHotKey(HWND hWnd, DWORD dwHotKeyID)
Definition: keymsg.c:714
#define msg(x)
Definition: auth_time.c:54
UINT WINAPI ImmWINNLSGetIMEHotkey(HWND hwndIme)
Definition: keymsg.c:704
struct IMM_DELAY_SET_LANG_BAND * PIMM_DELAY_SET_LANG_BAND
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define OUT
Definition: typedefs.h:40
#define WM_SYSKEYDOWN
Definition: winuser.h:1709
#define HIWORD(l)
Definition: typedefs.h:247
DWORD state2
Definition: ntuser.h:697
LRESULT WINAPI ImmRequestMessageA(HIMC hIMC, WPARAM wParam, LPARAM lParam)
Definition: keymsg.c:1166
#define INPUTCONTEXTDX_CHANGE_CONVERSION
Definition: immdev.h:158
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define LANG_KOREAN
Definition: nls.h:84
#define INVALID_HOTKEY_ID
Definition: precomp.h:52
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
LONG_PTR LRESULT
Definition: windef.h:209
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022
WINE_DEFAULT_DEBUG_CHANNEL(imm)
_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
struct tagIMECHARPOSITION IMECHARPOSITION
#define GCS_COMPSTR
Definition: imm.h:367
#define IMS_UNSETLANGBAND
Definition: immdev.h:47
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1079
LPARAM lParam
Definition: combotst.c:139
#define SMTO_BLOCK
Definition: winuser.h:1214
#define LOWORD(l)
Definition: pedump.c:82
DWORD dwCompatFlags
Definition: ntuser.h:1337
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define APIENTRY
Definition: api.h:79
BOOL APIENTRY Imm32KHanjaConvert(HIMC hIMC)
Definition: keymsg.c:211
PTHREADINFO FASTCALL Imm32CurrentPti(VOID)
Definition: utils.c:19
static BOOL CALLBACK Imm32SendNotificationProc(HIMC hIMC, LPARAM lParam)
Definition: keymsg.c:397
#define ValidateHwnd(hwnd)
Definition: precomp.h:85
#define PRIMARYLANGID(l)
Definition: nls.h:16
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:996