From 69d28027adb70daf962621bb5e8ab00a069cbe30 Mon Sep 17 00:00:00 2001 From: Clint Kilmer Date: Sat, 8 Feb 2025 12:21:10 -0700 Subject: [PATCH] Fix for 500ms hang after user clicks on the title bar, but before moving (#12217) Reference: https://gamedev.net/forums/topic/672094-keeping-things-moving-during-win32-moveresize-events/5254386/ --- src/video/windows/SDL_windowsevents.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index 947a05e4f4b00..af3407c407dc7 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -1525,6 +1525,15 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara case WM_NCLBUTTONDOWN: { data->in_title_click = true; + + // Fix for 500ms hang after user clicks on the title bar, but before moving mouse + // Reference: https://gamedev.net/forums/topic/672094-keeping-things-moving-during-win32-moveresize-events/5254386/ + if (SendMessage(hwnd, WM_NCHITTEST, wParam, lParam) == HTCAPTION) { + POINT cursorPos; + GetCursorPos(&cursorPos); + ScreenToClient(hwnd, &cursorPos); + PostMessage(hwnd, WM_MOUSEMOVE, 0, cursorPos.x | cursorPos.y << 16); + } } break; case WM_CAPTURECHANGED: