-
Notifications
You must be signed in to change notification settings - Fork 125
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
Fix latches #611
base: master
Are you sure you want to change the base?
Fix latches #611
Conversation
- Added a big bunch of tests for modifier latch. No yet exhaustive, but should cover the most usual use cases. - Added missing test cases for breaking the group latch. Ideally, more tests should be added to match the coverage of modifiers latches.
Prior to this commit, "latch A down" → "latch B down" → "latch A up" → "latch B up" would result in only B being latched. After this commit, both A and B end up latched. Changed latching behavior so that the same rules used to detect whether an action breaks a latch after the latching key is released, are now also used to detect whether the action prevents the latch from triggering at the latching key release. The major effect of this change is that depressing and releasing two latching keys simultaneously will now activate both latches, as expected. This will allow us to provide proper Sticky Key support. Co-authored-by: Jules Bertholet <[email protected]> Co-authored-by: Pierre Le Marre <[email protected]>
The specification says
There are two abiguities:
In the scenario that you are describing, I'm not activating any latches since the behavior of SetMods from X11 seems to be the desired one with the behavior of LatchMods being a bug due to the structure of the code. |
I believe X11’s behavior of no simultaneous latches is the one that most strictly matches the spec. The spec says “latched modifiers or groups apply only to the next key event that does not change keyboard state”, yes—but the modifier is only properly considered latched after the latching key is released. Therefore, the “does not change keyboard state” requirement doesn’t apply to pressing two latch keys simultaneously. The issue, of course, is that the spec behavior around latching is simply terrible! That’s why I filed #569 to deliberately deviate from it. |
@mahkoh Yet I do not think this is the expected behavior. The motivation of latches is accessibility. In Xorg they can be activated by the StickyKeys control. Now, imagine a user who needs to press But I am not an accessibility expert, so ultimately I would implement whatever experts advise to get proper Sticky Keys. If they say the feature is broken anyway and that the spec is ambiguous and the Xorg implementation is buggy, then I would say it’s up to each implementation to do their best to satisfy their users. |
FYI activating Sticky Keys in some DE under Wayland:
|
There is a risk that this PR might actually make the experience worse for some users, if the “new latches break existing latches for non- Usually, when you press two latching keys in succession, you want both modifiers to end up latched. This MR ensures that this always happens. However, sometimes you actually do want the first latch to be dropped. This is the case for layouts like bépo that use With xkbcommon in its current state, combining sticky
So, if we are to accept deviation from the spec anyway in order to better satisfy users, there is really no reason not to adopt all of #569. |
@Jules-Bertholet Bépo does not use
I do not understand the issue of your use case. Please pickup a layout in xkeyboard-config and write down a key sequence with the expected + current MR behavior to illustrate.
This is not what I wrote. Your MR explicitly deviates from the spec and this is not the subject here. Here we try to match the spec, but due to the ambiguities we try to achieve a common interpretation. Whether your MR will be accepted or not will not be considered until release 1.10, as I commented. |
Oh, my bad! The German E1 layout will do, then. Imagine you start with that layout, and then set up sticky keys, replacing |
I'd be interested in seeing the actual keymaps that you tested this with. |
@mahkoh I just activated the Sticky Keys feature in each desktop. Any keymap would do. |
I thought you were talking about the behavior of |
@mahkoh yes, I meant the sticky keys implementation of the Wayland compositors. I think most1 compositors use xkbcommon, which does not support this, so it’s up to each compositor. And not all of them implement it correctly, so I opened #596. On the other hand the latch behavior without sticky keys should be the same on all compositors otherwise. That is, if they do not mess with keyboard state. Footnotes
|
I added the tests to #618, but with the current behavior. The current MR will then require rebase. |
The spec says “if no keys were operated simultaneously with the latching modifier key”, not “if no keys that don’t affect keyboard state were operated simultaneously with the latching modifier key”. The meaning of “operated” is ambiguous, as pointed out by @mahkoh. But the meaning of “no keys” is not ambiguous at all, and it doesn’t match this PR. The way I see it:
|
Actually, scratch that, “operated” isn’t ambiguous either. As it’s used in the description of |
So, is your understanding that the only use case considered by XKB to trigger latches is keys strictly sequentially tapped (i.e. press then released)? We currently also trigger the latch if whatever different key is released between the press and release, i.e. |
FYI the shift key on my android phone does not latch if another key is pressed while the shift key is pressed. |
That is my understanding of the spec, yes. However, I also believe that this part of the spec is bad, and |
Let’s not rush and wait 1.11 to see if we want to deviate from the spec. |
Prior to this MR, "latch A down" → "latch B down" → "latch A up" → "latch B up" would result in only B being latched. After this MR, both A and B end up latched.
Changed latching behavior so that the same rules used to detect whether an action breaks a latch after the latching key is released, are now also used to detect whether the action prevents the latch from triggering at the latching key release.
The major effect of this change is that depressing and releasing two latching keys simultaneously will now activate both latches, as expected. This will allow us to provide proper Sticky Key support.
Note that it seems X11 handle simultaneous modifiers only if pressed sequentially, not simultaneously. But I have not done extensive tests. It seems a bug however; according to the XKB specification §2.1:
CC @Jules-Bertholet @mahkoh
@Jules-Bertholet I extracted the bug fix from #569 (good catch!), reworked it and added a big bunch of tests.