SUGGESTED FIX
*** /export/bino/mantis/webrev/src/windows/native/sun/windows/awt_Component.cpp- Wed Nov 6 19:31:04 2002
--- awt_Component.cpp Wed Nov 6 19:08:05 2002
*** 3055,3065 ****
return (LOWORD(GetKeyboardLayout(0)) == MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT))
&& (GetKeyboardType(0) == 7);
}
void AwtComponent::JavaKeyToWindowsKey(UINT javaKey,
! UINT *windowsKey, UINT *modifiers)
{
// Handle the few cases where a Java VK code corresponds to a Windows
// key/modifier combination or applies only to specific keyboard layouts
switch (javaKey) {
case java_awt_event_KeyEvent_VK_ALL_CANDIDATES:
--- 3055,3065 ----
return (LOWORD(GetKeyboardLayout(0)) == MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT))
&& (GetKeyboardType(0) == 7);
}
void AwtComponent::JavaKeyToWindowsKey(UINT javaKey,
! UINT *windowsKey, UINT *modifiers, UINT originalWindowsKey)
{
// Handle the few cases where a Java VK code corresponds to a Windows
// key/modifier combination or applies only to specific keyboard layouts
switch (javaKey) {
case java_awt_event_KeyEvent_VK_ALL_CANDIDATES:
*** 3089,3105 ****
--- 3089,3127 ----
*modifiers = 0;
return;
}
}
+ // Bug 4766655
+ // Two Windows keys could map to the same Java key, so
+ // give preference to the originalWindowsKey if it is
+ // specifed (not IGNORE_KEY).
+ if (originalWindowsKey == IGNORE_KEY) {
for (int j = 0; dynamicKeyMapTable[j].windowsKey != 0; j++) {
if (dynamicKeyMapTable[j].javaKey == javaKey) {
*windowsKey = dynamicKeyMapTable[j].windowsKey;
*modifiers = 0;
return;
}
}
+ }
+ else {
+ BOOL found = false;
+ for (int j = 0; dynamicKeyMapTable[j].windowsKey != 0; j++) {
+ if (dynamicKeyMapTable[j].javaKey == javaKey) {
+ *windowsKey = dynamicKeyMapTable[j].windowsKey;
+ *modifiers = 0;
+ found = true;
+ if (*windowsKey == originalWindowsKey) {
+ return; /* if ideal case found return, else keep looking */
+ }
+ }
+ }
+ if (found) {
+ return;
+ }
+ }
*windowsKey = 0;
*modifiers = 0;
return;
}
*** 6287,6297 ****
break;
}
if (keyCode != java_awt_event_KeyEvent_VK_UNDEFINED) {
UINT newWinKey, ignored;
! p->JavaKeyToWindowsKey(keyCode, &newWinKey, &ignored);
if (newWinKey != 0) {
winKey = newWinKey;
}
}
--- 6309,6319 ----
break;
}
if (keyCode != java_awt_event_KeyEvent_VK_UNDEFINED) {
UINT newWinKey, ignored;
! p->JavaKeyToWindowsKey(keyCode, &newWinKey, &ignored, winKey);
if (newWinKey != 0) {
winKey = newWinKey;
}
}
*** /export/bino/mantis/webrev/src/windows/native/sun/windows/awt_Component.h- Wed Nov 6 19:31:06 2002
--- awt_Component.h Wed Nov 6 19:25:00 2002
*** 394,404 ****
static void InitDynamicKeyMapTable();
static void BuildDynamicKeyMapTable();
static jint GetJavaModifiers();
static jint GetButton(int mouseButton);
static UINT WindowsKeyToJavaKey(UINT windowsKey, UINT modifiers);
! static void JavaKeyToWindowsKey(UINT javaKey, UINT *windowsKey, UINT *modifiers);
UINT WindowsKeyToJavaChar(UINT wkey, UINT modifiers);
/* routines used for input method support */
void SetInputMethod(jobject im, BOOL useNativeCompWindow);
static int GetContextData(HIMC hIMC, DWORD dwIndex, LPVOID* lplpData);
--- 394,411 ----
static void InitDynamicKeyMapTable();
static void BuildDynamicKeyMapTable();
static jint GetJavaModifiers();
static jint GetButton(int mouseButton);
static UINT WindowsKeyToJavaKey(UINT windowsKey, UINT modifiers);
! static void JavaKeyToWindowsKey(UINT javaKey, UINT *windowsKey, UINT *modifiers, UINT originalWindowsKey);
!
! INLINE static void AwtComponent::JavaKeyToWindowsKey(UINT javaKey,
! UINT *windowsKey, UINT *modifiers)
! {
! JavaKeyToWindowsKey(javaKey, windowsKey, modifiers, IGNORE_KEY);
! }
!
UINT WindowsKeyToJavaChar(UINT wkey, UINT modifiers);
/* routines used for input method support */
void SetInputMethod(jobject im, BOOL useNativeCompWindow);
static int GetContextData(HIMC hIMC, DWORD dwIndex, LPVOID* lplpData);
|