Fix #1736: on GNU/Linux, a hotkey can trigger multiple commands

SDL_TEXTINPUT events aren't generated on Windows when Alt is held down.
Let's ensure that the behavior is the same on all platforms.
This commit is contained in:
Jyrki Vesterinen 2018-04-10 19:00:54 +03:00
parent 15fdabbac9
commit c42401a8de

View file

@ -488,6 +488,15 @@ void run_event_loop()
last_resize_event_used = true;
}
if(SDL_GetModState() & KMOD_ALT) {
// Remove text input events, to match the behavior on Windows
// See https://github.com/wesnoth/wesnoth/issues/1736
events.erase(
std::remove_if(events.begin(), events.end(), [](const SDL_Event& e) { return e.type == SDL_TEXTINPUT; }),
events.end()
);
}
ev_end = events.end();
for(ev_it = events.begin(); ev_it != ev_end; ++ev_it) {