Fixed bug 4748 - Calling WIN_UpdateClipCursor() / WIN_UpdateClipCursorForWindows() on WIN_PumpEvents() causes beeping and choppy mouse cursor movement, right-click doesn't work

The problem here was calling ClipCursor() continuously in a tight loop. Fixed by only calling ClipCursor() if the clip area needs to be updated.
This commit is contained in:
Sam Lantinga 2020-02-11 10:08:22 -08:00
parent 668276fe81
commit c31727c7e7
1 changed files with 5 additions and 2 deletions

View File

@ -938,11 +938,14 @@ WIN_UpdateClipCursor(SDL_Window *window)
data->cursor_clipped_rect = rect;
}
} else {
RECT clipped_rect;
if (GetClientRect(data->hwnd, &rect) && !IsRectEmpty(&rect)) {
ClientToScreen(data->hwnd, (LPPOINT) & rect);
ClientToScreen(data->hwnd, (LPPOINT) & rect + 1);
if (ClipCursor(&rect)) {
data->cursor_clipped_rect = rect;
if (!GetClipCursor(&clipped_rect) || SDL_memcmp(&rect, &clipped_rect, sizeof(rect)) != 0) {
if (ClipCursor(&rect)) {
data->cursor_clipped_rect = rect;
}
}
}
}