fix: always process all events in the queue on x11.#73
Merged
amrbashir merged 2 commits intotauri-apps:devfrom Apr 22, 2024
Merged
fix: always process all events in the queue on x11.#73amrbashir merged 2 commits intotauri-apps:devfrom
amrbashir merged 2 commits intotauri-apps:devfrom
Conversation
Previously, there was always a 50ms delay between processing individual events, which could lead to a queue of events building up if the key repeat was higher than 20 Hz. This resulted in the global hotkey release only being detected long after the key is released.
amrbashir
approved these changes
Apr 22, 2024
Member
|
Thanks for your contibutions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
whilesolution 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
XNextEventwith 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 anXSyncAlarmto break out of the blockingXNextEventcall. It add significant complexity, so I don't think the trade off is worth it at this moment.