On Wed, 12 Jan 2022 20:45:02 GMT, Martin Fox <d...@openjdk.org> wrote:
>> When processing a `WM_CHAR` event on an OEM key (punctuation, symbol, dead >> key) the glass code will dynamically query the key's unshifted character to >> determine the Java code to assign to it. This is necessary since the >> relationship between OEM key codes and the characters they generate varies >> from layout to layout. >> >> The Robot implementation was consulting a table which assumed a fixed >> relationship between Java codes and Windows key codes even for the OEM keys. >> The table was also missing entries for any Java code not on a US QWERTY >> layout, like PLUS. >> >> In this PR if we don't find the Java code in the table or if it maps to an >> OEM key (which may be wrong) we sweep through all the OEM keys looking for >> the matching Java code. > > Martin Fox has updated the pull request incrementally with one additional > commit since the last revision: > > A Robot now correctly handles KeyCodes that aren't in the current layout PR looks good and works fine on Windows 11. I've tested the test attached to the JBS issue with a Spanish keyboard. It fails without the patch for `+`, `'`, `ยก`, and passes with it. There is a NPE if you press AltGr (with or without the patch): Exception in thread "JavaFX Application Thread" java.lang.NullPointerException: keyCode must not be null at java.base/java.util.Objects.requireNonNull(Objects.java:233) at javafx.graphics@21-internal/javafx.scene.robot.Robot.keyPress(Robot.java:92) at RobotKeySanityTest.lambda$userReleasedEvent$0(RobotKeySanityTest.java:121) ``` I wonder if RobotKeySanityTest could be part of the PR as a manual test? Same as in #694 modules/javafx.graphics/src/main/native-glass/win/KeyTable.cpp line 188: > 186: } > 187: > 188: static UINT const oemKeys[] = { update license header copyright modules/javafx.graphics/src/main/native-glass/win/KeyTable.h line 32: > 30: void JavaKeyToWindowsKey(jint jkey, UINT &vkey, UINT &modifiers); > 31: BOOL IsExtendedKey(UINT vkey); > 32: jint OEMCharToJavaKey(UINT ch, bool deadKey); update license header copyright modules/javafx.graphics/src/main/native-glass/win/ViewContainer.cpp line 409: > 407: if (unicodeConverted < 0) { > 408: // Dead key > 409: switch (wChar[0]) { update license header copyright ------------- PR Review: https://git.openjdk.org/jfx/pull/702#pullrequestreview-1374678712 PR Review Comment: https://git.openjdk.org/jfx/pull/702#discussion_r1159677954 PR Review Comment: https://git.openjdk.org/jfx/pull/702#discussion_r1159678087 PR Review Comment: https://git.openjdk.org/jfx/pull/702#discussion_r1159678139