Skip to content

fix: always process all events in the queue on x11.#73

Merged
amrbashir merged 2 commits intotauri-apps:devfrom
iwanders:process-all-x11-events
Apr 22, 2024
Merged

fix: always process all events in the queue on x11.#73
amrbashir merged 2 commits intotauri-apps:devfrom
iwanders:process-all-x11-events

Conversation

@iwanders
Copy link
Copy Markdown
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
Copy Markdown
Member

Thanks for your contibutions

@amrbashir amrbashir merged commit 24f41b0 into tauri-apps:dev Apr 22, 2024
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