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
+11
View File
@@ -764,6 +764,13 @@ namespace MainWindow
}
break;
case WM_USER_RUN_CALLBACK:
{
auto callback = reinterpret_cast<void (*)(void *window, void *userdata)>(wParam);
void *userdata = reinterpret_cast<void *>(lParam);
callback(hWnd, userdata);
break;
}
case WM_USER_GET_BASE_POINTER:
Reporting::NotifyDebugger();
switch (lParam) {
@@ -1135,4 +1142,8 @@ namespace MainWindow
return g_isFullscreen;
}
void RunCallbackInWndProc(void (*callback)(void *, void *), void *userdata) {
PostMessage(hwndMain, WM_USER_RUN_CALLBACK, reinterpret_cast<WPARAM>(callback), reinterpret_cast<LPARAM>(userdata));
}
} // namespace