Fixed relative mouse mode with multiple windows.
authorSam Lantinga <slouken@libsdl.org>
Mon, 24 Feb 2014 22:37:58 -0800
changeset 82523e4846dc97b1
parent 8251 833eae6867c2
child 8253 75ad8ebb3768
Fixed relative mouse mode with multiple windows.
The window cursor clipping will be taken care of when SDL_UpdateWindowGrab() is called.
src/video/windows/SDL_windowsmouse.c
     1.1 --- a/src/video/windows/SDL_windowsmouse.c	Mon Feb 24 22:36:24 2014 -0800
     1.2 +++ b/src/video/windows/SDL_windowsmouse.c	Mon Feb 24 22:37:58 2014 -0800
     1.3 @@ -196,44 +196,20 @@
     1.4  WIN_SetRelativeMouseMode(SDL_bool enabled)
     1.5  {
     1.6      RAWINPUTDEVICE rawMouse = { 0x01, 0x02, 0, NULL }; /* Mouse: UsagePage = 1, Usage = 2 */
     1.7 -    HWND hWnd;
     1.8 -    hWnd = GetActiveWindow();
     1.9  
    1.10 -    rawMouse.hwndTarget = hWnd;
    1.11 -    if(!enabled) {
    1.12 +    if (!enabled) {
    1.13          rawMouse.dwFlags |= RIDEV_REMOVE;
    1.14 -        rawMouse.hwndTarget = NULL;
    1.15      }
    1.16  
    1.17 -
    1.18      /* (Un)register raw input for mice */
    1.19      if (RegisterRawInputDevices(&rawMouse, 1, sizeof(RAWINPUTDEVICE)) == FALSE) {
    1.20  
    1.21          /* Only return an error when registering. If we unregister and fail, then
    1.22          it's probably that we unregistered twice. That's OK. */
    1.23 -        if(enabled) {
    1.24 +        if (enabled) {
    1.25              return SDL_Unsupported();
    1.26          }
    1.27      }
    1.28 -
    1.29 -    if (enabled) {
    1.30 -        LONG cx, cy;
    1.31 -        RECT rect;
    1.32 -        GetWindowRect(hWnd, &rect);
    1.33 -
    1.34 -        cx = (rect.left + rect.right) / 2;
    1.35 -        cy = (rect.top + rect.bottom) / 2;
    1.36 -
    1.37 -        /* Make an absurdly small clip rect */
    1.38 -        rect.left = cx-1;
    1.39 -        rect.right = cx+1;
    1.40 -        rect.top = cy-1;
    1.41 -        rect.bottom = cy+1;
    1.42 -
    1.43 -        ClipCursor(&rect);
    1.44 -    } else {
    1.45 -        ClipCursor(NULL);
    1.46 -    }
    1.47      return 0;
    1.48  }
    1.49