From 4029521a630ca848e89fdaf6d08cc1cbfb9424bc Mon Sep 17 00:00:00 2001 From: hwsmm <9151706+hwsmm@users.noreply.github.com> Date: Sun, 16 Mar 2025 04:43:40 +0900 Subject: [PATCH] Don't send text event while ctrl/alt is held on X11/Wayland (cherry picked from commit ac5b2b61024f48b0ee7f4d81856d0d1696c1bd24) --- src/video/wayland/SDL_waylandevents.c | 2 +- src/video/x11/SDL_x11events.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index 83c414fb3a..7a715dbb42 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/src/video/wayland/SDL_waylandevents.c @@ -1884,7 +1884,7 @@ static void keyboard_handle_key(void *data, struct wl_keyboard *keyboard, SDL_SendKeyboardKeyIgnoreModifiers(timestamp, input->keyboard_id, key, scancode, state == WL_KEYBOARD_KEY_STATE_PRESSED); if (state == WL_KEYBOARD_KEY_STATE_PRESSED) { - if (has_text && !(SDL_GetModState() & SDL_KMOD_CTRL)) { + if (has_text && !(SDL_GetModState() & (SDL_KMOD_CTRL | SDL_KMOD_ALT))) { if (!handled_by_ime) { SDL_SendKeyboardText(text); } diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index d619618d92..e674b9abcf 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -977,7 +977,7 @@ void X11_HandleKeyEvent(SDL_VideoDevice *_this, SDL_WindowData *windowdata, SDL_ X11_HandleModifierKeys(videodata, scancode, true, true); SDL_SendKeyboardKeyIgnoreModifiers(timestamp, keyboardID, keycode, scancode, true); - if (*text) { + if (*text && !(SDL_GetModState() & (SDL_KMOD_CTRL | SDL_KMOD_ALT))) { text[text_length] = '\0'; X11_ClearComposition(windowdata); SDL_SendKeyboardText(text);