1
0
Fork 0

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 9b3fa75ab2
commit d2b3e38565
Signed by: mia
SSH Key Fingerprint: SHA256:wqxNmz1v3S4rHhF0I3z/ogVueFRUac93swSgNGfr8No
2 changed files with 8 additions and 0 deletions

View File

@ -170,6 +170,13 @@ VisualTool<FeatureType>::VisualTool(VideoDisplay *parent, agi::Context *context)
template<class FeatureType>
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_double = event.LeftDClick();
shift_down = event.ShiftDown();

View File

@ -92,6 +92,7 @@ protected:
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
bool dragging = false; ///< Is a drag currently in progress?
long lastEvent = 0;
int frame_number; ///< Current frame number