Update the cursor clipping each frame, in case it was stolen by another application.
authorSam Lantinga <slouken@libsdl.org>
Sun, 26 Aug 2018 20:37:23 -0700
changeset 121542a9b4339468b
parent 12153 de4288fa5b0b
child 12155 751cdc74d55c
Update the cursor clipping each frame, in case it was stolen by another application.
src/video/windows/SDL_windowsevents.c
     1.1 --- a/src/video/windows/SDL_windowsevents.c	Sun Aug 26 10:34:23 2018 -0700
     1.2 +++ b/src/video/windows/SDL_windowsevents.c	Sun Aug 26 20:37:23 2018 -0700
     1.3 @@ -399,11 +399,6 @@
     1.4      }
     1.5  #endif /* WMMSG_DEBUG */
     1.6  
     1.7 -    /* Update the clipping rect in case someone else has stolen it */
     1.8 -    /* FIXME: Is this function cheap enough to call this frequently?
     1.9 -    WIN_UpdateClipCursor(data->window);
    1.10 -    */
    1.11 -
    1.12      if (IME_HandleMessage(hwnd, msg, wParam, &lParam, data->videodata))
    1.13          return 0;
    1.14  
    1.15 @@ -478,7 +473,6 @@
    1.16                  }
    1.17  
    1.18                  if (GetClipCursor(&rect) && SDL_memcmp(&rect, &data->cursor_clipped_rect, sizeof(rect) == 0)) {
    1.19 -SDL_Log("Windows deactivate, ClipCursor(NULL)\n");
    1.20                      ClipCursor(NULL);
    1.21                      SDL_zero(data->cursor_clipped_rect);
    1.22                  }
    1.23 @@ -1036,6 +1030,20 @@
    1.24      }
    1.25  }
    1.26  
    1.27 +static void WIN_UpdateClipCursorForWindows()
    1.28 +{
    1.29 +    SDL_VideoDevice *_this = SDL_GetVideoDevice();
    1.30 +    SDL_Window *window;
    1.31 +
    1.32 +    if (_this) {
    1.33 +        for (window = _this->windows; window; window = window->next) {
    1.34 +            if (window->driverdata) {
    1.35 +                WIN_UpdateClipCursor(window);
    1.36 +            }
    1.37 +        }
    1.38 +    }
    1.39 +}
    1.40 +
    1.41  /* A message hook called before TranslateMessage() */
    1.42  static SDL_WindowsMessageHook g_WindowsMessageHook = NULL;
    1.43  static void *g_WindowsMessageHookData = NULL;
    1.44 @@ -1081,6 +1089,9 @@
    1.45      if ((keystate[SDL_SCANCODE_RSHIFT] == SDL_PRESSED) && !(GetKeyState(VK_RSHIFT) & 0x8000)) {
    1.46          SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RSHIFT);
    1.47      }
    1.48 +
    1.49 +    /* Update the clipping rect in case someone else has stolen it */
    1.50 +    WIN_UpdateClipCursorForWindows();
    1.51  }
    1.52  
    1.53  /* to work around #3931, a bug introduced in Win10 Fall Creators Update (build nr. 16299)