From 4acb3f83bf67a12a50f5e8084bd253bcfedfab07 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Sat, 1 May 2021 07:38:30 +1000 Subject: [PATCH] [windows] Support Startup hook --- v2/internal/ffenestri/ffenestri_windows.cpp | 18 +++++++++++++++++- v2/internal/ffenestri/ffenestri_windows.h | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/v2/internal/ffenestri/ffenestri_windows.cpp b/v2/internal/ffenestri/ffenestri_windows.cpp index 1b59de0ac..14096e05e 100644 --- a/v2/internal/ffenestri/ffenestri_windows.cpp +++ b/v2/internal/ffenestri/ffenestri_windows.cpp @@ -69,6 +69,9 @@ struct Application *NewApplication(const char *title, int width, int height, int // Capture Main Thread mainThread = GetCurrentThreadId(); + // Startup url + result->startupURL = nullptr; + return result; } @@ -88,6 +91,12 @@ void SetBindings(struct Application *app, const char *bindings) { memcpy(app->bindings, temp.c_str(), temp.length()+1); } +void performShutdown(struct Application *app) { + if( app->startupURL != nullptr ) { + delete[] app->startupURL; + } + messageFromWindowCallback("WC"); +} LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -207,6 +216,13 @@ void loadAssets(struct Application* app) { void completed(struct Application* app) { delete[] app->initialCode; app->initialCode = nullptr; + + if( app->startupURL == nullptr ) { + messageFromWindowCallback("SS"); + return; + } + std::string readyMessage = std::string("SS") + std::string(app->startupURL); + messageFromWindowCallback(readyMessage.c_str()); } @@ -341,7 +357,7 @@ void Run(struct Application* app, int argc, char **argv) { (*f)(); delete(f); } else if (msg.message == WM_QUIT) { - messageFromWindowCallback("Q"); + performShutdown(app); return; } } diff --git a/v2/internal/ffenestri/ffenestri_windows.h b/v2/internal/ffenestri/ffenestri_windows.h index 0f74ee467..23fa46a7d 100644 --- a/v2/internal/ffenestri/ffenestri_windows.h +++ b/v2/internal/ffenestri/ffenestri_windows.h @@ -41,6 +41,7 @@ struct Application{ LONG maxWidth; LONG maxHeight; int frame; + char *startupURL; // placeholders char* bindings;