diff options
author | tsarn <nikita.tsarev@jetbrains.com> | 2024-04-26 10:01:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-26 10:01:10 +0200 |
commit | 6f6aca3c5d4356a9b4fd08f8cf145bd30e85b73b (patch) | |
tree | e5847d3ed228ae6f2d337b5cb28c428e18b7f4ac | |
parent | 73356a1bf3c02a7008ebadefd75ffb1c8147f784 (diff) | |
download | JetBrainsRuntime-6f6aca3c5d4356a9b4fd08f8cf145bd30e85b73b.tar.gz |
JBR-7063: Make .getKeyChar() report chars in KEY_PRESSED/KEY_RELEASED events for compatibility [WLToolkit] (#371)jb21.0.3-b442
-rw-r--r-- | src/java.desktop/unix/native/libawt_wlawt/WLKeyboard.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/java.desktop/unix/native/libawt_wlawt/WLKeyboard.c b/src/java.desktop/unix/native/libawt_wlawt/WLKeyboard.c index c4f87ef6faa..a5b51aefdcf 100644 --- a/src/java.desktop/unix/native/libawt_wlawt/WLKeyboard.c +++ b/src/java.desktop/unix/native/libawt_wlawt/WLKeyboard.c @@ -1191,6 +1191,15 @@ postKeyTypedEvents(const char *string) { } } +static uint16_t +getJavaKeyCharForKeycode(xkb_keycode_t xkbKeycode) { + uint32_t codepoint = xkb.state_key_get_utf32(keyboard.state, xkbKeycode); + if (codepoint == 0 || codepoint >= 0xffff) { + return java_awt_event_KeyEvent_CHAR_UNDEFINED; + } + return (uint16_t)codepoint; +} + // Posts an XKB keysym as KEY_TYPED events, without consulting the current compose state. static void handleKeyTypeNoCompose(xkb_keycode_t xkbKeycode) { @@ -1285,7 +1294,7 @@ handleKey(long timestamp, uint32_t keycode, bool isPressed, bool isRepeat) { .keyLocation = javaKeyLocation, .rawCode = keycode, .extendedKeyCode = javaExtendedKeyCode, - .keyChar = java_awt_event_KeyEvent_CHAR_UNDEFINED, + .keyChar = getJavaKeyCharForKeycode(xkbKeycode), }; wlPostKeyEvent(&event); |