mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-02-23 11:56:42 +00:00
x11: Send key events for dead keys consumed by the IME
This matches the Wayland backend and what apps originally written for SDL2 are expecting.
(cherry picked from commit 47162a4168)
This commit is contained in:
committed by
Sam Lantinga
parent
1543f523b7
commit
e42071a47c
@@ -987,29 +987,26 @@ void X11_HandleKeyEvent(SDL_VideoDevice *_this, SDL_WindowData *windowdata, SDL_
|
||||
}
|
||||
}
|
||||
|
||||
if (!handled_by_ime) {
|
||||
if (pressed) {
|
||||
X11_HandleModifierKeys(videodata, scancode, true, true);
|
||||
SDL_SendKeyboardKeyIgnoreModifiers(timestamp, keyboardID, keycode, scancode, true);
|
||||
|
||||
if (*text && !(SDL_GetModState() & (SDL_KMOD_CTRL | SDL_KMOD_ALT))) {
|
||||
text[text_length] = '\0';
|
||||
X11_ClearComposition(windowdata);
|
||||
SDL_SendKeyboardText(text);
|
||||
}
|
||||
} else {
|
||||
if (X11_KeyRepeat(display, xevent)) {
|
||||
// We're about to get a repeated key down, ignore the key up
|
||||
return;
|
||||
}
|
||||
|
||||
X11_HandleModifierKeys(videodata, scancode, false, true);
|
||||
SDL_SendKeyboardKeyIgnoreModifiers(timestamp, keyboardID, keycode, scancode, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (pressed) {
|
||||
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))) {
|
||||
text[text_length] = '\0';
|
||||
X11_ClearComposition(windowdata);
|
||||
SDL_SendKeyboardText(text);
|
||||
}
|
||||
|
||||
X11_UpdateUserTime(windowdata, xevent->xkey.time);
|
||||
} else {
|
||||
if (X11_KeyRepeat(display, xevent)) {
|
||||
// We're about to get a repeated key down, ignore the key up
|
||||
return;
|
||||
}
|
||||
|
||||
X11_HandleModifierKeys(videodata, scancode, false, true);
|
||||
SDL_SendKeyboardKeyIgnoreModifiers(timestamp, keyboardID, keycode, scancode, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user