audio display: limit mouse event rate

Same as with visual typesetting.
This commit is contained in:
Mia Herkt 2021-01-18 05:03:16 +01:00
parent 07e4d38198
commit b4f54a3adc
Signed by: mia
SSH key fingerprint: SHA256:wqxNmz1v3S4rHhF0I3z/ogVueFRUac93swSgNGfr8No
2 changed files with 10 additions and 0 deletions

View file

@ -1045,6 +1045,13 @@ void AudioDisplay::OnMouseLeave(wxMouseEvent&)
void AudioDisplay::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 - last_event) < 5) return;
last_event = ts;
// If we have focus, we get mouse move events on Mac even when the mouse is
// outside our client rectangle, we don't want those.
if (event.Moving() && !GetClientRect().Contains(event.GetPosition()))

View file

@ -130,6 +130,9 @@ class AudioDisplay: public wxWindow {
/// Zoom level given as a number, see SetZoomLevel for details
int zoom_level;
/// Time since last mouse event
long last_event = 0;
/// Absolute pixel position of the tracking cursor (mouse or playback)
int track_cursor_pos = -1;
/// Label to show by track cursor