Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

conime.c File Reference

#include "precomp.h"

Go to the source code of this file.

Defines

#define GUI_VKEY_MASK   (0x00ff)

Functions

DWORD ImmProcessKey (HWND hWnd, HKL hkl, UINT uVKey, LPARAM lParam, DWORD dwHotKeyID)
BOOL ImmSetActiveContext (HWND hWnd, HIMC hIMC, BOOL fFlag)
DWORD ImmCallImeConsoleIME (HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam, PUINT puVKey)
BOOL ImmSetActiveContextConsoleIME (HWND hWnd, BOOL fFlag)


Define Documentation

#define GUI_VKEY_MASK   (0x00ff)
 

Definition at line 15 of file ntuser/imm/conime.c.

Referenced by ImmCallImeConsoleIME().


Function Documentation

DWORD ImmCallImeConsoleIME HWND  hWnd,
UINT  Message,
WPARAM  wParam,
LPARAM  lParam,
PUINT  puVKey
 

Definition at line 34 of file ntuser/imm/conime.c.

References BOOL, DWORD, FALSE, GetKeyboardLayout(), GetWindowThreadProcessId(), GUI_VKEY_MASK, HMValidateHandle(), hWnd, tagIMEDPI::ImeInfo, ImmGetContext(), ImmLockImeDpi(), ImmProcessKey(), NULL, NULL_HIMC, PIMEDPI, TYPE_INPUTCONTEXT, UINT, and ValidateHwnd.

Referenced by CharHandlerFromConsole().

00043 : 00044 00045 Called by Console IME to convert Character 00046 This routine copy from user\kernel\ntimm.c :: xxxImmProcessKey 00047 for Console IME could not calls kernel function. 00048 00049 Arguments: 00050 00051 Return Value: 00052 --*/ 00053 { 00054 DWORD dwReturn ; 00055 PIMC pImc ; 00056 HIMC hImc ; 00057 BOOL fDBERoman ; 00058 PWND pwnd ; 00059 PIMEDPI pImeDpi; 00060 HKL hkl ; 00061 00062 dwReturn = 0; 00063 pImc = NULL; 00064 fDBERoman = FALSE; 00065 00066 // 00067 // we're interested in only keyboard messages. 00068 // 00069 if ( Message != WM_KEYDOWN && 00070 Message != WM_SYSKEYDOWN && 00071 Message != WM_KEYUP && 00072 Message != WM_SYSKEYUP ) { 00073 00074 return dwReturn; 00075 } 00076 00077 hkl = GetKeyboardLayout( GetWindowThreadProcessId(hWnd, NULL) ); 00078 pwnd = ValidateHwnd(hWnd); 00079 if ( pwnd == NULL) { 00080 return dwReturn; 00081 } 00082 hImc = ImmGetContext(hWnd); 00083 if ( hImc == NULL_HIMC ){ 00084 return dwReturn; 00085 } 00086 00087 *puVKey = (UINT)wParam & GUI_VKEY_MASK; 00088 00089 // 00090 // Check input context 00091 // 00092 pImc = HMValidateHandle((HANDLE)hImc, TYPE_INPUTCONTEXT); 00093 if ( pImc == NULL ) { 00094 return dwReturn; 00095 } 00096 00097 #ifdef LATER 00098 // 00099 // If there is an easy way to check the input context open/close status 00100 // from the kernel side, IME_PROP_NO_KEYS_ON_CLOSE checking should be 00101 // done here in kernel side. [ 3/10/96 takaok] 00102 // 00103 00104 // 00105 // Check IME_PROP_NO_KEYS_ON_CLOSE bit 00106 // 00107 // if the current imc is not open and IME doesn't need 00108 // keys when being closed, we don't pass any keyboard 00109 // input to ime except hotkey and keys that change 00110 // the keyboard status. 00111 // 00112 if ( (piix->ImeInfo.fdwProperty & IME_PROP_NO_KEYS_ON_CLOSE) && 00113 (!pimc->fdwState & IMC_OPEN) && 00114 uVKey != VK_SHIFT && // 0x10 00115 uVKey != VK_CONTROL && // 0x11 00116 uVKey != VK_CAPITAL && // 0x14 00117 uVKey != VK_KANA && // 0x15 00118 uVKey != VK_NUMLOCK && // 0x90 00119 uVKey != VK_SCROLL ) // 0x91 00120 { 00121 // Check if Korea Hanja conversion mode 00122 if( !(pimc->fdwConvMode & IME_CMODE_HANJACONVERT) ) { 00123 return dwReturn; 00124 } 00125 } 00126 #endif 00127 00128 // 00129 // if the IME doesn't need key up messages, we don't call ime. 00130 // 00131 pImeDpi = ImmLockImeDpi(hkl); 00132 if ( pImeDpi == NULL ) { 00133 return dwReturn; 00134 } 00135 00136 if ( lParam & 0x80000000 && // set if key up, clear if key down 00137 pImeDpi->ImeInfo.fdwProperty & IME_PROP_IGNORE_UPKEYS ) 00138 { 00139 return dwReturn; 00140 } 00141 00142 // 00143 // we don't want to handle sys keys since many functions for 00144 // acceelerators won't work without this 00145 // 00146 fDBERoman = (BOOL)( (*puVKey == VK_DBE_ROMAN) || 00147 (*puVKey == VK_DBE_NOROMAN) || 00148 (*puVKey == VK_DBE_HIRAGANA) || 00149 (*puVKey == VK_DBE_KATAKANA) || 00150 (*puVKey == VK_DBE_CODEINPUT) || 00151 (*puVKey == VK_DBE_NOCODEINPUT) || 00152 (*puVKey == VK_DBE_IME_WORDREGISTER) || 00153 (*puVKey == VK_DBE_IME_DIALOG) ); 00154 00155 if (Message == WM_SYSKEYDOWN || Message == WM_SYSKEYUP ) { 00156 // 00157 // IME may be waiting for VK_MENU, VK_F10 or VK_DBE_xxx 00158 // 00159 if ( *puVKey != VK_MENU && *puVKey != VK_F10 && !fDBERoman ) { 00160 return dwReturn; 00161 } 00162 } 00163 00164 // 00165 // check if the IME doesn't need ALT key 00166 // 00167 00168 if ( !(pImeDpi->ImeInfo.fdwProperty & IME_PROP_NEED_ALTKEY) ) { 00169 // 00170 // IME doesn't need ALT key 00171 // 00172 // we don't pass the ALT and ALT+xxx except VK_DBE_xxx keys. 00173 // 00174 if ( ! fDBERoman && 00175 (*puVKey == VK_MENU || (lParam & 0x20000000)) // KF_ALTDOWN 00176 ) 00177 { 00178 return dwReturn; 00179 } 00180 } 00181 00182 00183 dwReturn = ImmProcessKey(hWnd, hkl, *puVKey, lParam, IME_INVALID_HOTKEY ) ; 00184 return dwReturn; 00185 }

DWORD ImmProcessKey HWND  hWnd,
HKL  hkl,
UINT  uVKey,
LPARAM  lParam,
DWORD  dwHotKeyID
 

Definition at line 30 of file ntuser/imm/input.c.

Referenced by _InitializeImmEntryTable().

00036 { 00037 HIMC hIMC = ImmGetContext(hWnd); 00038 PIMEDPI pImeDpi = ImmLockImeDpi(hkl); 00039 DWORD dwReturn = 0; 00040 #if DBG 00041 if (dwHotKeyID >= IME_KHOTKEY_FIRST && dwHotKeyID <= IME_KHOTKEY_LAST) { 00042 TAGMSG2(DBGTAG_IMM, "ImmProcessKey: Kor IME Hotkeys should not come here: dwHotKeyID=%x, uVKey=%x", dwHotKeyID, uVKey); 00043 } 00044 #endif 00045 00046 ImmAssert(dwHotKeyID != IME_KHOTKEY_ENGLISH && 00047 dwHotKeyID != IME_KHOTKEY_SHAPE_TOGGLE && 00048 dwHotKeyID != IME_KHOTKEY_HANJACONVERT); 00049 00050 // 00051 // call ImeProcessKey 00052 // 00053 if (pImeDpi != NULL) { 00054 PINPUTCONTEXT pInputContext = ImmLockIMC(hIMC); 00055 00056 if (pInputContext != NULL) { 00057 BOOLEAN fTruncateWideVK = FALSE; 00058 BOOLEAN fCallIme = TRUE; 00059 BOOLEAN fSkipThisKey = FALSE; 00060 00061 #ifdef LATER 00062 00063 // 00064 // if the current imc is not open and IME doesn't need 00065 // keys when being closed, we don't pass any keyboard 00066 // input to ime except hotkey and keys that change 00067 // the keyboard status. 00068 // 00069 if ((pImeDpi->fdwProperty & IME_PROP_NO_KEYS_ON_CLOSE) && 00070 !pInputContext->fOpen && 00071 uVKey != VK_SHIFT && 00072 uVKey != VK_CONTROL && 00073 uVKey != VK_CAPITAL && 00074 uVKey != VK_KANA && 00075 uVKey != VK_NUMLOCK && 00076 uVKey != VK_SCROLL) { 00077 // Check if Korea Hanja conversion mode 00078 if(!(pimc->fdwConvMode & IME_CMODE_HANJACONVERT)) { 00079 fCallIme = FALSE; 00080 } 00081 } 00082 else 00083 #endif 00084 // 00085 // Protect IMEs which are unaware of wide virtual keys. 00086 // 00087 if ((BYTE)uVKey == VK_PACKET && 00088 (pImeDpi->ImeInfo.fdwProperty & IME_PROP_ACCEPT_WIDE_VKEY) == 0) { 00089 00090 if (pImeDpi->ImeInfo.fdwProperty & IME_PROP_UNICODE) { 00091 // 00092 // Since this IME is not ready to accept wide VKey, we should 00093 // truncate it. 00094 // 00095 fTruncateWideVK = TRUE; 00096 } 00097 else { 00098 // 00099 // Hmm, this guy is ANSI IME, and does not declare Wide Vkey awareness. 00100 // Let's guess this one is not ready to accept Wide Vkey, so let's not 00101 // pass it to this guy. 00102 // And if it is opened, we'd better skip this key for safety. 00103 // 00104 fCallIme = FALSE; 00105 if (pInputContext->fOpen) { 00106 fSkipThisKey = TRUE; 00107 } 00108 } 00109 } 00110 00111 if (fCallIme) { 00112 PBYTE pbKeyState = (PBYTE)ImmLocalAlloc(0, 256); 00113 00114 ImmAssert(fSkipThisKey == FALSE); 00115 00116 if (pbKeyState != NULL) { 00117 if (GetKeyboardState(pbKeyState)) { 00118 UINT uVKeyIme = uVKey; 00119 if (fTruncateWideVK) { 00120 uVKeyIme &= 0xffff; 00121 } 00122 if ( (*pImeDpi->pfn.ImeProcessKey)(hIMC, uVKeyIme, lParam, pbKeyState) ) { 00123 // 00124 // if the return value of ImeProcessKey is TRUE, 00125 // it means the key is the one that the ime is 00126 // waiting for. 00127 // 00128 pInputContext->fChgMsg = TRUE; 00129 pInputContext->uSavedVKey = uVKey; 00130 dwReturn |= IPHK_PROCESSBYIME; 00131 } 00132 } 00133 ImmLocalFree(pbKeyState); 00134 } 00135 } 00136 else if (fSkipThisKey) { 00137 dwReturn |= IPHK_SKIPTHISKEY; 00138 ImmAssert((dwReturn & (IPHK_PROCESSBYIME | IPHK_HOTKEY)) == 0); 00139 } 00140 ImmUnlockIMC(hIMC); 00141 } 00142 ImmUnlockImeDpi(pImeDpi); 00143 } 00144 00145 // 00146 // call hotkey handler 00147 // 00148 if (dwHotKeyID != IME_INVALID_HOTKEY && HotKeyIDDispatcher(hWnd, hIMC, hkl, dwHotKeyID)) { 00149 // Backward compat: 00150 // On Japanese system, some applications may want VK_KANJI. 00151 if ((uVKey != VK_KANJI) || 00152 (dwHotKeyID != IME_JHOTKEY_CLOSE_OPEN)) { 00153 dwReturn |= IPHK_HOTKEY; 00154 } 00155 } 00156 00157 // 00158 // some 3.x application doesn't like to see 00159 // VK_PROCESSKEY. 00160 // 00161 if (dwReturn & IPHK_PROCESSBYIME) { 00162 00163 DWORD dwImeCompat = ImmGetAppCompatFlags(hIMC); 00164 00165 if (dwImeCompat & IMECOMPAT_NOVKPROCESSKEY) { 00166 00167 // Korea 3.x application doesn't like to see dummy finalize VK_PROCESSKEY 00168 // and IME hot key. 00169 00170 if ( PRIMARYLANGID(LANGIDFROMLCID(GetSystemDefaultLCID())) == LANG_KOREAN && 00171 ( (uVKey == VK_PROCESSKEY) || (dwReturn & IPHK_HOTKEY) ) ) { 00172 ImmReleaseContext(hWnd, hIMC); 00173 return dwReturn; 00174 } 00175 00176 ImmTranslateMessage(hWnd, WM_KEYDOWN, VK_PROCESSKEY, lParam); 00177 dwReturn &= ~IPHK_PROCESSBYIME; 00178 dwReturn |= IPHK_SKIPTHISKEY; 00179 } 00180 } 00181 ImmReleaseContext(hWnd, hIMC); 00182 00183 return dwReturn; 00184 }

BOOL ImmSetActiveContext HWND  hWnd,
HIMC  hIMC,
BOOL  fFlag
 

Definition at line 309 of file w32/ntuser/imm/context.c.

Referenced by _InitializeImmEntryTable().

00313 { 00314 PCLIENTIMC pClientImc; 00315 PINPUTCONTEXT pInputContext; 00316 PIMEDPI pImeDpi; 00317 DWORD dwISC; 00318 HIMC hSaveImc; 00319 HWND hDefImeWnd; 00320 DWORD dwOpenStatus = 0; 00321 DWORD dwConversion = 0; 00322 #ifdef DEBUG 00323 PWND pWnd = ValidateHwnd(hWnd); 00324 00325 if (pWnd != NULL && GETPTI(pWnd) != PtiCurrent()) { 00326 RIPMSG1(RIP_WARNING, "hWnd (=%lx) is not of current thread.", hWnd); 00327 } 00328 #endif 00329 00330 if (!IS_IME_ENABLED()) { 00331 return FALSE; 00332 } 00333 00334 dwISC = ISC_SHOWUIALL; 00335 00336 pClientImc = ImmLockClientImc(hImc); 00337 00338 if (!fActivate) { 00339 if (pClientImc != NULL) 00340 ClrICF(pClientImc, IMCF_ACTIVE); 00341 goto NotifySetActive; 00342 } 00343 00344 if (hImc == NULL_HIMC) { 00345 hSaveImc = ImmGetSaveContext(hWnd, IGSC_DEFIMCFALLBACK); 00346 pInputContext = ImmLockIMC(hSaveImc); 00347 if (pInputContext != NULL) { 00348 pInputContext->hWnd = hWnd; 00349 ImmUnlockIMC(hSaveImc); 00350 } 00351 goto NotifySetActive; 00352 } 00353 00354 /* 00355 * Non-NULL input context, window handle have to be updated. 00356 */ 00357 if (pClientImc == NULL) 00358 return FALSE; 00359 00360 pInputContext = ImmLockIMC(hImc); 00361 if (pInputContext == NULL) { 00362 ImmUnlockClientImc(pClientImc); 00363 return FALSE; 00364 } 00365 00366 pInputContext->hWnd = hWnd; 00367 SetICF(pClientImc, IMCF_ACTIVE); 00368 00369 #ifdef LATER 00370 // Do uNumLangVKey checking later 00371 #endif 00372 00373 if (pInputContext->fdw31Compat & F31COMPAT_MCWHIDDEN) 00374 dwISC = ISC_SHOWUIALL - ISC_SHOWUICOMPOSITIONWINDOW; 00375 00376 dwOpenStatus = (DWORD)pInputContext->fOpen; 00377 dwConversion = pInputContext->fdwConversion; 00378 ImmUnlockIMC(hImc); 00379 00380 NotifySetActive: 00381 00382 pImeDpi = ImmLockImeDpi(GetKeyboardLayout(0)); 00383 if (pImeDpi != NULL) { 00384 (*pImeDpi->pfn.ImeSetActiveContext)(hImc, fActivate); 00385 ImmUnlockImeDpi(pImeDpi); 00386 } 00387 00388 /* 00389 * Notify UI 00390 */ 00391 if (IsWindow(hWnd)) { 00392 SendMessage(hWnd, WM_IME_SETCONTEXT, fActivate, dwISC); 00393 00394 /* 00395 * send notify to shell / keyboard driver 00396 */ 00397 if ( fActivate ) 00398 NtUserNotifyIMEStatus( hWnd, dwOpenStatus, dwConversion ); 00399 } 00400 else if (!fActivate) { 00401 /* 00402 * Because hWnd is not there (maybe destroyed), we send 00403 * WM_IME_SETCONTEXT to the default IME window. 00404 */ 00405 if ((hDefImeWnd = ImmGetDefaultIMEWnd(NULL)) != NULL) { 00406 SendMessage(hDefImeWnd, WM_IME_SETCONTEXT, fActivate, dwISC); 00407 } 00408 else { 00409 RIPMSG0(RIP_WARNING, 00410 "ImmSetActiveContext: can't send WM_IME_SETCONTEXT(FALSE)."); 00411 } 00412 } 00413 #ifdef DEBUG 00414 else { 00415 RIPMSG0(RIP_WARNING, 00416 "ImmSetActiveContext: can't send WM_IME_SETCONTEXT(TRUE)."); 00417 } 00418 #endif 00419 00420 #ifdef LATER 00421 // Implements ProcessIMCEvent() later. 00422 #endif 00423 00424 if (pClientImc != NULL) 00425 ImmUnlockClientImc(pClientImc); 00426 00427 return TRUE; 00428 }

BOOL ImmSetActiveContextConsoleIME HWND  hWnd,
BOOL  fFlag
 

Definition at line 188 of file ntuser/imm/conime.c.

References FALSE, hWnd, ImmGetContext(), ImmSetActiveContext(), and NULL_HIMC.

Referenced by ConsoleKillFocus(), ConsoleSetFocus(), and SetNLSMode().

00195 : 00196 00197 Set this context as active one. 00198 00199 Arguments: 00200 00201 hWnd - the get focus window 00202 fFlag - get focus or kill focus 00203 00204 Return Value: 00205 00206 --*/ 00207 00208 { 00209 HIMC hImc; 00210 00211 hImc = ImmGetContext(hWnd) ; 00212 if (hImc == NULL_HIMC) { 00213 return FALSE; 00214 } 00215 return(ImmSetActiveContext(hWnd, hImc, fFlag)) ; 00216 00217 }


Generated on Sat May 15 19:43:13 2004 for test by doxygen 1.3.7