fix: always process all events in the queue on x11. #73
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.
Commit message:
Extra information:
Holding the key for a longer duration led to a larger backlog, and thus a longer delay before the release event was detected. I opted for the
while
solution instead of reducing the sleep to ensure we always clear out the entire event backlog.The 50ms delay here does still mean that we incur a worst case delay of 50ms when detecting the keydown and keyup event. I looked for a version of
XNextEvent
with a timeout and I found this article that describes two approaches to check for events with a timeout, the first requires usingpoll
, the second sets anXSyncAlarm
to break out of the blockingXNextEvent
call. It add significant complexity, so I don't think the trade off is worth it at this moment.