audio display: limit mouse event rate
Same as with visual typesetting.
This commit is contained in:
parent
ca1ac8bcea
commit
71fb001d25
2 changed files with 10 additions and 0 deletions
|
@ -1045,6 +1045,13 @@ void AudioDisplay::OnMouseLeave(wxMouseEvent&)
|
||||||
|
|
||||||
void AudioDisplay::OnMouseEvent(wxMouseEvent& event)
|
void AudioDisplay::OnMouseEvent(wxMouseEvent& event)
|
||||||
{
|
{
|
||||||
|
// wx doesn’t throttle for us, updating the video view is
|
||||||
|
// very expensive, and aegisub’s 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
|
// 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.
|
// outside our client rectangle, we don't want those.
|
||||||
if (event.Moving() && !GetClientRect().Contains(event.GetPosition()))
|
if (event.Moving() && !GetClientRect().Contains(event.GetPosition()))
|
||||||
|
|
|
@ -130,6 +130,9 @@ class AudioDisplay: public wxWindow {
|
||||||
/// Zoom level given as a number, see SetZoomLevel for details
|
/// Zoom level given as a number, see SetZoomLevel for details
|
||||||
int zoom_level;
|
int zoom_level;
|
||||||
|
|
||||||
|
/// Time since last mouse event
|
||||||
|
long last_event = 0;
|
||||||
|
|
||||||
/// Absolute pixel position of the tracking cursor (mouse or playback)
|
/// Absolute pixel position of the tracking cursor (mouse or playback)
|
||||||
int track_cursor_pos = -1;
|
int track_cursor_pos = -1;
|
||||||
/// Label to show by track cursor
|
/// Label to show by track cursor
|
||||||
|
|
Loading…
Reference in a new issue