fixed handling global animation key event actions multiple times
[rocksndiamonds.git] / src / events.c
index e4f3329e32ab740df7fd18246735a97d19b7c4f2..11fd28f40035daab17fc49caf6e05a0995b8262c 100644 (file)
@@ -218,6 +218,10 @@ static void HandleEvents(void)
        HandleKeyEvent((KeyEvent *) &event);
        break;
 
+      case EVENT_USER:
+       HandleUserEvent((UserEvent *) &event);
+       break;
+
       default:
        HandleOtherEvents(&event);
        break;
@@ -233,10 +237,6 @@ void HandleOtherEvents(Event *event)
 {
   switch (event->type)
   {
-    case EVENT_CLIENTMESSAGE:
-      HandleClientMessageEvent((ClientMessageEvent *) event);
-      break;
-
     case SDL_CONTROLLERBUTTONDOWN:
     case SDL_CONTROLLERBUTTONUP:
       // for any game controller button event, disable overlay buttons
@@ -261,6 +261,10 @@ void HandleOtherEvents(Event *event)
       HandleDropEvent(event);
       break;
 
+    case EVENT_QUIT:
+      CloseAllAndExit(0);
+      break;
+
     default:
       break;
   }
@@ -1424,12 +1428,6 @@ void HandleKeyEvent(KeyEvent *event)
     HandleKey(key, key_status);
 }
 
-void HandleClientMessageEvent(ClientMessageEvent *event)
-{
-  if (CheckCloseWindowEvent(event))
-    CloseAllAndExit(0);
-}
-
 static int HandleDropFileEvent(char *filename)
 {
   Error(ERR_DEBUG, "DROP FILE EVENT: '%s'", filename);
@@ -1605,6 +1603,15 @@ void HandleDropEvent(Event *event)
     SDL_free(event->drop.file);
 }
 
+void HandleUserEvent(UserEvent *event)
+{
+  switch (event->code)
+  {
+    default:
+      break;
+  }
+}
+
 void HandleButton(int mx, int my, int button, int button_nr)
 {
   static int old_mx = 0, old_my = 0;
@@ -2138,9 +2145,12 @@ void HandleKey(Key key, int key_status)
     return;
   }
 
-  if (HandleGlobalAnimClicks(-1, -1, (key == KSYM_space ||
-                                     key == KSYM_Return ||
-                                     key == KSYM_Escape), TRUE))
+  // some key events are handled like clicks for global animations
+  boolean click = (key == KSYM_space ||
+                  key == KSYM_Return ||
+                  key == KSYM_Escape);
+
+  if (click && HandleGlobalAnimClicks(-1, -1, MB_LEFTBUTTON, TRUE))
   {
     // do not handle this key event anymore
     if (key != KSYM_Escape)    // always allow ESC key to be handled