-
Notifications
You must be signed in to change notification settings - Fork 473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8278938: [Win] Robot can target wrong key for punctuation and symbols #702
Conversation
👋 Welcome back beldenfox! A progress list of the required criteria for merging this PR into |
Webrevs
|
/reviewers 2 |
@kevinrushforth |
@beldenfox This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
@andy-goryachev-oracle or @jperedadnr would one of you also be able to review this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -185,18 +185,134 @@ jint WindowsKeyToJavaKey(UINT wKey) | |||
return com_sun_glass_events_KeyEvent_VK_UNDEFINED; | |||
} | |||
|
|||
void JavaKeyToWindowsKey(jint jkey, UINT &vkey, UINT &modifiers) | |||
static UINT const oemKeys[] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update license header copyright
@@ -29,5 +29,5 @@ | |||
jint WindowsKeyToJavaKey(UINT wKey); | |||
void JavaKeyToWindowsKey(jint jkey, UINT &vkey, UINT &modifiers); | |||
BOOL IsExtendedKey(UINT vkey); | |||
|
|||
jint OEMCharToJavaKey(UINT ch, bool deadKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update license header copyright
@@ -406,65 +406,9 @@ void ViewContainer::HandleViewKeyEvent(HWND hwnd, UINT msg, WPARAM wParam, LPARA | |||
case 0x00E2:// VK_OEM_102 | |||
if (unicodeConverted < 0) { | |||
// Dead key | |||
switch (wChar[0]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update license header copyright
The RobotKeySanityTest is tricky, it requires the user to press a lot of keys to get good coverage but can produce confusing results if the user presses certain keys, like AltGr. Windows treats AltGr as if you pressed Ctrl and Alt at the same time. This means the OS sends two events when you press the key and two more when you release it. This is confusing the RobotKeySanityTest which can only handle one press/release pair at a time. I'm not sure I can fix the test but will think about it. The KeyboardTest app that I recently added to PR #425 covers most of the same ground and avoids the problematic keys. The downside of KeyboardTest is that it only provides good coverage for specific layouts (I'll try to add Spanish) and provides the best coverage when run against multiple layouts which takes effort to set up. I've written an app that just logs key events as the user types and that would probably be a better candidate to attach to some PR. When something confusing happens with RobotKeySanityTest or KeyboardTest that's the app I pull up to diagnose what's going on (like I just did with AltGr). |
Okay, makes sense. I'll approve this PR as is then, if you modify it for any reason, I'll review again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code changes look fine to me. I do have two minor points about code style.
- Please enclose all single-line targets of
if
, etc., with curly braces. - I also recommend (but do not insist), that the opening curly brace the target block of
if
, etc., be on the same line as theif
.
We aren't quite as rigorous on code style in native code, but for code that isn't third-party, consistency is a good thing.
if (oemKeys[i] == vkey) | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please enclose this in curly braces (or move the return true;
to be on the same line as the if
).
if (jkey == com_sun_glass_events_KeyEvent_VK_UNDEFINED) | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same.
@beldenfox One more comment: since your branch is quite out of date, can you please merge in the latest upstream master? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
@beldenfox This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 2 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@jperedadnr, @kevinrushforth) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
/integrate |
@beldenfox |
/sponsor |
Going to push as commit 3d6f328.
Your commit was automatically rebased without conflicts. |
@kevinrushforth @beldenfox Pushed as commit 3d6f328. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
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.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/702/head:pull/702
$ git checkout pull/702
Update a local copy of the PR:
$ git checkout pull/702
$ git pull https://git.openjdk.org/jfx.git pull/702/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 702
View PR using the GUI difftool:
$ git pr show -t 702
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/702.diff
Webrev
Link to Webrev Comment