Do generate wxEVT_CHAR for Ctrl-Letter even in non US layouts

Use the key translated to the US layout by XKB and not the actual
character produced by the key in the current layout when determining
whether to generate wxEVT_CHAR for key presses with Ctrl or not.

This ensures that we produce the expected events for Ctrl-Latter in all
layouts and not just the ones using Latin letters.

See #25384, #25385.

(cherry picked from commit 57c33bb9ed)
This commit is contained in:
Vadim Zeitlin
2025-07-30 23:33:34 +02:00
parent 082d1fd28a
commit 769bddb9e3
2 changed files with 14 additions and 12 deletions
+1
View File
@@ -267,6 +267,7 @@ wxGTK:
- Fix handling total window size with GNOME with X11 (#25348).
- Fix height of read-only wxBitmapComboBox (#25468).
- Fix wxGLCanvas scale when using EGL/Wayland in high DPI (Popax21, #23733).
- Fix missing wxEVT_CHAR for Ctrl-Letter in non-US layouts (#25384).
- Show system default window buttons under Wayland (#25562).
wxMSW
+13 -12
View File
@@ -1388,20 +1388,21 @@ gtk_window_key_press_callback( GtkWidget *WXUNUSED(widget),
// etc).
if ( eventChar.ControlDown() )
{
if ( uniChar >= 'a' && uniChar <= 'z' )
uniChar = toupper(uniChar);
// We should already have the corresponding key in US layout,
// translated from GTK using XKB, in the event.
long keyCode = event.m_keyCode;
if ( (uniChar >= 'A' && uniChar <= 'Z') ||
uniChar == '[' ||
uniChar == '\\' ||
uniChar == ']' ||
uniChar == '^' ||
uniChar == '_' )
if ( (keyCode >= 'A' && keyCode <= 'Z') ||
keyCode == '[' ||
keyCode == '\\' ||
keyCode == ']' ||
keyCode == '^' ||
keyCode == '_' )
{
// Convert to ASCII control character.
uniChar &= 0x1f;
keyCode &= 0x1f;
}
else if ( uniChar != ' ' )
else if ( keyCode != ' ' )
{
// For the printable characters other than Space (for which
// we still do generate CHAR event, for compatibility with
@@ -1413,9 +1414,9 @@ gtk_window_key_press_callback( GtkWidget *WXUNUSED(widget),
break;
}
eventChar.m_keyCode = uniChar;
eventChar.m_keyCode = keyCode;
#if wxUSE_UNICODE
eventChar.m_uniChar = uniChar;
eventChar.m_uniChar = keyCode;
#endif // wxUSE_UNICODE
}
else // Not a control character.