From f07ba5b954518fb2ab7083158bbcae8e40ab5fab Mon Sep 17 00:00:00 2001 From: Frank Praznik Date: Sat, 7 Feb 2026 14:11:58 -0500 Subject: [PATCH] wayland: Check the mod state when sending repeated key text The control and alt modifiers should suppress text events when repeating to match standard press behavior. --- src/video/wayland/SDL_waylandevents.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index 169f8a6e88..b1d7fe07fe 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/src/video/wayland/SDL_waylandevents.c @@ -421,7 +421,7 @@ static bool keyboard_repeat_handle(SDL_WaylandKeyboardRepeat *repeat_info, Uint6 const Uint64 timestamp = repeat_info->base_time_ns + repeat_info->next_repeat_ns; SDL_SendKeyboardKeyIgnoreModifiers(Wayland_AdjustEventTimestampBase(timestamp), repeat_info->keyboard_id, repeat_info->key, repeat_info->scancode, true); } - if (repeat_info->text[0]) { + if (repeat_info->text[0] && !(SDL_GetModState() & (SDL_KMOD_CTRL | SDL_KMOD_ALT))) { SDL_SendKeyboardText(repeat_info->text); } repeat_info->next_repeat_ns += SDL_NS_PER_SECOND / (Uint64)repeat_info->repeat_rate; @@ -2310,10 +2310,11 @@ static void keyboard_handle_key(void *data, struct wl_keyboard *keyboard, SDL_SendKeyboardKeyIgnoreModifiers(timestamp_ns, seat->keyboard.sdl_id, key, scancode, state == WL_KEYBOARD_KEY_STATE_PRESSED); if (state == WL_KEYBOARD_KEY_STATE_PRESSED) { + if (handled_by_ime) { + has_text = false; + } if (has_text && !(SDL_GetModState() & (SDL_KMOD_CTRL | SDL_KMOD_ALT))) { - if (!handled_by_ime) { - SDL_SendKeyboardText(text); - } + SDL_SendKeyboardText(text); } if (seat->keyboard.xkb.keymap && WAYLAND_xkb_keymap_key_repeats(seat->keyboard.xkb.keymap, key + 8)) { keyboard_repeat_set(&seat->keyboard.repeat, seat->keyboard.sdl_id, key, time, timestamp_ns, scancode, has_text, text);