Fixed bug 2520 - Held double-click app startup creates a stuck MOUSEBUTTONDOWN event snake5creator When starting application with the usual "double click on file" method on Windows, only holding the last click, an unnecessary MOUSEBUTTONDOWN event is sent before the initial MOUSEMOTION event, and mouse button state is stuck in the sense that it takes a subsequent button release, followed by another press for the system to resume sending events (beginning with the next button release / MOUSEBUTTONUP event). Input event log with held double-click startup: http://i.imgur.com/nypGKR2.png Without: http://i.imgur.com/yaIqAvV.png
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index 78eeff9..24e0f19 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -275,15 +275,25 @@ WIN_CheckAsyncMouseRelease( SDL_WindowData *data )
mouseFlags = SDL_GetMouseState( NULL, NULL );
keyState = GetAsyncKeyState( VK_LBUTTON );
- WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), ( mouseFlags & SDL_BUTTON_LMASK ), data, SDL_BUTTON_LEFT );
- keyState = GetAsyncKeyState( VK_RBUTTON );
- WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), ( mouseFlags & SDL_BUTTON_RMASK ), data, SDL_BUTTON_RIGHT );
- keyState = GetAsyncKeyState( VK_MBUTTON );
- WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), ( mouseFlags & SDL_BUTTON_MMASK ), data, SDL_BUTTON_MIDDLE );
- keyState = GetAsyncKeyState( VK_XBUTTON1 );
- WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), ( mouseFlags & SDL_BUTTON_X1MASK ), data, SDL_BUTTON_X1 );
- keyState = GetAsyncKeyState( VK_XBUTTON2 );
- WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), ( mouseFlags & SDL_BUTTON_X2MASK ), data, SDL_BUTTON_X2 );
+ if (!(keyState & 0x8000)) {
+ WIN_CheckWParamMouseButton(SDL_FALSE, (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT);
+ }
+ keyState = GetAsyncKeyState(VK_RBUTTON);
+ if (!(keyState & 0x8000)) {
+ WIN_CheckWParamMouseButton(SDL_FALSE, (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT);
+ }
+ keyState = GetAsyncKeyState(VK_MBUTTON);
+ if (!(keyState & 0x8000)) {
+ WIN_CheckWParamMouseButton(SDL_FALSE, (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE);
+ }
+ keyState = GetAsyncKeyState(VK_XBUTTON1);
+ if (!(keyState & 0x8000)) {
+ WIN_CheckWParamMouseButton(SDL_FALSE, (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1);
+ }
+ keyState = GetAsyncKeyState(VK_XBUTTON2);
+ if (!(keyState & 0x8000)) {
+ WIN_CheckWParamMouseButton(SDL_FALSE, (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2);
+ }
data->mouse_button_flags = 0;
}
@@ -368,6 +378,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_ACTIVATE:
{
+ POINT cursorPos;
BOOL minimized;
minimized = HIWORD(wParam);
@@ -377,6 +388,11 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
SDL_SetKeyboardFocus(data->window);
}
WIN_UpdateClipCursor(data->window);
+
+ GetCursorPos(&cursorPos);
+ ScreenToClient(hwnd, &cursorPos);
+ SDL_SendMouseMotion(data->window, 0, 0, cursorPos.x, cursorPos.y);
+
WIN_CheckAsyncMouseRelease(data);
/*