From fca9bcdd7f0ff730a70ddc3efbc181731c1c9c05 Mon Sep 17 00:00:00 2001 From: Arseniy Lartsev <3534650+ars3niy@users.noreply.github.com> Date: Sun, 3 May 2020 00:26:30 +0200 Subject: [PATCH] Fixed possible freezes while dragging visible area on minimap (#638) --- client/gui/CGuiHandler.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client/gui/CGuiHandler.cpp b/client/gui/CGuiHandler.cpp index 9af279bb7..b915f0cab 100644 --- a/client/gui/CGuiHandler.cpp +++ b/client/gui/CGuiHandler.cpp @@ -194,6 +194,14 @@ void CGuiHandler::handleEvents() SDL_Event ev = events.front(); current = &ev; events.pop(); + + // In a sequence of mouse motion events, skip all but the last one. + // This prevents freezes when every motion event takes longer to handle than interval at which + // the events arrive (like dragging on the minimap in world view, with redraw at every event) + // so that the events would start piling up faster than they can be processed. + if ((ev.type == SDL_MOUSEMOTION) && !events.empty() && (events.front().type == SDL_MOUSEMOTION)) + continue; + handleCurrentEvent(); } }