# HG changeset patch # User Ozkan Sezer # Date 1525154110 -10800 # Node ID 56b0b4c9bd760082afdddc8ec04ce5cf51ddc8d3 # Parent bc2aba33ae1f87a0ba8256bec8ee3829010c7893 restrict the win10 mouse bug workaround to win10 v1709 only. diff -r bc2aba33ae1f -r 56b0b4c9bd76 src/video/windows/SDL_windowsevents.c --- a/src/video/windows/SDL_windowsevents.c Mon Apr 23 22:29:14 2018 -0700 +++ b/src/video/windows/SDL_windowsevents.c Tue May 01 09:04:11 2018 +0300 @@ -359,10 +359,11 @@ ShouldGenerateWindowCloseOnAltF4(void) return !SDL_GetHintBoolean(SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4, SDL_FALSE); } -/* Win10 "Fall Creators Update" introduced the bug that SetCursorPos() (as used by SDL_WarpMouseInWindow()) - doesn't reliably generate WM_MOUSEMOVE events anymore (see #3931) which breaks relative mouse mode via warping. - This is used to implement a workaround.. */ -static SDL_bool isWin10FCUorNewer = SDL_FALSE; +/* Windows10 v1709 "Fall Creators Update" introduced the bug that SetCursorPos(), as + used by SDL_WarpMouseInWindow(), doesn't reliably generate WM_MOUSEMOVE events + anymore (see #3931), which breaks relative mouse mode via warping. This issue + seems to be fixed in Win10 v1803 update. This implement a workaround for v1709. */ +static SDL_bool isWin10_v1709 = SDL_FALSE; LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) @@ -486,7 +487,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPAR if (!mouse->relative_mode || mouse->relative_mode_warp) { SDL_MouseID mouseID = (((GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) ? SDL_TOUCH_MOUSEID : 0); SDL_SendMouseMotion(data->window, mouseID, 0, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); - if (isWin10FCUorNewer && mouseID != SDL_TOUCH_MOUSEID && mouse->relative_mode_warp) { + if (isWin10_v1709 && mouseID != SDL_TOUCH_MOUSEID && mouse->relative_mode_warp) { /* To work around #3931, Win10 bug introduced in Fall Creators Update, where SetCursorPos() (SDL_WarpMouseInWindow()) doesn't reliably generate mouse events anymore, after each windows mouse event generate a fake event for the middle of the window @@ -1076,7 +1077,7 @@ WIN_PumpEvents(_THIS) /* to work around #3931, a bug introduced in Win10 Fall Creators Update (build nr. 16299) we need to detect the windows version. this struct and the function below does that. - usually this struct and the corresponding function (RtlGetVersion) are in + usually this struct and the corresponding function (RtlGetVersion) are in but here we just load it dynamically */ struct SDL_WIN_OSVERSIONINFOW { ULONG dwOSVersionInfoSize; @@ -1088,7 +1089,7 @@ struct SDL_WIN_OSVERSIONINFOW { }; static SDL_bool -IsWin10FCUorNewer(void) +IsWin10_v1709(void) { HMODULE handle = GetModuleHandleW(L"ntdll.dll"); if (handle) { @@ -1099,10 +1100,7 @@ IsWin10FCUorNewer(void) SDL_zero(info); info.dwOSVersionInfoSize = sizeof(info); if (getVersionPtr(&info) == 0) { /* STATUS_SUCCESS == 0 */ - if ( (info.dwMajorVersion == 10 && info.dwMinorVersion == 0 && info.dwBuildNumber >= 16299) - || (info.dwMajorVersion == 10 && info.dwMinorVersion > 0) - || (info.dwMajorVersion > 10) ) - { + if (info.dwMajorVersion == 10 && info.dwMinorVersion == 0 && info.dwBuildNumber == 16299) { return SDL_TRUE; } } @@ -1175,7 +1173,7 @@ SDL_RegisterApp(char *name, Uint32 style return SDL_SetError("Couldn't register application class"); } - isWin10FCUorNewer = IsWin10FCUorNewer(); + isWin10_v1709 = IsWin10_v1709(); app_registered = 1; return 0;