clear modstate on window focus

this fixes the issue where the alt modstate was getting stuck on systems
that don't send standard keyup events after alt-tab. for example, in KDE
Plasma (on Gentoo, at least), the keyup event when alt is released after
alt-tab contains an incorrect keycode (NUMLOCK instead of L_ALT), which
was preventing us from correctly clearing the alt modstate.
develop
myk002 2021-08-06 07:10:42 -07:00
parent 063c512389
commit 192dfd51ee
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
1 changed files with 10 additions and 3 deletions

@ -2472,13 +2472,20 @@ int UnicodeAwareSym(const SDL::KeyboardEvent& ke)
//MEMO: return false if event is consumed //MEMO: return false if event is consumed
int Core::DFH_SDL_Event(SDL::Event* ev) int Core::DFH_SDL_Event(SDL::Event* ev)
{ {
//static bool alt = 0;
// do NOT process events before we are ready. // do NOT process events before we are ready.
if(!started) return true; if(!started) return true;
if(!ev) if(!ev)
return true; return true;
if(ev && (ev->type == SDL::ET_KEYDOWN || ev->type == SDL::ET_KEYUP))
if(ev->type == SDL::ET_ACTIVEEVENT && ev->active.gain)
{
// clear modstate when gaining focus in case alt-tab was used when
// losing focus and modstate is now incorrectly set
modstate = 0;
return true;
}
if(ev->type == SDL::ET_KEYDOWN || ev->type == SDL::ET_KEYUP)
{ {
auto ke = (SDL::KeyboardEvent *)ev; auto ke = (SDL::KeyboardEvent *)ev;