-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix broken dead key behavior on Wayland #9983
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
Conversation
Hmm, there seems to be a deeper problem with the text input protocol not being properly activated at initial window creation time, which this masks, but doesn't fix. Investigating now. |
FYI, text input isn't activated by default in SDL3. You need to call SDL_StartTextInput() if you want to enable text input. |
I'm seeing this in testime, which does activate text input. The problem is that the protocol is initially enabled while the window is unmapped, but according to the spec it needs to be re-enabled "every time the active text input changes to a new one, including within the current surface", which means that it needs to be re-enabled when the window is mapped and initially gains focus, since the text input was changed. The behavior introduced by this patch hacks around this, by basically bypassing it, but doesn't fix the root cause. Easy enough to fix by ensuring that it is re-enabled on keyboard enter events. |
@Kontrabant You were on the right track, but it wasn't the text input protocol that was causing this. Instead, it was XKB that was not reset upon enabling text input, which is apparently responsible for both composite and dead keys. Since this was not reset, keys were carrying over from that, which is what caused the à to appear on dead keys when text input was disabled. I still went ahead and re-initialized text input on keyboard enter for correctness, though. Chances are that some compositor out there breaks if this isn't done correctly, so it's best to follow the standards whenever possible. |
This fixes numerous problems regarding dead keys on Wayland. Most notably, Wayland was enforcing dead keys on SDL_KEYDOWN and SDL_KEYUP events, which caused unresponsiveness on keys that were mapped to dead keys (tilde on US-Intl is most notable for this, commonly used as a console key). When starting text input, not all state was reset properly. The text input protocol requires to be re-enabled every time text input changes, which SDL did not do. Also, XKB compose state was not reset at all, causing composite and dead keys to carry over from when text input was disabled.
057e1d6
to
64b3e82
Compare
I squashed your commits into one and made a few extra cleanups:
With this, looks good to me. |
Merged, thanks! |
Is there a main version of this commit? |
Working on it. Trying to cherry-pick results in a merge mess, so doing it manually. |
Thanks! |
Manually ported and merged into main. |
Fixes numerous issues regarding dead key behavior on Wayland.
Description
This fixes numerous problems regarding dead keys on Wayland. Most
notably, Wayland was enforcing dead keys on SDL_KEYDOWN and SDL_KEYUP
events, which caused unresponsiveness on keys that were mapped to dead
keys (tilde on US-Intl is most notable for this, commonly used as a
console key).
In addition to this, Wayland was also ignoring SDL_StopTextInput calls,
and proceeded to process dead keys regardless if text input is disabled
or not. This caused issues on console keys where the first keypress
after the console key is merged with the dead key, causing the first key
to appear as à instead of a.
Existing Issue(s)
None