-
-
Notifications
You must be signed in to change notification settings - Fork 980
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
Preserve modified keys when modifier and key are sent simultaneously on Wayland #7283
Conversation
OK I will look at it when I have a moment. |
So I am not really convinced by your proposed fixes, except maybe 1 which needs more investigation. It would be good if we can get some clarity on the spec from whoever maintains it. Or at least check what other toolkits like Qt, GTK, winint, etc. do so we can "follow the herd". |
Pinging @wengxt they may have some useful comments. |
Thanks a lot for the review. I'll make sure to read those docs. I don't feel there's anything wrong about the implementation in wl_text_input. If the input was consistent, it would work just fine, but it's not and the spec doesn't account for that. Option 1 is a workaround to patch a symptom, if it does no harm then it just works. But I'd feel better about preventing the bug at the source, it is not normal that this part receives different inputs for a same keypress. I'll continue investigating higher up the chain, maybe I'll find something useful. |
I agree the wording in the docs is unclear. But if I understand correctly, option 1 might be on the right track:
And they go on refining the concept of state:
They also state that
Since in I've done a preliminary check of a few terminals and toolkits, and it doesn't seems there's a clear standard to follow. I've not digged into the entire code bases but it looks like GTK does what I just stated but Qt would stop processing in case of a mismatch. 🤷🏼♂️ I also figured out why the second keypress works and no the first (impression of different inputs for same keypress). It's the actually the same data: The first keypress is blocked because of the serial mismatch, the second keypress sends the same input and that unblocks the first one:
So I think it comes down to either sending the text in case of a mismatch, or finding the root cause of the serial difference. |
I fixed it slightly differently from your proposal, please have a look and let me know if you feel there are any remaining issues. |
I've tested it and it works. The logs are outputting the same events sequence for a same keypress. LGTM, thanks a lot for taking the time to look into this. This has been bugging me for months but it seems like it's finally over. |
thanks for doing the legwork! |
…y ZMK keyboard + fcitx5 Fixes kovidgoyal#7283
This is an attempt to fix #7258, in which shifted keys sent by a programmable keyboard are dropped half of the time on Wayland/Fcitx.
Required setup to reproduce:
&RPAR
Behavior
When opening a Kitty terminal, typing ")" once does nothing, typing it again displays the ")" character. Repeating this key sequence invariably yields the same result.
Let's analyze just those two first keypresses.
Observations
wev
Here's the
wev
output for the first keypress:And the second keypress:
Everything looks in order, but let's take note that all of the events of a keypress are sent with the same timestamp, which is not possible with a regular keyboard (this is an optimization for bluetooth communication, since the shifted key is triggered with a single keypress instead of two).
Kitty
In Kitty, here's how it goes:
First keypress:
Second keypress:
Something's not right. For some reason, the first and second keypress events are not handled the same way. I'm no expert at this and I have not found the site of this issue yet. This could come from Kitty but this could likely be in the Compositor/IME chain. Guidance or enlightment would be quite welcomed here.
What is happening?
commit_serial
counter is incremented.serial
andcommit_serial
doesn't match Kitty drops the pre-edit text.So that explains it, but I do not know why this was implemented. From what I deducted, it was to mute warnings on a specific contexts?
Solutions
There are multiple ways to fix this:
What I'm suggesting in this PR is probably the less involved solution. Let's render the pre-edit text anyway, even if in case of a serial count mismatch. Would it have any adverse effect? In which situation wouldn't we want to render text that the user has typed?
My second option would be not to commit on cursor position updates. In my tests, it was unecessary to commit at this point and it's the source of the mismatch, but surely I am missing some use cases where it is useful. Perhaps skipping the commit step on some condition would be less drastic, which leads me to the next idea.
In
keys.c
, the caseGLFW_IME_NONE
updates the IME position for MacOS and Fig (RIP). If a condition could be met to skip this action for other contexts, the bug would be prevented as the cursor position would not be updated.I'm sure there's more ways to fix it, but for now I'd be interested to hear your take on this.
Both fixes work equally well from a user perspective. Codewise, option 1 is only a patch for a mishandling that has already happened and the log will still be mixed up. Option 3 yields a more cleaned up events order (identical log for each keypress).
Thanks for taking the time to review this and provide some feedback!