added experimental (cross-platform) drag and drop test code
authorHolger Schemel <info@artsoft.org>
Thu, 10 Jan 2019 19:03:25 +0000 (20:03 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 12 Jan 2019 19:49:46 +0000 (20:49 +0100)
src/events.c
src/events.h

index e770480..f8a888a 100644 (file)
@@ -268,6 +268,14 @@ void HandleOtherEvents(Event *event)
       HandleJoystickEvent(event);
       break;
 
+    case SDL_DROPFILE:
+      HandleDropFileEvent(event);
+      break;
+
+    case SDL_DROPTEXT:
+      HandleDropTextEvent(event);
+      break;
+
     default:
       break;
   }
@@ -1518,6 +1526,30 @@ void HandleClientMessageEvent(ClientMessageEvent *event)
     CloseAllAndExit(0);
 }
 
+static void HandleDropFileEventExt(char *filename)
+{
+  Error(ERR_DEBUG, "DROP FILE EVENT: '%s'", filename);
+}
+
+static void HandleDropTextEventExt(char *text)
+{
+  Error(ERR_DEBUG, "DROP TEXT EVENT: '%s'", text);
+}
+
+void HandleDropFileEvent(Event *event)
+{
+  HandleDropFileEventExt(event->drop.file);
+
+  SDL_free(event->drop.file);
+}
+
+void HandleDropTextEvent(Event *event)
+{
+  HandleDropTextEventExt(event->drop.file);
+
+  SDL_free(event->drop.file);
+}
+
 void HandleButton(int mx, int my, int button, int button_nr)
 {
   static int old_mx = 0, old_my = 0;
index c90580b..5c0630e 100644 (file)
@@ -35,6 +35,8 @@ boolean HandleKeysDebug(Key, int);
 void HandleKeyEvent(KeyEvent *);
 void HandleFocusEvent(FocusChangeEvent *);
 void HandleClientMessageEvent(ClientMessageEvent *);
+void HandleDropFileEvent(Event *);
+void HandleDropTextEvent(Event *);
 
 void HandleToonAnimations(void);