RFR: 8278924: [Linux] Robot key test can fail if multiple keyboard layouts are installed
Martin Fox
duke at openjdk.org
Sun Apr 2 23:39:27 UTC 2023
On Sun, 2 Apr 2023 22:49:51 GMT, Thiago Milczarek Sayao <tsayao at openjdk.org> wrote:
>> The Robot implementation on Linux did not consult the current layout when mapping from a KeyCode to a hardware code. Internally it retrieved results for all the layouts but just picked the first one it saw leading to random effects. Though not part of the original bug report, the code also ignored the shift level when choosing which result to pick. On a French layout the dollar sign is on two keys (AltGr 4 is the second one) and the code could choose either one. Same is true for pound.
>>
>> This PR consults the current layout and only on shift level 0 which is the same level used in get_glass_key to figure out which KeyCode to assign when generating a KeyEvent.
>
> @beldenfox Could you point out which tests were failing?
> `test.robot.javafx.embed.swing.SwingNodeJDialogTest` is getting stuck for me.
@tsayao The best place to start is with the manual test that I added to PR #425 (KeyboardTest.java). That test works on Windows, Mac, and Linux and uses a Robot to throw a whole slew of platform key events at the system and then verify that the right JavaFX KeyEvents come through on the other side.
The primary motivation for this PR is to pave the way for future PR's. Accelerators involving punctuation and symbols aren't working at all well on Linux (see [JDK-8273743](https://bugs.openjdk.org/browse/JDK-8273743)) and having a working Robot in hand will be extremely helpful in testing the fixes. The manual test in #425 can also be configured to test KeyCharacterCombinations (the component that's broken) but for now you can ignore all that.
Unfortunately the manual test itself is a big chunk of code that needs to be reviewed but it is the first comprehensive test written for JavaFX keyboard handling. I wish I could make it shorter (it looks more complicated than it is) but the only way to test the keyboard system is to press a lot of keys.
BTW, the bot that kicked this PR has lousy timing. I'll be out of town for most of the coming week and will be away from my Linux box.
-------------
PR Comment: https://git.openjdk.org/jfx/pull/718#issuecomment-1493468548
More information about the openjfx-dev
mailing list