+
+/* event filter especially needed for SDL event filtering due to
+ delay problems with lots of mouse motion events when mouse
+ button not pressed */
+
+int FilterMouseMotionEvents(const Event *event)
+{
+ if (event->type != EVENT_MOTIONNOTIFY)
+ return 1;
+
+ /* get mouse motion events without pressed button only in level editor */
+ if (button_status == MB_RELEASED && game_status != LEVELED)
+ return 0;
+ else
+ 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;
+}
+