X11: Fix Fl::event_key() when using non-latin keyboard layouts (#1427)
Build and Test / build-linux (push) Has been cancelled
Build and Test / build-wayland (push) Has been cancelled
Build and Test / build-macos (push) Has been cancelled
Build and Test / build-windows (push) Has been cancelled

This commit is contained in:
ManoloFLTK
2026-05-04 18:04:05 +02:00
parent 88a4d745fd
commit fe4a6aa912
+23
View File
@@ -1300,6 +1300,18 @@ static bool remove_xid_vector(Window xid) {
return false;
}
static char keycode_to_ascii(int keycode) {
static const char row_AD[] = "qwertyuiop";
static const char row_AC[] = "asdfghjkl";
static const char row_AB[] = "zxcvbnm";
if (keycode >= 24 && keycode <= 33) return row_AD[keycode - 24];
else if (keycode >= 38 && keycode <= 46) return row_AC[keycode - 38];
else if (keycode >= 52 && keycode <= 58) return row_AB[keycode - 52];
else return 0;
}
int fl_handle(const XEvent& thisevent)
{
XEvent xevent = thisevent;
@@ -1991,6 +2003,17 @@ int fl_handle(const XEvent& thisevent)
keysym = '0';
}
int keysyms_per_keycode;
KeySym *syms = XGetKeyboardMapping(fl_display, 38 /* 'A' key on US keyboard */, 1,
&keysyms_per_keycode);
// Check for non-Latin keyboard layout
if (syms[0] > 'z') {
int asciiSym = keycode_to_ascii(keycode);
if (asciiSym != 0) {
keysym = asciiSym;
}
}
// We have to get rid of the XK_KP_function keys, because they are
// not produced on Windoze and thus case statements tend not to check
// for them. There are 15 of these in the range 0xff91 ... 0xff9f