public
Fork of jacius/rubygame
Description: Flexible game creation library for Ruby
Homepage: http://rubygame.sourceforge.net
Clone URL: git://github.com/atiaxi/rubygame.git
fetch_sdl_events will no longer be confused if more than one SDL_ACTIVE*
event happens at once (i.e. window iconified and loses focus)
atiaxi (author)
Sun Aug 31 13:36:35 -0700 2008
commit  1580e8a81e719d9db6d3f4c1a0b2284b6f579e68
tree    4c05befc2eec518bd76965b3bd3e87cc3042ddd9
parent  d983161d52b6a37c075e0a2dfe5ca57a3899f7a2
...
50
51
52
 
 
53
54
55
56
57
58
59
60
61
62
63
64
65
 
 
 
 
 
66
67
68
69
70
71
72
73
 
74
75
76
...
50
51
52
53
54
55
56
57
58
59
60
 
 
 
 
 
 
 
61
62
63
64
65
66
 
 
 
 
 
 
 
67
68
69
70
0
@@ -50,27 +50,21 @@ VALUE rg_make_rbevent( char *klassname, int argc, VALUE *argv )
0
  *   WindowMinimized  / WindowUnMinimized
0
  *
0
  * Which class we use depends on the details of the ACTIVEEVENT.
0
+ * If more than one happens at once, WindowMinimized/UnMinimized has first
0
+ * priority, then InputFocusGained/Lost then MouseFocusGained/Lost
0
  *
0
  */
0
 VALUE rg_convert_activeevent( SDL_Event ev )
0
 {
0
   char *klassname;
0
 
0
-  switch( ev.active.state )
0
-  {
0
-    case SDL_APPINPUTFOCUS:
0
-      klassname = ev.active.gain ? "InputFocusGained" : "InputFocusLost";
0
-      break;
0
-
0
-    case SDL_APPMOUSEFOCUS:
0
+  if(ev.active.state | SDL_APPACTIVE){
0
+    klassname = ev.active.gain ? "WindowUnminimized" : "WindowMinimized";
0
+  } else if(ev.active.state | SDL_APPINPUTFOCUS) {
0
+    klassname = ev.active.gain ? "InputFocusGained" : "InputFocusLost";
0
+  } else if(ev.active.state | SDL_APPMOUSEFOCUS) {
0
       klassname = ev.active.gain ? "MouseFocusGained" : "MouseFocusLost";
0
-      break;
0
-
0
-    case SDL_APPACTIVE:
0
-      klassname = ev.active.gain ? "WindowUnminimized" : "WindowMinimized";
0
-      break;
0
-
0
-    default:
0
+  } else {
0
       rb_raise(eSDLError, 
0
                "unknown ACTIVEEVENT state %d. This is a bug in Rubygame.",
0
                ev.active.state);

Comments