X11: Added reliable detection of autorepeat for Xkb #409
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a proposal for a reliable detection of repeated keys for Linux.
It is not based on peeking a future event and its timestamp.
Method
Use of libX11 API XkbSetDetectableAutoRepeat.
Since the server-side may not necessarily support the request, it's good to keep the basic method as a fallback.
The purpose is to disable the reception of release events for repeated keys.
Then, if there is a press on a key already marked as down in the key state, it is identifiable as a repetition.
So unlike the basic method which filters out the release events, this filters the key press.
Description of problem
It solves a problem where repetitions are not detected in all cases.
A notable symptom is the
MidiKeyboardComponent
playing its notes in rapid fire, while keeping pressed one or more of the keys.Additional information
By the currently used method, the repetitions are detected by timestamp on the press event which follows a release.
A problem is that there is a race for the reception of the press event.
The call
XPending
ofisKeyReleasePartOfAutoRepeat
can be observed returning false when the second event is not available in time.This is a custom trace which shows the event sequence and the information around autorepeat.
trace.diff.gz
Environment of test
I am running this software: current Arch Linux, X.Org 1.20.0, MATE Desktop 1.20.3.
Linux quad 4.16.18-rt9-1-rt #1 SMP PREEMPT RT Fri Jul 13 21:57:24 CEST 2018 x86_64 GNU/Linux