Mercurial > fife-parpg
diff engine/core/eventchannel/eventmanager.cpp @ 96:76fb866be8ea
Add input and app focus events (e.g. iconify) (patch by phiker)
author | spq@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sun, 20 Jul 2008 19:42:37 +0000 |
parents | 90005975cdbb |
children | c512dff398c2 |
line wrap: on
line diff
--- a/engine/core/eventchannel/eventmanager.cpp Sun Jul 20 19:40:21 2008 +0000 +++ b/engine/core/eventchannel/eventmanager.cpp Sun Jul 20 19:42:37 2008 +0000 @@ -508,9 +508,35 @@ cmd.setSource(this); cmd.setCommandType(CMD_QUIT_GAME); dispatchCommand(cmd); + } break; + case SDL_ACTIVEEVENT: { + Command cmd; + cmd.setSource(this); + SDL_ActiveEvent actevt = event.active; + if (actevt.state == SDL_APPMOUSEFOCUS) + { + if (actevt.gain) + cmd.setCommandType(CMD_MOUSE_FOCUS_GAINED); + else + cmd.setCommandType(CMD_MOUSE_FOCUS_LOST); } - case SDL_ACTIVEEVENT: + else if (actevt.state == SDL_APPINPUTFOCUS) + { + if (actevt.gain) + cmd.setCommandType(CMD_INPUT_FOCUS_GAINED); + else + cmd.setCommandType(CMD_INPUT_FOCUS_LOST); + } + else if (actevt.state == SDL_APPACTIVE) + { + if (actevt.gain) + cmd.setCommandType(CMD_APP_RESTORED); + else + cmd.setCommandType(CMD_APP_ICONIFIED); + } + dispatchCommand(cmd); + } break; case SDL_KEYDOWN: case SDL_KEYUP: { @@ -541,8 +567,8 @@ } } dispatchMouseEvent(mouseevt); + } break; - } } }