On Wed, 22 Sep 2021 08:05:03 GMT, Alisen Chung
<[email protected]> wrote:
>> src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m line 485:
>>
>>> 483: } else if([lang isEqualToString:@"ru"]) {
>>> 484: // checking for Russian characters
>>> 485: offset += 0x01000000;
>>
>> where did this value come from ?
>> And I agree adding only russian looks odd. Actually I have no idea (and am
>> curious) why the submitter was actually testing a russian layout keyboard.
>> Are we doing something weird, or does macOS really make developers have to
>> understand every single supported language -> keyboard mapping ?
>> Is there a better (more generic) way ?
>> Is this the ONLY place we'd need to add understanding of Russian ? If
>> there's more it would not be worth doing it just here.
>
>> where did this value come from ?
>
> The 0x01000000 offset value is copied from
> share/classes/sun/awt/ExtendedKeyCodes.java. When using
> getExtendedKeyCodeForChar(int c), if the character isn't in the
> regularKeyCodesMap, that 0x01000000 offset is added and the new value is
> checked for again in the extendedKeyCodeSet. I noticed that Russian was in
> the extendedKeyCodeSet so I just checked for Russian active keyboard layout
> and added that offset since the case wasn't being handled before.
>
>> Are we doing something weird, or does macOS really make developers have to
>> understand every single supported language -> keyboard mapping ?
> Is there a better (more generic) way ?
>
> I can try to test whether removing the Russian language check also fixes
> other languages (since that's what we do in ExtendedKeyCodes.java anyway),
> but macOS might have a different system of keycodes so I can't tell for sure
> that it would work for all of them.
>
>> Is this the ONLY place we'd need to add understanding of Russian ? If
>> there's more it would not be worth doing it just here.
>
> From my understanding anything that relies on keycodes would be fixed with
> this since AWTEvent.m was only checking for English to translate NSKeyCodes
> to Java virtual keycodes. I didn't see anywhere else related to keycodes we
> would need to have a language check .
This at least looks better. I guess you tried a few keyboard layout settings ?
Can you add a comment to the source where the 0x10000000 value comes from /
what it means.
-------------
PR: https://git.openjdk.java.net/jdk/pull/5617