From 774ff2bbaf1250cecefec6e4094fc98d3566f1d5 Mon Sep 17 00:00:00 2001 From: Mia Herkt Date: Mon, 18 Jan 2021 05:03:16 +0100 Subject: [PATCH] audio display: limit mouse event rate Same as with visual typesetting. --- src/audio_display.cpp | 7 +++++++ src/audio_display.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/audio_display.cpp b/src/audio_display.cpp index 2756ac3ff..9713c5add 100644 --- a/src/audio_display.cpp +++ b/src/audio_display.cpp @@ -1045,6 +1045,13 @@ void AudioDisplay::OnMouseLeave(wxMouseEvent&) 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 // outside our client rectangle, we don't want those. if (event.Moving() && !GetClientRect().Contains(event.GetPosition())) diff --git a/src/audio_display.h b/src/audio_display.h index 4c8e26a5f..93f100ef4 100644 --- a/src/audio_display.h +++ b/src/audio_display.h @@ -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