Skip to content
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: always process all events in the queue on x11. #73

Merged
merged 2 commits into from
Apr 22, 2024

Conversation

iwanders
Copy link
Contributor

Commit message:

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.

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 using poll, the second sets an XSyncAlarm to break out of the blocking XNextEvent call. It add significant complexity, so I don't think the trade off is worth it at this moment.

iwanders and others added 2 commits April 21, 2024 11:40
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 amrbashir changed the title Always process all events in the queue on x11. fix: always process all events in the queue on x11. Apr 22, 2024
@amrbashir
Copy link
Member

Thanks for your contibutions

@amrbashir amrbashir merged commit 24f41b0 into tauri-apps:dev Apr 22, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants