# HG changeset patch # User spq@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1216582957 0 # Node ID 76fb866be8ea0dccd35ce6d97a1efe3d9ebb77cf # Parent 0b6998fde3669b4ab6319f5436da93dc9e25bdbb Add input and app focus events (e.g. iconify) (patch by phiker) diff -r 0b6998fde366 -r 76fb866be8ea engine/core/eventchannel/command/ec_commandids.h --- a/engine/core/eventchannel/command/ec_commandids.h Sun Jul 20 19:40:21 2008 +0000 +++ b/engine/core/eventchannel/command/ec_commandids.h Sun Jul 20 19:42:37 2008 +0000 @@ -40,6 +40,12 @@ enum CommandType { CMD_UNKNOWN = -1, CMD_QUIT_GAME = 402, + CMD_MOUSE_FOCUS_GAINED, + CMD_MOUSE_FOCUS_LOST, + CMD_INPUT_FOCUS_GAINED, + CMD_INPUT_FOCUS_LOST, + CMD_APP_RESTORED, + CMD_APP_ICONIFIED, }; } //FIFE diff -r 0b6998fde366 -r 76fb866be8ea engine/core/eventchannel/eventmanager.cpp --- 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; - } } }