rnd-20001206-1-src
[rocksndiamonds.git] / src / events.c
index 1e2ca16841661450886d719a2f701e0c8eea49be..f4e690f82c2ddbe6b6d3f3aba10df575f4bc9025 100644 (file)
@@ -45,6 +45,23 @@ int FilterMouseMotionEvents(const Event *event)
     return 1;
 }
 
+/* this is only really needed for non-SDL targets to filter unwanted events;
+   when using SDL with properly installed event filter, this function can be
+   replaced with a simple "NextEvent()" call, but it doesn't hurt either */
+
+static boolean NextValidEvent(Event *event)
+{
+  while (PendingEvent())
+  {
+    NextEvent(event);
+
+    if (FilterMouseMotionEvents(event))
+      return TRUE;
+  }
+
+  return FALSE;
+}
+
 void EventLoop(void)
 {
   while(1)
@@ -53,9 +70,7 @@ void EventLoop(void)
     {
       Event event;
 
-      NextEvent(&event);
-
-      if (FilterMouseMotionEvents(&event))
+      if (NextValidEvent(&event))
       {
        switch(event.type)
        {