diff --git a/src/main.cpp b/src/main.cpp index eecab7d..de9bef7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,6 +23,7 @@ #include #define WM_USER_CLOSE (WM_USER + 1) +#define WM_USER_WAKEUP (WM_USER + 2) LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp); HINSTANCE hInst; @@ -108,7 +109,7 @@ void destroy_window() { std::lock_guard lock(main_task_mutex); main_tasklist.emplace_back([=] { - SendMessage(hWnd, WM_USER_CLOSE, 0, 0); + PostMessage(hWnd, WM_USER_CLOSE, 0, 0); }); } @@ -196,10 +197,13 @@ void win32_update_fps(int frames) else swprintf_s(title_fps, L"%s - %d fps", window_title, frames); - std::lock_guard lock(main_task_mutex); - main_tasklist.emplace_back([] { - SetWindowText(hWnd, title_fps); - }); + { + std::lock_guard lock(main_task_mutex); + main_tasklist.emplace_back([] { + SetWindowText(hWnd, title_fps); + }); + } + PostMessage(hWnd, WM_USER_WAKEUP, 0, 0); } void win32_show_cursor(bool visible)