Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

223 lines
5.6 KiB

  1. /**************************************************************************\
  2. * Module Name: conime.c
  3. *
  4. * Copyright (c) 1985 - 1999, Microsoft Corporation
  5. *
  6. * client side receiveing stubs
  7. *
  8. * History:
  9. * 19-Sep-1995 v-HirShi Created
  10. * 12-Jun-1996 v-HirShi Attached to SUR
  11. \**************************************************************************/
  12. #include "precomp.h"
  13. #pragma hdrstop
  14. #define GUI_VKEY_MASK (0x00ff)
  15. DWORD
  16. ImmProcessKey(
  17. HWND hWnd,
  18. HKL hkl,
  19. UINT uVKey,
  20. LPARAM lParam,
  21. DWORD dwHotKeyID
  22. ) ;
  23. BOOL
  24. ImmSetActiveContext(
  25. HWND hWnd,
  26. HIMC hIMC,
  27. BOOL fFlag
  28. ) ;
  29. DWORD
  30. ImmCallImeConsoleIME(
  31. HWND hWnd,
  32. UINT Message,
  33. WPARAM wParam,
  34. LPARAM lParam,
  35. PUINT puVKey
  36. )
  37. /*++
  38. Routine Description:
  39. Called by Console IME to convert Character
  40. This routine copy from user\kernel\ntimm.c :: xxxImmProcessKey
  41. for Console IME could not calls kernel function.
  42. Arguments:
  43. Return Value:
  44. --*/
  45. {
  46. DWORD dwReturn ;
  47. PIMC pImc ;
  48. HIMC hImc ;
  49. BOOL fDBERoman ;
  50. PWND pwnd ;
  51. PIMEDPI pImeDpi;
  52. HKL hkl ;
  53. dwReturn = 0;
  54. pImc = NULL;
  55. fDBERoman = FALSE;
  56. //
  57. // we're interested in only keyboard messages.
  58. //
  59. if ( Message != WM_KEYDOWN &&
  60. Message != WM_SYSKEYDOWN &&
  61. Message != WM_KEYUP &&
  62. Message != WM_SYSKEYUP ) {
  63. return dwReturn;
  64. }
  65. hkl = GetKeyboardLayout( GetWindowThreadProcessId(hWnd, NULL) );
  66. pwnd = ValidateHwnd(hWnd);
  67. if ( pwnd == NULL) {
  68. return dwReturn;
  69. }
  70. hImc = ImmGetContext(hWnd);
  71. if ( hImc == NULL_HIMC ){
  72. return dwReturn;
  73. }
  74. *puVKey = (UINT)wParam & GUI_VKEY_MASK;
  75. //
  76. // Check input context
  77. //
  78. pImc = HMValidateHandle((HANDLE)hImc, TYPE_INPUTCONTEXT);
  79. if ( pImc == NULL ) {
  80. return dwReturn;
  81. }
  82. #ifdef LATER
  83. //
  84. // If there is an easy way to check the input context open/close status
  85. // from the kernel side, IME_PROP_NO_KEYS_ON_CLOSE checking should be
  86. // done here in kernel side. [ 3/10/96 takaok]
  87. //
  88. //
  89. // Check IME_PROP_NO_KEYS_ON_CLOSE bit
  90. //
  91. // if the current imc is not open and IME doesn't need
  92. // keys when being closed, we don't pass any keyboard
  93. // input to ime except hotkey and keys that change
  94. // the keyboard status.
  95. //
  96. if ( (piix->ImeInfo.fdwProperty & IME_PROP_NO_KEYS_ON_CLOSE) &&
  97. (!pimc->fdwState & IMC_OPEN) &&
  98. uVKey != VK_SHIFT && // 0x10
  99. uVKey != VK_CONTROL && // 0x11
  100. uVKey != VK_CAPITAL && // 0x14
  101. uVKey != VK_KANA && // 0x15
  102. uVKey != VK_NUMLOCK && // 0x90
  103. uVKey != VK_SCROLL ) // 0x91
  104. {
  105. // Check if Korea Hanja conversion mode
  106. if( !(pimc->fdwConvMode & IME_CMODE_HANJACONVERT) ) {
  107. return dwReturn;
  108. }
  109. }
  110. #endif
  111. //
  112. // if the IME doesn't need key up messages, we don't call ime.
  113. //
  114. pImeDpi = ImmLockImeDpi(hkl);
  115. if ( pImeDpi == NULL ) {
  116. return dwReturn;
  117. }
  118. if ( lParam & 0x80000000 && // set if key up, clear if key down
  119. pImeDpi->ImeInfo.fdwProperty & IME_PROP_IGNORE_UPKEYS )
  120. {
  121. ImmUnlockImeDpi(pImeDpi);
  122. return dwReturn;
  123. }
  124. //
  125. // we don't want to handle sys keys since many functions for
  126. // acceelerators won't work without this
  127. //
  128. fDBERoman = (BOOL)( (*puVKey == VK_DBE_ROMAN) ||
  129. (*puVKey == VK_DBE_NOROMAN) ||
  130. (*puVKey == VK_DBE_HIRAGANA) ||
  131. (*puVKey == VK_DBE_KATAKANA) ||
  132. (*puVKey == VK_DBE_CODEINPUT) ||
  133. (*puVKey == VK_DBE_NOCODEINPUT) ||
  134. (*puVKey == VK_DBE_IME_WORDREGISTER) ||
  135. (*puVKey == VK_DBE_IME_DIALOG) );
  136. if (Message == WM_SYSKEYDOWN || Message == WM_SYSKEYUP ) {
  137. //
  138. // IME may be waiting for VK_MENU, VK_F10 or VK_DBE_xxx
  139. //
  140. if ( *puVKey != VK_MENU && *puVKey != VK_F10 && !fDBERoman ) {
  141. ImmUnlockImeDpi(pImeDpi);
  142. return dwReturn;
  143. }
  144. }
  145. //
  146. // check if the IME doesn't need ALT key
  147. //
  148. if ( !(pImeDpi->ImeInfo.fdwProperty & IME_PROP_NEED_ALTKEY) ) {
  149. //
  150. // IME doesn't need ALT key
  151. //
  152. // we don't pass the ALT and ALT+xxx except VK_DBE_xxx keys.
  153. //
  154. if ( ! fDBERoman &&
  155. (*puVKey == VK_MENU || (lParam & 0x20000000)) // KF_ALTDOWN
  156. )
  157. {
  158. ImmUnlockImeDpi(pImeDpi);
  159. return dwReturn;
  160. }
  161. }
  162. dwReturn = ImmProcessKey(hWnd, hkl, *puVKey, lParam, IME_INVALID_HOTKEY ) ;
  163. ImmUnlockImeDpi(pImeDpi);
  164. return dwReturn;
  165. }
  166. BOOL
  167. ImmSetActiveContextConsoleIME(
  168. HWND hWnd,
  169. BOOL fFlag
  170. )
  171. /*++
  172. Routine Description:
  173. Set this context as active one.
  174. Arguments:
  175. hWnd - the get focus window
  176. fFlag - get focus or kill focus
  177. Return Value:
  178. --*/
  179. {
  180. HIMC hImc;
  181. hImc = ImmGetContext(hWnd) ;
  182. if (hImc == NULL_HIMC) {
  183. return FALSE;
  184. }
  185. return(ImmSetActiveContext(hWnd, hImc, fFlag)) ;
  186. }