RFR: 8150709: Mac OSX and German Keyboard Layout (Y/Z) [v10]

Andy Goryachev angorya at openjdk.org
Thu Apr 20 23:56:00 UTC 2023


On Thu, 20 Apr 2023 23:33:03 GMT, Martin Fox <duke at openjdk.org> wrote:

>> This PR adds code to ensure that KeyCodeCombinations match KeyEvents as expected by more accurately mapping from a Mac key code to a Java key code based on the user’s active keyboard layout (the existing code assumes a US QWERTY layout). The new code first identifies a set of Mac keys which can produce different characters based on the user’s keyboard layout. A Mac key code outside that area is processed exactly as before. For a key inside the layout-sensitive area the code calls UCKeyTranslate to translate the key to an unshifted ASCII character based on the active keyboard and uses that to determine the Java key code.
>> 
>> When performing the reverse mapping for the Robot the code first uses the old QWERTY mapping to find a candidate key. If it lies in the layout-sensitive area the code then scans the entire area calling UCKeyTranslate until it finds a match. If the key lies outside the layout-sensitive area it’s processed exactly as before.
>> 
>> There are multiple duplicates of these bugs logged against Mac applications built with JavaFX.
>> 
>> https://bugs.openjdk.java.net/browse/JDK-8090257 Mac: Inconsistent KeyEvents with alternative keyboard layouts
>> https://bugs.openjdk.java.net/browse/JDK-8088120 [Accelerator, Mac] CMD + Z accelerator is not working with French keyboard
>> https://bugs.openjdk.java.net/browse/JDK-8087915 Mac: accelerator doesn't take into account azerty keyboard layout
>> https://bugs.openjdk.java.net/browse/JDK-8150709 Mac OSX and German Keyboard Layout (Y/Z)
>
> Martin Fox has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 10 additional commits since the last revision:
> 
>  - Merge remote-tracking branch 'upstream/master' into macshortcut
>  - Coding style consistency (mostly)
>  - Added Spanish to KeyboardTest and fixed related bug. Changes based on review feedback.
>  - Added manual cross-platform keyboard handling test
>  - Bug fixes in Robot. Ensure symbols uncovered using Option are ignored.
>  - Merge branch 'master' into macshortcut
>  - Fixed whitespace error.
>  - A small number of keyboard layouts require the Option key to reach
>    critical letters like 'Q'. Added a third probe (after Command and
>    Shift+Command) to look for letters that require Option. The
>    keyboards in question are Azeri, Turkmen, and the Sami layouts.
>  - The code now queries both the shifted and unshifted characters for a key
>    favoring digits and letters over everything else. This ensures we catch
>    the digits on the French layout without interfering with Dvorak.
>  - Mac - generate KeyCodes that match user's active keyboard layout.

This PR also needs the following code added to manualTests-events/.classpath, otherwise it would not compile in Eclipse.
(for convenience, showing the whole file):


<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry combineaccessrules="false" kind="src" path="/base">
		<attributes>
			<attribute name="module" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry combineaccessrules="false" kind="src" path="/graphics">
		<attributes>
			<attribute name="module" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry combineaccessrules="false" kind="src" path="/controls">
		<attributes>
			<attribute name="module" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
		<attributes>
			<attribute name="module" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry excluding=".classpath|.project|.settings" kind="src" output="bin" path=""/>
	<classpathentry kind="output" path="bin"/>
</classpath>

tests/manual/events/KeyboardTest.java line 26:

> 24:  */
> 25: 
> 26: import java.util.ArrayList;

would it make sense to avoid using the default package?
also perhaps move the tests to ./src?

-------------

PR Comment: https://git.openjdk.org/jfx/pull/425#issuecomment-1517069347
PR Review Comment: https://git.openjdk.org/jfx/pull/425#discussion_r1173183156


More information about the openjfx-dev mailing list