rnd-20001125-3-src
[rocksndiamonds.git] / src / events.c
index a46f3548117071086e8be052b6024e40e7c0647b..8d6cd62195f26bbc44bf79dec0287d087dc584e4 100644 (file)
@@ -33,7 +33,7 @@
    delay problems with lots of mouse motion events when mouse
    button not pressed */
 
-int EventFilter(const Event *event)
+int FilterMouseMotionEvents(const Event *event)
 {
   if (event->type != EVENT_MOTIONNOTIFY)
     return 1;
@@ -55,7 +55,7 @@ void EventLoop(void)
 
       NextEvent(&event);
 
-      if (EventFilter(&event))
+      if (FilterMouseMotionEvents(&event))
       {
        switch(event.type)
        {
@@ -79,13 +79,15 @@ void EventLoop(void)
        }
       }
     }
-
-    HandleNoXEvent();
+    else
+      HandleNoEvent();
 
     /* don't use all CPU time when idle; the main loop while playing
        has its own synchronization and is CPU friendly, too */
 
-    if (game_status != PLAYING)
+    if (game_status == PLAYING)
+      HandleGameActions();
+    else
     {
       SyncDisplay();
       if (!PendingEvent())     /* delay only if no pending events */
@@ -121,7 +123,7 @@ void HandleOtherEvents(Event *event)
       HandleClientMessageEvent((ClientMessageEvent *) event);
       break;
 
-#ifdef USE_SDL_LIBRARY
+#ifdef USE_SDL_JOYSTICK
     case SDL_JOYAXISMOTION:
     case SDL_JOYBUTTONDOWN:
     case SDL_JOYBUTTONUP:
@@ -204,7 +206,7 @@ void SleepWhileUnmapped()
 
 void HandleExposeEvent(ExposeEvent *event)
 {
-#ifndef USE_SDL_LIBRARY
+#ifndef TARGET_SDL
   int x = event->x, y = event->y;
   int width = event->width, height = event->height;
 
@@ -258,7 +260,7 @@ void HandleMotionEvent(MotionEvent *event)
   if (!PointerInWindow(window))
     return;    /* window and pointer are on different screens */
 
-#if 0
+#if 1
   if (button_status == MB_RELEASED && game_status != LEVELED)
     return;
 #endif
@@ -324,7 +326,7 @@ void HandleFocusEvent(FocusChangeEvent *event)
 
 void HandleClientMessageEvent(ClientMessageEvent *event)
 {
-#ifdef USE_SDL_LIBRARY
+#ifdef TARGET_SDL
   CloseAllAndExit(0);  /* the only possible message here is SDL_QUIT */
 #else
 #ifndef MSDOS
@@ -424,6 +426,7 @@ void HandleButton(int mx, int my, int button)
 void HandleKey(Key key, int key_status)
 {
   int joy = 0;
+  boolean anyTextGadgetActiveOrJustFinished = anyTextGadgetActive();
   static struct SetupKeyboardInfo custom_key;
   static struct
   {
@@ -587,7 +590,8 @@ void HandleKey(Key key, int key_status)
       break;
 
     case LEVELED:
-      HandleLevelEditorKeyInput(key);
+      if (!anyTextGadgetActiveOrJustFinished)
+       HandleLevelEditorKeyInput(key);
       break;
 
     case PLAYING:
@@ -738,7 +742,7 @@ void HandleKey(Key key, int key_status)
   }
 }
 
-void HandleNoXEvent()
+void HandleNoEvent()
 {
   if (button_status && game_status != PLAYING)
   {
@@ -752,9 +756,6 @@ void HandleNoXEvent()
 #endif
 
   HandleJoystick();
-
-  if (game_status == PLAYING)
-    HandleGameActions();
 }
 
 static int HandleJoystickForAllPlayers()