Closed
Description
When typing in Russian on GNOME Wayland, SDL absolutely pummels the app with SDL_EVENT_KEYMAP_CHANGED
events:
encoded.mp4
On Sway, it doesn't send any text input events whatsoever when in Russian, using the following config:
input type:keyboard xkb_layout us,ru
bindsym $mod+Backspace input type:keyboard xkb_switch_layout next
Interestingly, you can also notice in the video that when I switched from Russian to Japanese, SDL continued to produce text input events in Russian.
Demo code
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <stdio.h>
static SDL_Window* window;
static SDL_Renderer* renderer;
static char inputbuf[4096];
int main() {
SDL_zero(inputbuf);
SDL_SetHint(SDL_HINT_EVENT_LOGGING, "1");
SDL_CreateWindowAndRenderer("sdl_testapp", 1280, 720, SDL_WINDOW_HIGH_PIXEL_DENSITY | SDL_WINDOW_RESIZABLE, &window, &renderer);
SDL_SetRenderVSync(renderer, 1);
SDL_StartTextInput(window);
bool quit = false;
SDL_Event event;
while (!quit) {
while (!quit && SDL_PollEvent(&event)) {
if (event.type == SDL_EVENT_QUIT) {
quit = true;
} else if (event.type == SDL_EVENT_KEY_UP && event.key.scancode == SDL_SCANCODE_RETURN) {
SDL_StopTextInput(window);
} else if (event.type == SDL_EVENT_KEY_DOWN && event.key.scancode == SDL_SCANCODE_BACKSPACE) {
if (SDL_strlen(inputbuf) > 0)
inputbuf[SDL_strlen(inputbuf) - 1] = 0;
} else if (event.type == SDL_EVENT_TEXT_INPUT)
SDL_strlcat(inputbuf, event.text.text, sizeof(inputbuf));
else if (event.type == SDL_EVENT_MOUSE_BUTTON_UP) {
SDL_StartTextInput(window);
}
}
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_RenderClear(renderer);
int w, h;
SDL_GetWindowSizeInPixels(window, &w, &h);
SDL_SetWindowTitle(window, inputbuf);
char* buf = NULL;
SDL_asprintf(&buf, "Dimensions: %ix%i\nText input active: %b\nScreen keyboard shown: %b",
w, h, SDL_TextInputActive(window), SDL_ScreenKeyboardShown(window));
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
SDL_RenderDebugText(renderer, 10, 10, buf);
SDL_free(buf);
SDL_RenderPresent(renderer);
}
}
Metadata
Metadata
Assignees
Labels
No labels