changeset 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 0b6998fde366
children 346738d09188
files engine/core/eventchannel/command/ec_commandids.h engine/core/eventchannel/eventmanager.cpp
diffstat 2 files changed, 34 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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;
-					}
 			}
 		}