From 4799785b6dfc2d4490598b447c99435105b8ebba Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 8 Apr 2023 16:26:53 +0200 Subject: [PATCH] Improve code in gtk_window_key_press_callback() Don't use isalpha() in it as this was potentially incorrect, both because the key code could be not in the supported range and because isalpha() might return unexpected result in non C locale, and also inconsistent with AdjustCharEventKeyCodes(). Just check that the code is in a..z or A..Z range explicitly instead. See #23379. --- src/gtk/window.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 4a892098b7..87e15041a5 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1413,9 +1413,12 @@ gtk_window_key_press_callback( GtkWidget *WXUNUSED(widget), { wxKeyEvent eventChar(wxEVT_CHAR, event); - if ( event.ControlDown() && isalpha(event.m_keyCode) ) + // Check for the special case of Ctrl+letter, see comment before + // AdjustCharEventKeyCodes(). + if ( event.ControlDown() && + ((event.m_keyCode >= 'a' && event.m_keyCode <= 'z') || + (event.m_keyCode >= 'A' && event.m_keyCode <= 'Z')) ) { - // Ctrl+letter is handled specially by AdjustCharEventKeyCodes(). eventChar.m_keyCode = event.m_keyCode; eventChar.m_uniChar = event.m_uniChar; }