jfx icon indicating copy to clipboard operation
jfx copied to clipboard

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

Open beldenfox opened this issue 1 year ago • 17 comments

On Linux getKeyCodeForChar does not consult the current keyboard layout. For example, it assumes the “+” character is on KeyCode.PLUS even on layouts which don’t generate KeyCode.PLUS. The result is that most KeyCharacterCombinations don’t work.

This PR fixes this using the same approach that Mac glass uses. When the user types a key we lookup all the characters that key might generate and put them in a map. getKeyCodeForChar then consults the map to find the Java key code. This ensures that we only pay attention to keys that are on the user’s physical keyboard.

(Some Linux layout maps are expansive and include entries for keys that may be on the user’s keyboard but probably aren’t, like “(“ and “)” on the numeric keypad. If we simply ask for all entries that generate a given character we can get multiple hits with no good way to determine which ones are physically present.)

This PR also contains fixes to the Robot to enable testing. When Glass consults the GdkKeymap to determine which keys might generate a keyval GDK returns a list covering every installed layout and shift level. The old Glass code simply picked the first entry in the list. This PR iterates through the list looking for one that works for the current layout and correct shift level.


Progress

  • [x] Change must not contain extraneous whitespace
  • [x] Commit message must refer to an issue
  • [ ] Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

  • JDK-8273743: KeyCharacterCombination for "+" does not work on US QWERTY keyboard layout (Bug - P3)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1373/head:pull/1373
$ git checkout pull/1373

Update a local copy of the PR:
$ git checkout pull/1373
$ git pull https://git.openjdk.org/jfx.git pull/1373/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1373

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1373.diff

Webrev

Link to Webrev Comment

beldenfox avatar Feb 20 '24 18:02 beldenfox

:wave: Welcome back mfox! 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 Feb 20 '24 18:02 bridgekeeper[bot]

Webrevs

mlbridge[bot] avatar Feb 20 '24 18:02 mlbridge[bot]

/reviewers 2

kevinrushforth avatar Feb 21 '24 15:02 kevinrushforth

@kevinrushforth The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

openjdk[bot] avatar Feb 21 '24 15:02 openjdk[bot]

❗ This change is not yet ready to be integrated. See the Progress checklist in the description for automated requirements.

openjdk[bot] avatar Mar 13 '24 20:03 openjdk[bot]

@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!

bridgekeeper[bot] avatar Apr 10 '24 21:04 bridgekeeper[bot]

Comment added to keep the bots at bay.

beldenfox avatar Apr 10 '24 23:04 beldenfox

@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!

bridgekeeper[bot] avatar May 09 '24 01:05 bridgekeeper[bot]

I've updated to the latest master. This will probably be the last time I refresh this pull request; I can only hold off the bots for so long.

beldenfox avatar May 14 '24 23:05 beldenfox

In the context of the recent discussion on the mailing list, would it be possible to actually detect the keyboard layout? There is a limited number of layouts, so in theory that should be possible.

Another question - I recall on Windows there is a way to enter certain key using Alt codes. Does this method exist on Linux?

andy-goryachev-oracle avatar May 15 '24 21:05 andy-goryachev-oracle

In the context of the recent discussion on the mailing list, would it be possible to actually detect the keyboard layout?

I answered this question in full on the mailing list but will provide a summary here. There's no documented way of doing this on Windows. The Mac organizes layouts based on language (for example, English), Linux organizes them based on country (so Australia, Great Britain, and the U.S. are all distinct). On all platforms there are more layouts than you think (the Mac has 5 German layouts and Linux has 20 Germany layouts) and there's no standard on how the variants are designated.

Another question - I recall on Windows there is a way to enter certain key using Alt codes. Does this method exist on Linux?

I'm not that familiar with this feature but here's my understanding. The feature isn't universal but tied to the input method system you're using. With IBus you can press Shift+Ctrl+U followed by the Unicode value followed by Enter. But if you want to use an IME with JavaFX you have to use the obsolete XIM framework instead which doesn't support this.

beldenfox avatar May 17 '24 15:05 beldenfox

@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!

bridgekeeper[bot] avatar Jun 14 '24 16:06 bridgekeeper[bot]

@beldenfox This pull request has been inactive for more than 8 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 Jul 16 '24 16:07 bridgekeeper[bot]

I think this PR should be reopened.

andy-goryachev-oracle avatar Jul 16 '24 16:07 andy-goryachev-oracle

/open

beldenfox avatar Jul 22 '24 17:07 beldenfox

@beldenfox This pull request is now open

openjdk[bot] avatar Jul 22 '24 17:07 openjdk[bot]

@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!

bridgekeeper[bot] avatar Aug 19 '24 20:08 bridgekeeper[bot]