RFR: 8262945: [macos] Regression Manual Test for Key Events Fails

Phil Race prr at openjdk.java.net
Tue Sep 21 22:41:57 UTC 2021


On Tue, 21 Sep 2021 18:00:13 GMT, Alisen Chung <github.com+90066231+alisenchung at openjdk.org> wrote:

> Added a check for active keyboard language and added support for Russian NSEvent keyCodes to JavaVirtualKeyCode translation. Originally, only English characters were checked for even if other languages were in native letterCharacterSet. Can be easily expanded to include other languages as well.

src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m line 471:

> 469:             lang = languages;
> 470:         }
> 471: 

This may become irrelevant if the fix changes, as it well might, but I'm not sure what to make of line 469 above.

the check "If (languages .." implies that there's a chance languages may be null  and I'm a bit
surprised the compiler doesn't complain about the assignment of an NSArray* to an NSString*
and then later on you dereference lang (line 483)

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.

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

PR: https://git.openjdk.java.net/jdk/pull/5617



More information about the client-libs-dev mailing list