src/windows/native/sun/windows/awt_Component.cpp
Print this page
*** 3142,3152 ****
*windowsKey = 0;
*modifiers = 0;
return;
}
! UINT AwtComponent::WindowsKeyToJavaKey(UINT windowsKey, UINT modifiers)
{
// Handle the few cases where we need to take the modifier into
// consideration for the Java VK code or where we have to take the keyboard
// layout into consideration so that function keys can get
// recognized in a platform-independent way.
--- 3142,3153 ----
*windowsKey = 0;
*modifiers = 0;
return;
}
! UINT AwtComponent::WindowsKeyToJavaKey(UINT windowsKey, UINT modifiers, UINT character, BOOL isDeadKey)
!
{
// Handle the few cases where we need to take the modifier into
// consideration for the Java VK code or where we have to take the keyboard
// layout into consideration so that function keys can get
// recognized in a platform-independent way.
*** 3169,3178 ****
--- 3170,3188 ----
return java_awt_event_KeyEvent_VK_KANA_LOCK;
}
break;
};
+ // check dead key
+ if(isDeadKey){
+ for (int i = 0; charToDeadVKTable[i].c != 0; i++) {
+ if (charToDeadVKTable[i].c == character) {
+ return charToDeadVKTable[i].javaKey;
+ }
+ }
+ }
+
// for the general case, use a bi-directional table
for (int i = 0; keyMapTable[i].windowsKey != 0; i++) {
if (keyMapTable[i].windowsKey == windowsKey) {
return keyMapTable[i].javaKey;
}
*** 3382,3409 ****
dynPrimaryKeymap[wkey].jkey = jkeyLegacy;
}
}
}
! UINT AwtComponent::WindowsKeyToJavaChar(UINT wkey, UINT modifiers, TransOps ops)
{
static Hashtable transTable("VKEY translations");
// Try to translate using last saved translation
if (ops == LOAD) {
void* value = transTable.remove(reinterpret_cast<void*>(static_cast<INT_PTR>(wkey)));
if (value != NULL) {
! return static_cast<UINT>(reinterpret_cast<INT_PTR>(value));
}
}
// If the windows key is a return, wkey will equal 13 ('\r')
// In this case, we want to return 10 ('\n')
// Since ToAscii would convert VK_RETURN to '\r', we need
// to have a special case here.
! if (wkey == VK_RETURN)
! return '\n';
// high order bit in keyboardState indicates whether the key is down
static const BYTE KEY_STATE_DOWN = 0x80;
BYTE keyboardState[AwtToolkit::KB_STATE_SIZE];
AwtToolkit::GetKeyboardState(keyboardState);
--- 3392,3426 ----
dynPrimaryKeymap[wkey].jkey = jkeyLegacy;
}
}
}
! void AwtComponent::WindowsKeyToJavaChar(UINT wkey, UINT modifiers, TransOps ops, UINT *character, BOOL *isDeadKey)
{
static Hashtable transTable("VKEY translations");
+ static Hashtable deadKeyFlagTable("Dead Key Flags");
+ *isDeadKey = FALSE;
// Try to translate using last saved translation
if (ops == LOAD) {
void* value = transTable.remove(reinterpret_cast<void*>(static_cast<INT_PTR>(wkey)));
+ void* deadKeyFlag = deadKeyFlagTable.remove(reinterpret_cast<void*>(static_cast<INT_PTR>(wkey)));
if (value != NULL) {
! *character = static_cast<UINT>(reinterpret_cast<INT_PTR>(value));
! *isDeadKey = static_cast<UINT>(reinterpret_cast<BOOL>(deadKeyFlag));
! return;
}
}
// If the windows key is a return, wkey will equal 13 ('\r')
// In this case, we want to return 10 ('\n')
// Since ToAscii would convert VK_RETURN to '\r', we need
// to have a special case here.
! if (wkey == VK_RETURN){
! *character= '\n';
! return;
! }
// high order bit in keyboardState indicates whether the key is down
static const BYTE KEY_STATE_DOWN = 0x80;
BYTE keyboardState[AwtToolkit::KB_STATE_SIZE];
AwtToolkit::GetKeyboardState(keyboardState);
*** 3488,3497 ****
--- 3505,3515 ----
UINT scancode = ::MapVirtualKey(wkey, 0);
int converted = ::ToAsciiEx(wkey, scancode, keyboardState,
&mbChar, 0, GetKeyboardLayout());
UINT translation;
+ BOOL deadKeyFlag = (converted == 2);
// Dead Key
if (converted < 0) {
translation = java_awt_event_KeyEvent_CHAR_UNDEFINED;
} else
*** 3515,3526 ****
translation = unicodeChar[0];
}
if (ops == SAVE) {
transTable.put(reinterpret_cast<void*>(static_cast<INT_PTR>(wkey)),
reinterpret_cast<void*>(static_cast<INT_PTR>(translation)));
}
! return translation;
}
MsgRouting AwtComponent::WmKeyDown(UINT wkey, UINT repCnt,
UINT flags, BOOL system)
{
--- 3533,3549 ----
translation = unicodeChar[0];
}
if (ops == SAVE) {
transTable.put(reinterpret_cast<void*>(static_cast<INT_PTR>(wkey)),
reinterpret_cast<void*>(static_cast<INT_PTR>(translation)));
+ deadKeyFlagTable.put(reinterpret_cast<void*>(static_cast<INT_PTR>(wkey)),
+ reinterpret_cast<void*>(static_cast<INT_PTR>(deadKeyFlag)));
}
!
! *character = translation;
! *isDeadKey = deadKeyFlag;
! return;
}
MsgRouting AwtComponent::WmKeyDown(UINT wkey, UINT repCnt,
UINT flags, BOOL system)
{
*** 3535,3546 ****
InitMessage(&msg, (system ? WM_SYSKEYDOWN : WM_KEYDOWN),
wkey, MAKELPARAM(repCnt, flags));
UINT modifiers = GetJavaModifiers();
jint keyLocation = GetKeyLocation(wkey, flags);
! UINT jkey = WindowsKeyToJavaKey(wkey, modifiers);
! UINT character = WindowsKeyToJavaChar(wkey, modifiers, SAVE);
UpdateDynPrimaryKeymap(wkey, jkey, keyLocation, modifiers);
SendKeyEventToFocusOwner(java_awt_event_KeyEvent_KEY_PRESSED,
TimeHelper::windowsToUTC(msg.time), jkey, character,
--- 3558,3571 ----
InitMessage(&msg, (system ? WM_SYSKEYDOWN : WM_KEYDOWN),
wkey, MAKELPARAM(repCnt, flags));
UINT modifiers = GetJavaModifiers();
jint keyLocation = GetKeyLocation(wkey, flags);
! BOOL isDeadKey = FALSE;
! UINT character;
! WindowsKeyToJavaChar(wkey, modifiers, SAVE, &character, &isDeadKey);
! UINT jkey = WindowsKeyToJavaKey(wkey, modifiers, character, isDeadKey);
UpdateDynPrimaryKeymap(wkey, jkey, keyLocation, modifiers);
SendKeyEventToFocusOwner(java_awt_event_KeyEvent_KEY_PRESSED,
TimeHelper::windowsToUTC(msg.time), jkey, character,
*** 3577,3588 ****
InitMessage(&msg, (system ? WM_SYSKEYUP : WM_KEYUP),
wkey, MAKELPARAM(repCnt, flags));
UINT modifiers = GetJavaModifiers();
jint keyLocation = GetKeyLocation(wkey, flags);
! UINT jkey = WindowsKeyToJavaKey(wkey, modifiers);
! UINT character = WindowsKeyToJavaChar(wkey, modifiers, LOAD);
UpdateDynPrimaryKeymap(wkey, jkey, keyLocation, modifiers);
SendKeyEventToFocusOwner(java_awt_event_KeyEvent_KEY_RELEASED,
TimeHelper::windowsToUTC(msg.time), jkey, character,
modifiers, keyLocation, (jlong)wkey, &msg);
--- 3602,3615 ----
InitMessage(&msg, (system ? WM_SYSKEYUP : WM_KEYUP),
wkey, MAKELPARAM(repCnt, flags));
UINT modifiers = GetJavaModifiers();
jint keyLocation = GetKeyLocation(wkey, flags);
! BOOL isDeadKey = FALSE;
! UINT character;
! WindowsKeyToJavaChar(wkey, modifiers, LOAD, &character, &isDeadKey);
! UINT jkey = WindowsKeyToJavaKey(wkey, modifiers, character, isDeadKey);
UpdateDynPrimaryKeymap(wkey, jkey, keyLocation, modifiers);
SendKeyEventToFocusOwner(java_awt_event_KeyEvent_KEY_RELEASED,
TimeHelper::windowsToUTC(msg.time), jkey, character,
modifiers, keyLocation, (jlong)wkey, &msg);
*** 5626,5636 ****
if (newWinKey != 0) {
winKey = newWinKey;
}
}
! modifiedChar = p->WindowsKeyToJavaChar(winKey, modifiers, AwtComponent::NONE);
bCharChanged = (keyChar != modifiedChar);
}
break;
case java_awt_event_KeyEvent_KEY_RELEASED:
--- 5653,5666 ----
if (newWinKey != 0) {
winKey = newWinKey;
}
}
! BOOL isDeadKey = FALSE;
! UINT character;
! p->WindowsKeyToJavaChar(winKey, modifiers, AwtComponent::NONE, &character, &isDeadKey);
! modifiedChar = character;
bCharChanged = (keyChar != modifiedChar);
}
break;
case java_awt_event_KeyEvent_KEY_RELEASED: