Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.

Testing:
* Set the SDL_HINT_MOUSE_RELATIVE_MODE_WARP hint true, run testsprite2, press Ctrl-R to enter relative mode, alt tab away from the window, then click on the title bar of the window. Didn't get the mouse button release before, and we do now.

CR: Yahn + Alfred
This commit is contained in:
Sam Lantinga 2014-02-13 11:05:28 -08:00
parent 567b5ba8e9
commit e34da6801f

View File

@ -259,6 +259,30 @@ WIN_CheckRawMouseButtons( ULONG rawButtons, SDL_WindowData *data )
} }
} }
void
WIN_CheckAsyncMouseRelease( SDL_WindowData *data )
{
Uint32 mouseFlags;
SHORT keyState;
/* mouse buttons may have changed state here, we need to resync them,
but we will get a WM_MOUSEMOVE right away which will fix things up if in non raw mode also
*/
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 );
data->mouse_button_flags = 0;
}
SDL_FORCE_INLINE BOOL SDL_FORCE_INLINE BOOL
WIN_ConvertUTF32toUTF8(UINT32 codepoint, char * text) WIN_ConvertUTF32toUTF8(UINT32 codepoint, char * text)
{ {
@ -344,32 +368,12 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
minimized = HIWORD(wParam); minimized = HIWORD(wParam);
if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) { if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) {
Uint32 mouseFlags;
SHORT keyState;
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0); SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);
if (SDL_GetKeyboardFocus() != data->window) { if (SDL_GetKeyboardFocus() != data->window) {
SDL_SetKeyboardFocus(data->window); SDL_SetKeyboardFocus(data->window);
} }
/* mouse buttons may have changed state here, we need
to resync them, but we will get a WM_MOUSEMOVE right away which will fix
things up if in non raw mode also
*/
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 );
data->mouse_button_flags = 0;
WIN_UpdateClipCursor(data->window); WIN_UpdateClipCursor(data->window);
WIN_CheckAsyncMouseRelease(data);
/* /*
* FIXME: Update keyboard state * FIXME: Update keyboard state
@ -578,6 +582,9 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
data->in_modal_loop = SDL_FALSE; data->in_modal_loop = SDL_FALSE;
WIN_UpdateClipCursor(data->window); WIN_UpdateClipCursor(data->window);
/* The mouse may have been released during the modal loop */
WIN_CheckAsyncMouseRelease(data);
} }
break; break;