From 0182ab6eb3cb445065b2100f6cfc35d8780016ce Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 1 Apr 2020 21:43:04 +0100 Subject: [PATCH] Get drag-and-drop working again --- src/Backends/Platform.h | 1 + src/Backends/Platform/GLFW3.cpp | 12 ++++++++++++ src/Backends/Platform/SDL2.cpp | 5 +++++ src/Main.cpp | 2 +- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Backends/Platform.h b/src/Backends/Platform.h index edb53c54..544fdcd5 100644 --- a/src/Backends/Platform.h +++ b/src/Backends/Platform.h @@ -11,6 +11,7 @@ BOOL PlatformBackend_GetBasePath(char *string_buffer); void PlatformBackend_HideMouse(void); void PlatformBackend_SetWindowIcon(const unsigned char *rgb_pixels, unsigned int width, unsigned int height); void PlatformBackend_SetCursor(const unsigned char *rgb_pixels, unsigned int width, unsigned int height); +void PlaybackBackend_EnableDragAndDrop(void); BOOL PlatformBackend_SystemTask(void); void PlatformBackend_ShowMessageBox(const char *title, const char *message); unsigned long PlatformBackend_GetTicks(void); diff --git a/src/Backends/Platform/GLFW3.cpp b/src/Backends/Platform/GLFW3.cpp index bcc418c5..ff51ef6e 100644 --- a/src/Backends/Platform/GLFW3.cpp +++ b/src/Backends/Platform/GLFW3.cpp @@ -217,6 +217,13 @@ static void WindowSizeCallback(GLFWwindow *window, int width, int height) Backend_HandleWindowResize(width, height); } +static void DragAndDropCallback(GLFWwindow *window, int count, const char **paths) +{ + (void)window; + + LoadProfile(paths[0]); +} + void PlatformBackend_Init(void) { glfwInit(); @@ -313,6 +320,11 @@ void PlatformBackend_SetCursor(const unsigned char *rgb_pixels, unsigned int wid } } +void PlaybackBackend_EnableDragAndDrop(void) +{ + glfwSetDropCallback(window, DragAndDropCallback); +} + BOOL PlatformBackend_SystemTask(void) { if (glfwWindowShouldClose(window)) diff --git a/src/Backends/Platform/SDL2.cpp b/src/Backends/Platform/SDL2.cpp index ef10f97f..8d8ed4f1 100644 --- a/src/Backends/Platform/SDL2.cpp +++ b/src/Backends/Platform/SDL2.cpp @@ -85,6 +85,11 @@ void PlatformBackend_SetCursor(const unsigned char *rgb_pixels, unsigned int wid SDL_SetCursor(cursor); } +void PlaybackBackend_EnableDragAndDrop(void) +{ + SDL_EventState(SDL_DROPFILE, SDL_ENABLE); +} + BOOL PlatformBackend_SystemTask(void) { while (SDL_PollEvent(NULL) || !bActive) diff --git a/src/Main.cpp b/src/Main.cpp index 33618639..344e2b44 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -270,7 +270,7 @@ int main(int argc, char *argv[]) } #ifdef DEBUG_SAVE - //SDL_EventState(SDL_DROPFILE, SDL_ENABLE); + PlaybackBackend_EnableDragAndDrop(); #endif // Set up window icon