visual typesetting: limit event frequency

This change makes Aegisub a lot more responsive on platforms like X11
where mouse events may come in at very high frequencies and/or in bursts.
This commit is contained in:
Mia Herkt 2021-01-18 03:20:57 +01:00
parent d40eb355dd
commit ca1ac8bcea
Signed by: mia
SSH key fingerprint: SHA256:wqxNmz1v3S4rHhF0I3z/ogVueFRUac93swSgNGfr8No
2 changed files with 8 additions and 0 deletions

View file

@ -172,6 +172,13 @@ VisualTool<FeatureType>::VisualTool(VideoDisplay *parent, agi::Context *context)
template<class FeatureType> template<class FeatureType>
void VisualTool<FeatureType>::OnMouseEvent(wxMouseEvent &event) { void VisualTool<FeatureType>::OnMouseEvent(wxMouseEvent &event) {
// wx doesnt throttle for us, updating the video view is
// very expensive, and aegisubs work queue handling is bad,
// so limit mouse event rate to ~200 Hz
long ts = event.GetTimestamp();
if ((ts - lastEvent) < 5) return;
lastEvent = ts;
bool left_click = event.LeftDown(); bool left_click = event.LeftDown();
bool left_double = event.LeftDClick(); bool left_double = event.LeftDClick();
shift_down = event.ShiftDown(); shift_down = event.ShiftDown();

View file

@ -92,6 +92,7 @@ protected:
bool holding = false; ///< Is a hold currently in progress? bool holding = false; ///< Is a hold currently in progress?
AssDialogue *active_line = nullptr; ///< Active dialogue line; nullptr if it is not visible on the current frame AssDialogue *active_line = nullptr; ///< Active dialogue line; nullptr if it is not visible on the current frame
bool dragging = false; ///< Is a drag currently in progress? bool dragging = false; ///< Is a drag currently in progress?
long lastEvent = 0;
int frame_number; ///< Current frame number int frame_number; ///< Current frame number