8000 x11: Filter out duplicate key presses when an IME is active by Kontrabant · Pull Request #12974 · libsdl-org/SDL · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

x11: Filter out duplicate key presses when an IME is active #12974

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/video/x11/SDL_x11events.c
Original file line number Diff line number Diff line change
Expand Up @@ -988,8 +988,11 @@ void X11_HandleKeyEvent(SDL_VideoDevice *_this, SDL_WindowData *windowdata, SDL_
}

if (pressed) {
X11_HandleModifierKeys(videodata, scancode, true, true);
SDL_SendKeyboardKeyIgnoreModifiers(timestamp, keyboardID, keycode, scancode, true);
// Duplicate events may be sent when an IME is active; don't send multiple keydown events for the same serial.
if (videodata->last_key_down_serial != xevent->xkey.serial) {
X11_HandleModifierKeys(videodata, scancode, true, true);
SDL_SendKeyboardKeyIgnoreModifiers(timestamp, keyboardID, keycode, scancode, true);
}

// Synthesize a text event if the IME didn't consume a printable character
if (*text && !(SDL_GetModState() & (SDL_KMOD_CTRL | SDL_KMOD_ALT))) {
Expand All @@ -999,6 +1002,7 @@ void X11_HandleKeyEvent(SDL_VideoDevice *_this, SDL_WindowData *windowdata, SDL_
}

X11_UpdateUserTime(windowdata, xevent->xkey.time);
videodata->last_key_down_serial = xevent->xkey.serial;
} else {
if (X11_KeyRepeat(display, xevent)) {
// We're about to get a repeated key down, ignore the key up
Expand Down
2 changes: 2 additions & 0 deletions src/video/x11/SDL_x11video.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ struct SDL_VideoData
int xinput_master_pointer_device;
bool xinput_hierarchy_changed;

unsigned long last_key_down_serial;

int xrandr_event_base;
struct
{
Expand Down
Loading
0