Add facility to run callbacks on the window thread

This commit is contained in:
Henrik Rydgård
2024-04-06 12:14:29 +02:00
parent 616ee81f84
commit 9ec5efdcc5
6 changed files with 31 additions and 2 deletions

View File

@@ -144,3 +144,9 @@ void System_ShowFileInFolder(const Path &path) {
void System_BrowseForFolder(RequesterToken token, std::string_view title, const Path &initialPath, RequestCallback callback, RequestFailedCallback failedCallback) {
g_requestManager.MakeSystemRequest(SystemRequestType::BROWSE_FOR_FOLDER, token, callback, failedCallback, title, initialPath.ToCString(), 0);
}
void System_RunCallbackInWndProc(void (*callback)(void *, void *), void *userdata) {
int64_t castPtr = (int64_t)callback;
int64_t castUserData = (int64_t)userdata;
g_requestManager.MakeSystemRequest(SystemRequestType::RUN_CALLBACK_IN_WNDPROC, NO_REQUESTER_TOKEN, nullptr, nullptr, "", "", castPtr, castUserData);
}

View File

@@ -176,6 +176,8 @@ inline void System_SendDebugScreenshot(std::string_view data, int height) {
g_requestManager.MakeSystemRequest(SystemRequestType::SEND_DEBUG_SCREENSHOT, NO_REQUESTER_TOKEN, nullptr, nullptr, data, "", height);
}
void System_RunCallbackInWndProc(void (*callback)(void *, void *), void *userdata);
// Non-inline to avoid including Path.h
void System_CreateGameShortcut(const Path &path, std::string_view title);
void System_ShowFileInFolder(const Path &path);

View File

@@ -86,6 +86,8 @@ enum class SystemRequestType {
GPS_COMMAND,
INFRARED_COMMAND,
MICROPHONE_COMMAND,
RUN_CALLBACK_IN_WNDPROC,
};
// Implementations are supposed to process the request, and post the response to the g_RequestManager (see Message.h).