jfx icon indicating copy to clipboard operation
jfx copied to clipboard

DRAFT 8273743: KeyCharacterCombination for "+" does not work on US QWERTY keyboard layout

Open beldenfox opened this issue 4 years ago • 9 comments

There was a mismatch between the way get_glass_key generated the Java key code for a given key press and how getKeyCodeForChar determined the key code for the matching character. For example, when pressing the plus sign on a US keyboard get_glass_key correctly generated KeyCode.EQUALS but getKeyCodeForChar("+") generated KeyCode.PLUS.

In this PR getKeyCodeForChar mirrors the behavior of get_glass_key; it determines which key the character lies on and generates a key code based on the unshifted character on the same key.

I'm working on a more comprehensive test case that allows you to press any key on the keyboard and test whether a KeyCharacterCombination for that character will succeed or not. I've attached it to this thread. It might be worth submitting as a manual test case CharComboTest.txt .


Progress

  • [x] Change must not contain extraneous whitespace
  • [ ] Commit message must refer to an issue
  • [ ] Change must be properly reviewed

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jfx pull/635/head:pull/635
$ git checkout pull/635

Update a local copy of the PR:
$ git checkout pull/635
$ git pull https://git.openjdk.java.net/jfx pull/635/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 635

View PR using the GUI difftool:
$ git pr show -t 635

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jfx/pull/635.diff

beldenfox avatar Sep 28 '21 21:09 beldenfox

:wave: Welcome back beldenfox! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

bridgekeeper[bot] avatar Sep 28 '21 21:09 bridgekeeper[bot]

Webrevs

mlbridge[bot] avatar Sep 28 '21 21:09 mlbridge[bot]

/reviewers 2

kevinrushforth avatar Sep 29 '21 11:09 kevinrushforth

@kevinrushforth The number of required reviews for this PR is now set to 2 (with at least 1 of role reviewers).

openjdk[bot] avatar Sep 29 '21 11:09 openjdk[bot]

As you recommended in the description, could you please add the attached test as part of PR as manual test which fails before the fix and passes with the fix?

pankaj-bansal avatar Nov 09 '21 06:11 pankaj-bansal

The changes look fine. I ran the full system test and I do not see any regression being introduced because of this change. The manual test attached fails for all keys before the change. With the change, the test passes for most of the keys, but fails for following 3 keys

  • Failed: key code Comma did not match Shift+<
  • Failed: key code Comma did not match Shift+<
  • Failed: key code Comma did not match Shift+<
  • Failed: key code Comma did not match Shift+<
  • Failed: key code 0 did not match Shift+)
  • Failed: key code 0 did not match Shift+)
  • Failed: key code 0 did not match Shift+)
  • Failed: key code 9 did not match Shift+(
  • Failed: key code 9 did not match Shift+(
  • Failed: key code 9 did not match Shift+(

pankaj-bansal avatar Dec 05 '21 08:12 pankaj-bansal

Gdk is finding these three characters (comma, left paren, right paren) on the main keyboard using the Shift modifier and on the keypad without Shift. Presumably there are keyboards out there which have some or all of these characters on the keypad and those keys were incorporated into the US keymap (but not French, Russian, or German). Most keys on the keypad have distinct keyvals but not these, they share the same keyvals as the keys on the main keyboard.

I'll continue to investigate but this just reinforces my conviction that KeyCharacterCombination should be re-engineered. The current approach requires mapping backward from a character to a key which is difficult to do on every platform except Windows (where it's still tricky, see #672) and the requirement that each character maps to just one key is inherently limiting.

beldenfox avatar Dec 06 '21 01:12 beldenfox

I can map from a character to a key but I haven’t found any way of verifying that the key is actually on the user’s keyboard. I can’t even filter them out as keypad keys, their XkbKeyTypeIndex puts them in the same class as the Space bar.

I’ve amended the PR to approach this the same way the Mac does. As the user types we query the key to determine which characters it can generate and stash them in a map. In getKeyCodeForChar we consult that map to answer the question.

This means both the Mac and Linux would be using the same brute force hack to get around the limitations of getKeyCodeForChar. I think it’s time for it to go. I’ve entered an alternate PR #694 that paves the way for retiring that call and replacing it with one that’s much easier to get right on all platforms. I would prefer to close this PR and focus on that one. Life is short.

beldenfox avatar Dec 13 '21 19:12 beldenfox

I marked this as draft in hopes that #694 goes through instead. The review cycles were useful as very similar code is in #694 and will be needed to address JDK-8278924.

beldenfox avatar Dec 17 '21 18:12 beldenfox

@beldenfox This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 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!

bridgekeeper[bot] avatar Mar 31 '23 23:03 bridgekeeper[bot]

@beldenfox This pull request has been inactive for more than 16 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the /open pull request command.

bridgekeeper[bot] avatar May 27 '23 02:05 bridgekeeper[bot]