Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
authorSam Lantinga <slouken@libsdl.org>
Thu, 13 Feb 2014 11:05:28 -0800
changeset 8212d278747da408
parent 8211 089bc02a5e4b
child 8213 c08568651ebb
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
src/video/windows/SDL_windowsevents.c
     1.1 --- a/src/video/windows/SDL_windowsevents.c	Thu Feb 13 11:05:26 2014 -0800
     1.2 +++ b/src/video/windows/SDL_windowsevents.c	Thu Feb 13 11:05:28 2014 -0800
     1.3 @@ -259,6 +259,30 @@
     1.4      }
     1.5  }
     1.6  
     1.7 +void
     1.8 +WIN_CheckAsyncMouseRelease( SDL_WindowData *data )
     1.9 +{
    1.10 +    Uint32 mouseFlags;
    1.11 +    SHORT keyState;
    1.12 +
    1.13 +    /* mouse buttons may have changed state here, we need to resync them,
    1.14 +       but we will get a WM_MOUSEMOVE right away which will fix things up if in non raw mode also
    1.15 +    */
    1.16 +    mouseFlags = SDL_GetMouseState( NULL, NULL );
    1.17 +
    1.18 +    keyState = GetAsyncKeyState( VK_LBUTTON );
    1.19 +    WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), ( mouseFlags & SDL_BUTTON_LMASK ), data, SDL_BUTTON_LEFT );
    1.20 +    keyState = GetAsyncKeyState( VK_RBUTTON );
    1.21 +    WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), ( mouseFlags & SDL_BUTTON_RMASK ), data, SDL_BUTTON_RIGHT );
    1.22 +    keyState = GetAsyncKeyState( VK_MBUTTON );
    1.23 +    WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), ( mouseFlags & SDL_BUTTON_MMASK ), data, SDL_BUTTON_MIDDLE );
    1.24 +    keyState = GetAsyncKeyState( VK_XBUTTON1 );
    1.25 +    WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), ( mouseFlags & SDL_BUTTON_X1MASK ), data, SDL_BUTTON_X1 );
    1.26 +    keyState = GetAsyncKeyState( VK_XBUTTON2 );
    1.27 +    WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), ( mouseFlags & SDL_BUTTON_X2MASK ), data, SDL_BUTTON_X2 );
    1.28 +    data->mouse_button_flags = 0;
    1.29 +}
    1.30 +
    1.31  SDL_FORCE_INLINE BOOL
    1.32  WIN_ConvertUTF32toUTF8(UINT32 codepoint, char * text)
    1.33  {
    1.34 @@ -344,32 +368,12 @@
    1.35  
    1.36              minimized = HIWORD(wParam);
    1.37              if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) {
    1.38 -                Uint32 mouseFlags;
    1.39 -                SHORT keyState;
    1.40 -
    1.41                  SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);
    1.42                  if (SDL_GetKeyboardFocus() != data->window) {
    1.43                      SDL_SetKeyboardFocus(data->window);
    1.44                  }
    1.45 -                /* mouse buttons may have changed state here, we need
    1.46 -                to resync them, but we will get a WM_MOUSEMOVE right away which will fix
    1.47 -                things up if in non raw mode also
    1.48 -                */
    1.49 -                mouseFlags = SDL_GetMouseState( NULL, NULL );
    1.50 -
    1.51 -                keyState = GetAsyncKeyState( VK_LBUTTON );
    1.52 -                WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT );
    1.53 -                keyState = GetAsyncKeyState( VK_RBUTTON );
    1.54 -                WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT );
    1.55 -                keyState = GetAsyncKeyState( VK_MBUTTON );
    1.56 -                WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE );
    1.57 -                keyState = GetAsyncKeyState( VK_XBUTTON1 );
    1.58 -                WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 );
    1.59 -                keyState = GetAsyncKeyState( VK_XBUTTON2 );
    1.60 -                WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 );
    1.61 -                data->mouse_button_flags = 0;
    1.62 -
    1.63                  WIN_UpdateClipCursor(data->window);
    1.64 +                WIN_CheckAsyncMouseRelease(data);
    1.65  
    1.66                  /*
    1.67                   * FIXME: Update keyboard state
    1.68 @@ -578,6 +582,9 @@
    1.69          {
    1.70              data->in_modal_loop = SDL_FALSE;
    1.71              WIN_UpdateClipCursor(data->window);
    1.72 +
    1.73 +            /* The mouse may have been released during the modal loop */
    1.74 +            WIN_CheckAsyncMouseRelease(data);
    1.75          }
    1.76          break;
    1.77