提交 88ab4507 编写于 作者: D dmarkov

8139189: VK_OEM_102 dead key detected as VK_UNDEFINED

8160623: [PIT] Exception running java/awt/event/KeyEvent/KeyChar/KeyCharTest.java
Reviewed-by: alexsch, yan, prr
上级 4b9106ee
...@@ -256,6 +256,8 @@ AwtComponent::AwtComponent() ...@@ -256,6 +256,8 @@ AwtComponent::AwtComponent()
AwtComponent::BuildPrimaryDynamicTable(); AwtComponent::BuildPrimaryDynamicTable();
sm_PrimaryDynamicTableBuilt = TRUE; sm_PrimaryDynamicTableBuilt = TRUE;
} }
deadKeyActive = FALSE;
} }
AwtComponent::~AwtComponent() AwtComponent::~AwtComponent()
...@@ -2936,6 +2938,7 @@ static const CharToVKEntry charToDeadVKTable[] = { ...@@ -2936,6 +2938,7 @@ static const CharToVKEntry charToDeadVKTable[] = {
{0x037A, java_awt_event_KeyEvent_VK_DEAD_IOTA}, // ASCII ??? {0x037A, java_awt_event_KeyEvent_VK_DEAD_IOTA}, // ASCII ???
{0x309B, java_awt_event_KeyEvent_VK_DEAD_VOICED_SOUND}, {0x309B, java_awt_event_KeyEvent_VK_DEAD_VOICED_SOUND},
{0x309C, java_awt_event_KeyEvent_VK_DEAD_SEMIVOICED_SOUND}, {0x309C, java_awt_event_KeyEvent_VK_DEAD_SEMIVOICED_SOUND},
{0x0004, java_awt_event_KeyEvent_VK_COMPOSE},
{0,0} {0,0}
}; };
...@@ -3428,8 +3431,9 @@ UINT AwtComponent::WindowsKeyToJavaChar(UINT wkey, UINT modifiers, TransOps ops, ...@@ -3428,8 +3431,9 @@ UINT AwtComponent::WindowsKeyToJavaChar(UINT wkey, UINT modifiers, TransOps ops,
AwtToolkit::GetKeyboardState(keyboardState); AwtToolkit::GetKeyboardState(keyboardState);
// apply modifiers to keyboard state if necessary // apply modifiers to keyboard state if necessary
BOOL shiftIsDown = FALSE;
if (modifiers) { if (modifiers) {
BOOL shiftIsDown = modifiers & java_awt_event_InputEvent_SHIFT_DOWN_MASK; shiftIsDown = modifiers & java_awt_event_InputEvent_SHIFT_DOWN_MASK;
BOOL altIsDown = modifiers & java_awt_event_InputEvent_ALT_DOWN_MASK; BOOL altIsDown = modifiers & java_awt_event_InputEvent_ALT_DOWN_MASK;
BOOL ctrlIsDown = modifiers & java_awt_event_InputEvent_CTRL_DOWN_MASK; BOOL ctrlIsDown = modifiers & java_awt_event_InputEvent_CTRL_DOWN_MASK;
...@@ -3501,18 +3505,27 @@ UINT AwtComponent::WindowsKeyToJavaChar(UINT wkey, UINT modifiers, TransOps ops, ...@@ -3501,18 +3505,27 @@ UINT AwtComponent::WindowsKeyToJavaChar(UINT wkey, UINT modifiers, TransOps ops,
} // ctrlIsDown } // ctrlIsDown
} // modifiers } // modifiers
// instead of creating our own conversion tables, I'll let Win32
// convert the character for me.
WORD wChar[2]; WORD wChar[2];
UINT scancode = ::MapVirtualKey(wkey, 0); int converted = 1;
int converted = ::ToUnicodeEx(wkey, scancode, keyboardState, UINT ch = ::MapVirtualKey(wkey, 2);
wChar, 2, 0, GetKeyboardLayout()); if (ch & 0x80000000) {
// Dead key which is handled as a normal key
isDeadKey = deadKeyActive = TRUE;
} else if (deadKeyActive) {
// We cannot use ::ToUnicodeEx if dead key is active because this will
// break dead key function
wChar[0] = shiftIsDown ? ch : tolower(ch);
} else {
UINT scancode = ::MapVirtualKey(wkey, 0);
converted = ::ToUnicodeEx(wkey, scancode, keyboardState,
wChar, 2, 0, GetKeyboardLayout());
}
UINT translation; UINT translation;
BOOL deadKeyFlag = (converted == 2); BOOL deadKeyFlag = (converted == 2);
// Dead Key // Dead Key
if (converted < 0) { if (converted < 0 || isDeadKey) {
translation = java_awt_event_KeyEvent_CHAR_UNDEFINED; translation = java_awt_event_KeyEvent_CHAR_UNDEFINED;
} else } else
// No translation available -- try known conversions or else punt. // No translation available -- try known conversions or else punt.
...@@ -3666,6 +3679,8 @@ MsgRouting AwtComponent::WmIMEChar(UINT character, UINT repCnt, UINT flags, BOOL ...@@ -3666,6 +3679,8 @@ MsgRouting AwtComponent::WmIMEChar(UINT character, UINT repCnt, UINT flags, BOOL
MsgRouting AwtComponent::WmChar(UINT character, UINT repCnt, UINT flags, MsgRouting AwtComponent::WmChar(UINT character, UINT repCnt, UINT flags,
BOOL system) BOOL system)
{ {
deadKeyActive = FALSE;
// Will only get WmChar messages with DBCS if we create them for // Will only get WmChar messages with DBCS if we create them for
// an Edit class in the WmForwardChar method. These synthesized // an Edit class in the WmForwardChar method. These synthesized
// DBCS chars are ok to pass on directly to the default window // DBCS chars are ok to pass on directly to the default window
......
/* /*
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -820,6 +820,8 @@ private: ...@@ -820,6 +820,8 @@ private:
// 6524352: support finer-resolution // 6524352: support finer-resolution
int m_wheelRotationAmount; int m_wheelRotationAmount;
BOOL deadKeyActive;
/* /*
* The association list of children's IDs and corresponding components. * The association list of children's IDs and corresponding components.
* Some components like Choice or List are required their sizes while * Some components like Choice or List are required their sizes while
......
<!-- <!--
Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it This code is free software; you can redistribute it and/or modify it
...@@ -31,6 +31,8 @@ questions. ...@@ -31,6 +31,8 @@ questions.
Test run requires the following keyboard layouts to be installed: Test run requires the following keyboard layouts to be installed:
Linux OS: English (US, alternative international) Linux OS: English (US, alternative international)
Windows OS: Hungarian Windows OS: Hungarian
A keyboard layout having compose function or compose-like key. Programmer
Dvorak (http://www.kaufmann.no/roland/dvorak/) is suggested to use.
To test JDK-8000423 fix (Linux only!): To test JDK-8000423 fix (Linux only!):
please switch to US alternative international layout and try to type diacritics please switch to US alternative international layout and try to type diacritics
...@@ -40,6 +42,12 @@ To test JDK-7197619 fix (Windows only!): ...@@ -40,6 +42,12 @@ To test JDK-7197619 fix (Windows only!):
please switch to Hungarian keyboard layout and try to type diacritics please switch to Hungarian keyboard layout and try to type diacritics
(Ctrl+Alt+2 e; Ctrl+Alt+2 E) (Ctrl+Alt+2 e; Ctrl+Alt+2 E)
To test JDK-8139189 fix:
please switch to Programmer Dvorak keyboard layout try to type diacritics
using compose combinations (Compose+z+d, Compose+z+Shift+d). The Compose key
in Programmer Dvorak layout is OEM102 the key which is located between
Left Shift and Z keys on the standard 102-key keyboard.
If you can do that then the test is passed; otherwise failed. If you can do that then the test is passed; otherwise failed.
</body> </body>
</html> </html>
...@@ -32,7 +32,7 @@ import sun.awt.SunToolkit; ...@@ -32,7 +32,7 @@ import sun.awt.SunToolkit;
/* /*
* @test * @test
* @bug 8022401 * @bug 8022401 8160623
* @summary Wrong key char * @summary Wrong key char
* @author Alexandr Scherbatiy * @author Alexandr Scherbatiy
* @run main KeyCharTest * @run main KeyCharTest
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册