1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Fixed possible freezes while dragging visible area on minimap (#638)

This commit is contained in:
Arseniy Lartsev
2020-05-03 00:26:30 +02:00
committed by GitHub
parent cfe33e6b6e
commit fca9bcdd7f

View File

@@ -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();
}
}